Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. The Criminal Enterprises
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Support

    3. Suggestions

*DO NOT* SHARE MEDIA OR LINKS TO LEAKED COPYRIGHTED MATERIAL. Discussion is allowed.

Community Script Hook V .NET


crosire
 Share

Recommended Posts

        Entity test = Game.Player.GetTargetedEntity();            if (test is Vehicle)            {                Vehicle car = test as Vehicle;                lastcar = car.GetHashCode(); Vehicle newcar = Function.Call<Vehicle>(Hash.CREATE_VEHICLE, lastcar, Game.Player.Character.Position.X, Game.Player.Character.Position.Y, Game.Player.Character.Position.Z, 0.0,1,1);            }

 

so I updated the hook from the sdk you made some amazing changes =P

and finally I got things working.. but I wonder how can I use this function .. it doesn't spawn new vehicles?

 

Never mind: just saw you updated world.createvehicle =P

Edited by Loset
Link to comment
Share on other sites

GetHashCode doesn't return the model hash, it's a function derivered from System.Object. To get the model hash you can use the GTA.Model class.

 

I suggest updating to the latest commit just pushed a few minutes ago. JohnnyCrazy added support for creating vehicles using the scripting API.

Vehicle newcar = World.CreateVehicle(new Model("some_model_name).Hash, Game.Player.Character.Position);
Link to comment
Share on other sites

 

GetHashCode doesn't return the model hash, it's a function derivered from System.Object. To get the model hash you can use the GTA.Model class.

 

I suggest updating to the latest commit just pushed a few minutes ago. JohnnyCrazy added support for creating vehicles using the scripting API.

Vehicle newcar = World.CreateVehicle(new Model("some_model_name).Hash, Game.Player.Character.Position);

I'd suggest something like this:

Ped newped = World.CreateEntity(new Ped( Ped specific options ), World specific options);Vehicle newcar = World.CreateEntity(new Vehicle(new Model("some_model_name").Hash), Game.Player.Character.Position);
Edited by slik
Link to comment
Share on other sites

monsterxsync

This is just awesome... but i have a question how would i go about making a GUI for this in c#? using GDI+ or something?
and how come i keep getting errors when trying to build this from source?

Error 1 error C3845: 'GTA::ScriptSettings::mValues': only static data members can be initialized inside a ref class or value type f:\github\scripthookvdotnet\source\Settings.hpp 36 1 ScriptHookVDotNet
Edited by monsterxsync
Link to comment
Share on other sites

                    Player me = new Player(Function.Call<int>(Hash.NETWORK_GET_PLAYER_INDEX, Game.Player.Character.ID));                    me.WantedLevel = 4;                    Function.Call(Hash.SET_PLAYER_WANTED_LEVEL, me.ID, 4, false);                    Function.Call(Hash.SET_PLAYER_WANTED_LEVEL_NOW,me.ID, false);                    Function.Call(Hash.SET_PLAYER_WANTED_LEVEL, me.ID, 4, 0);                    Function.Call(Hash.SET_PLAYER_WANTED_LEVEL_NOW, me.ID, 0);

so after I added the hash.. =/ almost everytime I tried using Hash functions I failed =/

Link to comment
Share on other sites

 

                    Player me = new Player(Function.Call<int>(Hash.NETWORK_GET_PLAYER_INDEX, Game.Player.Character.ID));                    me.WantedLevel = 4;                    Function.Call(Hash.SET_PLAYER_WANTED_LEVEL, me.ID, 4, false);                    Function.Call(Hash.SET_PLAYER_WANTED_LEVEL_NOW,me.ID, false);                    Function.Call(Hash.SET_PLAYER_WANTED_LEVEL, me.ID, 4, 0);                    Function.Call(Hash.SET_PLAYER_WANTED_LEVEL_NOW, me.ID, 0);

so after I added the hash.. =/ almost everytime I tried using Hash functions I failed =/

 

Is that for online?

Link to comment
Share on other sites

 

 

                    Player me = new Player(Function.Call<int>(Hash.NETWORK_GET_PLAYER_INDEX, Game.Player.Character.ID));                    me.WantedLevel = 4;                    Function.Call(Hash.SET_PLAYER_WANTED_LEVEL, me.ID, 4, false);                    Function.Call(Hash.SET_PLAYER_WANTED_LEVEL_NOW,me.ID, false);                    Function.Call(Hash.SET_PLAYER_WANTED_LEVEL, me.ID, 4, 0);                    Function.Call(Hash.SET_PLAYER_WANTED_LEVEL_NOW, me.ID, 0);

so after I added the hash.. =/ almost everytime I tried using Hash functions I failed =/

 

Is that for online?

 

kinda

Link to comment
Share on other sites

I'm just wondering if I can change all the models with world.set_player_model or something like that?

Link to comment
Share on other sites

I can't get this to load. I've tried downloading the pre-compiled version, and compiling it myself, neither of them works (doesn't load, and no error log)

Link to comment
Share on other sites

identitymatrix

I can't get this to load. I've tried downloading the pre-compiled version, and compiling it myself, neither of them works (doesn't load, and no error log)

 

Please give us your ScriptHookDotNet.log

Link to comment
Share on other sites

 

I can't get this to load. I've tried downloading the pre-compiled version, and compiling it myself, neither of them works (doesn't load, and no error log)

 

Please give us your ScriptHookDotNet.log

 

As I said, there's no log. However, I tried reinstalling GTA V, and that seems to have fixed it

Link to comment
Share on other sites

 

As I said, there's no log. However, I tried reinstalling GTA V, and that seems to have fixed it

 

But you installed an ASI loader + Script Hook V, right? What does the asiloader.log file say?

Link to comment
Share on other sites

identitymatrix

Any examples of drawing text on-screen?

 

*exhale* Well.... No apparent single native function that simply displays text, but this is how it is done in the scripts and alexander blades trainer.

 

Wish we had litteral_strings_now :@

 

SET_TEXT_FONT(0);
SET_TEXT_SCALE(0.55, 0.55);
SET_TEXT_COLOUR(255, 255, 255, 255);
SET_TEXT_WRAP(0.0, 1.0);
SET_TEXT_CENTRE(1);
SET_TEXT_DROPSHADOW(0, 0, 0, 0, 0);
SET_TEXT_EDGE(1, 0, 0, 0, 205);
if (statusTextGxtEntry)
{
_SET_TEXT_ENTRY((char *)statusText.c_str());
} else
{
_SET_TEXT_ENTRY("STRING");
_ADD_TEXT_COMPONENT_STRING((char *)statusText.c_str());
}
UI::_DRAW_TEXT(0.5, 0.5);

 

Any examples of drawing text on-screen?

 

*exhale* Well.... No apparent single native function that simply displays text, but this is how it is done in the scripts and alexander blades trainer.

 

Wish we had litteral_strings_now :@

 

SET_TEXT_FONT(0);
SET_TEXT_SCALE(0.55, 0.55);
SET_TEXT_COLOUR(255, 255, 255, 255);
SET_TEXT_WRAP(0.0, 1.0);
SET_TEXT_CENTRE(1);
SET_TEXT_DROPSHADOW(0, 0, 0, 0, 0);
SET_TEXT_EDGE(1, 0, 0, 0, 205);
if (statusTextGxtEntry)
{
_SET_TEXT_ENTRY((char *)statusText.c_str());
} else
{
_SET_TEXT_ENTRY("STRING");
_ADD_TEXT_COMPONENT_STRING((char *)statusText.c_str());
}
UI::_DRAW_TEXT(0.5, 0.5);

 

 

I'm just not sure how to display the actual text as I see no function like draw_text

 

Also, Crosire, If you leave gta v for a while and come back the insert key reload script functionality is lost. say if you are writting a fair bit of code

Link to comment
Share on other sites

 

Any examples of drawing text on-screen?

 

*exhale* Well.... No apparent single native function that simply displays text, but this is how it is done in the scripts and alexander blades trainer.

 

Wish we had litteral_strings_now :@

 

SET_TEXT_FONT(0);
SET_TEXT_SCALE(0.55, 0.55);
SET_TEXT_COLOUR(255, 255, 255, 255);
SET_TEXT_WRAP(0.0, 1.0);
SET_TEXT_CENTRE(1);
SET_TEXT_DROPSHADOW(0, 0, 0, 0, 0);
SET_TEXT_EDGE(1, 0, 0, 0, 205);
if (statusTextGxtEntry)
{
_SET_TEXT_ENTRY((char *)statusText.c_str());
} else
{
_SET_TEXT_ENTRY("STRING");
_ADD_TEXT_COMPONENT_STRING((char *)statusText.c_str());
}
UI::_DRAW_TEXT(0.5, 0.5);

 

I'm aware of how it's done in Alexander Blade's native trainer, but my attempt to adapt it to C# did not work, and I'm out of ideas, which is my reason for asking here.

Edited by Raxdiam
Link to comment
Share on other sites

Directly translates to the following C# code (until there is a proper wrapper for UI drawing in the scripting API):

using GTA.Native;string statusText = "Status";bool statusTextGxtEntry = false;Function.Call(Hash.SET_TEXT_FONT, 0);Function.Call(Hash.SET_TEXT_SCALE, 0.55f, 0.55f);Function.Call(Hash.SET_TEXT_COLOUR, 255, 255, 255, 255);Function.Call(Hash.SET_TEXT_WRAP, 0.0f, 1.0f);Function.Call(Hash.SET_TEXT_CENTRE, 1);Function.Call(Hash.SET_TEXT_DROPSHADOW, 0, 0, 0, 0, 0);Function.Call(Hash.SET_TEXT_EDGE, 1, 0, 0, 0, 205);if (statusTextGxtEntry){Function.Call(Hash._SET_TEXT_ENTRY, statusText);}else{Function.Call(Hash._SET_TEXT_ENTRY, "STRING");Function.Call(Hash._ADD_TEXT_COMPONENT_STRING, statusText);}Function.Call(Hash._DRAW_TEXT, 0.5f, 0.5f);

 

Also, Crosire, If you leave gta v for a while and come back the insert key reload script functionality is lost. say if you are writting a fair bit of code

 

 

Yeah, it currently seems to crash after being inactive for a while.

 

 

--------

 

 

Just uploaded a new binary (v0.3.0) build from the latest commit on Github. It includes a lot of additions to the scripting API and a few fixes: now lets you create peds, vehicles, etc.

 

Thanks to everybody who was involved =).

Edited by Crosire
Link to comment
Share on other sites

I am going to just ask if anyone would throw me a tip on how to change the player's model? as I need to change their model to one of the cop models.

Link to comment
Share on other sites

I am going to just ask if anyone would throw me a tip on how to change the player's model? as I need to change their model to one of the cop models.

Not part of the scripting API yet, but try something like this manually (requires version 0.3.0):

GTA.Model copmodel = "s_m_y_cop_01";copmodel.Request(1000);GTA.Native.Function.Call(GTA.Native.Hash.SET_PLAYER_MODEL, Game.Player, copmodel.Hash);

This attempts to load the cop model into memory (1 second timeout) and then sets that model as player model.

Edited by Crosire
Link to comment
Share on other sites

identitymatrix

Directly translates to the following C# code (until there is a proper wrapper for UI drawing in the scripting API):

using GTA.Native;string statusText = "Status";bool statusTextGxtEntry = false;Function.Call(Hash.SET_TEXT_FONT, 0);Function.Call(Hash.SET_TEXT_SCALE, 0.55f, 0.55f);Function.Call(Hash.SET_TEXT_COLOUR, 255, 255, 255, 255);Function.Call(Hash.SET_TEXT_WRAP, 0.0f, 1.0f);Function.Call(Hash.SET_TEXT_CENTRE, 1);Function.Call(Hash.SET_TEXT_DROPSHADOW, 0, 0, 0, 0, 0);Function.Call(Hash.SET_TEXT_EDGE, 1, 0, 0, 0, 205);if (statusTextGxtEntry){Function.Call(Hash._SET_TEXT_ENTRY, statusText);}else{Function.Call(Hash._SET_TEXT_ENTRY, "STRING");Function.Call(Hash._ADD_TEXT_COMPONENT_STRING, statusText);}Function.Call(Hash._DRAW_TEXT, 0.5f, 0.5f);

 

Also, Crosire, If you leave gta v for a while and come back the insert key reload script functionality is lost. say if you are writting a fair bit of code

 

 

Yeah, it currently seems to crash after being inactive for a while.

 

 

--------

 

 

Just uploaded a new binary (v0.3.0) build from the latest commit on Github. It includes a lot of additions to the scripting API and a few fixes: now lets you create peds, vehicles, etc.

 

Thanks to everybody who was involved =).

 

Hmmm... this is very useful. It actually works, (when rewritten for vb.net)

 

Private Sub msg(ByVal msg As String, ByVal duration As Int16, Optional ByVal isGxtEntry As Boolean = False)        Dim statusText As String = msg        Dim statusTextGxtEntry As Boolean = isGxtEntry               Native.Function.Call(Native.Hash.SET_TEXT_FONT, 0)        Native.Function.Call(Native.Hash.SET_TEXT_SCALE, 0.55F, 0.55F)        Native.Function.Call(Native.Hash.SET_TEXT_COLOUR, 255, 255, 255, 255)        Native.Function.Call(Native.Hash.SET_TEXT_WRAP, 0.0F, 1.0F)        Native.Function.Call(Native.Hash.SET_TEXT_CENTRE, 1)        Native.Function.Call(Native.Hash.SET_TEXT_DROPSHADOW, 0, 0, 0, 0, 0)        Native.Function.Call(Native.Hash.SET_TEXT_EDGE, 1, 0, 0, 0, 205)        If (statusTextGxtEntry) Then            Native.Function.Call(Native.Hash._SET_TEXT_ENTRY, statusText)        Else            Native.Function.Call(Native.Hash._SET_TEXT_ENTRY, "STRING")            Native.Function.Call(Native.Hash._ADD_TEXT_COMPONENT_STRING, statusText)            Native.Function.Call(Native.Hash._DRAW_TEXT, 0.5F, 0.5F)                  End If    End Sub

This function only print on screen for about 50ms, How exactly do I do get it do stay on screen for a certain duration? Alexander use a function called 'GetTickCount()' but I don't understand when he defined that function in his trainer as it has (or seems) to have no origin.

 

He uses...

 

if GetTickCount() < maxTickCount

and getTickCount() + waitTime;

Edited by TheVideoVolcano
Link to comment
Share on other sites

unknown modder

Hmmm... this is very useful. It actually works, (when rewritten for vb.net)

 

Private Sub msg(ByVal msg As String, ByVal duration As Int16, Optional ByVal isGxtEntry As Boolean = False)        Dim statusText As String = msg        Dim statusTextGxtEntry As Boolean = isGxtEntry               Native.Function.Call(Native.Hash.SET_TEXT_FONT, 0)        Native.Function.Call(Native.Hash.SET_TEXT_SCALE, 0.55F, 0.55F)        Native.Function.Call(Native.Hash.SET_TEXT_COLOUR, 255, 255, 255, 255)        Native.Function.Call(Native.Hash.SET_TEXT_WRAP, 0.0F, 1.0F)        Native.Function.Call(Native.Hash.SET_TEXT_CENTRE, 1)        Native.Function.Call(Native.Hash.SET_TEXT_DROPSHADOW, 0, 0, 0, 0, 0)        Native.Function.Call(Native.Hash.SET_TEXT_EDGE, 1, 0, 0, 0, 205)        If (statusTextGxtEntry) Then            Native.Function.Call(Native.Hash._SET_TEXT_ENTRY, statusText)        Else            Native.Function.Call(Native.Hash._SET_TEXT_ENTRY, "STRING")            Native.Function.Call(Native.Hash._ADD_TEXT_COMPONENT_STRING, statusText)            Native.Function.Call(Native.Hash._DRAW_TEXT, 0.5F, 0.5F)                  End If    End Sub

This function only print on screen for about 50ms, How exactly do I do get it do stay on screen for a certain duration? Alexander use a function called 'GetTickCount()' but I don't understand when he defined that function in his trainer as it has (or seems) to have no origin.

 

He uses...

 

if GetTickCount() < maxTickCount

and getTickCount() + waitTime;

 

Draw_text functions need to be called each game time, if you want a message to stay there, perhaps consider using print instead

this code will need a slight bit of tweaking for you but the natives and what to call them with are still there

	void UI::Print(char *Text, int time)	{		Natives::_0xB87A37EEB7FAA67D((char *)"STRING");		Natives::_ADD_TEXT_COMPONENT_STRING(Text);		Natives::_0x9D77056A530643F6(time, 1);	}
Link to comment
Share on other sites

 

I am going to just ask if anyone would throw me a tip on how to change the player's model? as I need to change their model to one of the cop models.

Not part of the scripting API yet, but try something like this manually (requires version 0.3.0):

GTA.Model copmodel = "s_m_y_cop_01";copmodel.Request(1000);GTA.Native.Function.Call(GTA.Native.Hash.SET_PLAYER_MODEL, Game.Player, copmodel.Hash);

This attempts to load the cop model into memory (1 second timeout) and then sets that model as player model.

Okay it appears I forgot to replace ScriptHookDotNet.asi for the 0.3.0 version which for anyone else having this issue of methodnotfound error you have to replace your .asi too for each version.

Edited by timnboys
Link to comment
Share on other sites

Draw_text functions need to be called each game time, if you want a message to stay there, perhaps consider using print instead

this code will need a slight bit of tweaking for you but the natives and what to call them with are still there

	void UI::Print(char *Text, int time)	{		Natives::_0xB87A37EEB7FAA67D((char *)"STRING");		Natives::_ADD_TEXT_COMPONENT_STRING(Text);		Natives::_0x9D77056A530643F6(time, 1);	}

 

Translated to C#:

void Print(string text, int time = 2500){    GTA.Native.Function.Call(Hash._0xB87A37EEB7FAA67D, "STRING");    GTA.Native.Function.Call(Hash._ADD_TEXT_COMPONENT_STRING, text);    GTA.Native.Function.Call(Hash._0x9D77056A530643F6, time, 1);}

 

Translated to VB:

Private Sub SetStatusText(text As String, Optional time As Integer = 2500)    GTA.Native.Function.Call(Hash._0xB87A37EEB7FAA67D, "STRING")    GTA.Native.Function.Call(Hash._ADD_TEXT_COMPONENT_STRING, text)    GTA.Native.Function.Call(Hash._0x9D77056A530643F6, time, 1)End Sub

This seems to work for me. Thank you unknown modder.

  • Like 1
Link to comment
Share on other sites

unknown modder

I dont know why you have added vector2 as a native return type, there isnt a single native in the game that returns 2 items.

Link to comment
Share on other sites

identitymatrix

 

Draw_text functions need to be called each game time, if you want a message to stay there, perhaps consider using print instead

this code will need a slight bit of tweaking for you but the natives and what to call them with are still there

	void UI::Print(char *Text, int time)	{		Natives::_0xB87A37EEB7FAA67D((char *)"STRING");		Natives::_ADD_TEXT_COMPONENT_STRING(Text);		Natives::_0x9D77056A530643F6(time, 1);	}

 

Translated to C#:

void Print(string text, int time = 2500){    GTA.Native.Function.Call(Hash._0xB87A37EEB7FAA67D, "STRING");    GTA.Native.Function.Call(Hash._ADD_TEXT_COMPONENT_STRING, text);    GTA.Native.Function.Call(Hash._0x9D77056A530643F6, time, 1);}

 

Translated to VB:

Private Sub SetStatusText(text As String, Optional time As Integer = 2500)    GTA.Native.Function.Call(Hash._0xB87A37EEB7FAA67D, "STRING")    GTA.Native.Function.Call(Hash._ADD_TEXT_COMPONENT_STRING, text)    GTA.Native.Function.Call(Hash._0x9D77056A530643F6, time, 1)End Sub

This seems to work for me. Thank you unknown modder.

 

 

Where do the hash.0x9D77056A530643F6 and hash._0xB87A37EEB7FAA67D come from?

 

They aren't in the native db or scocl scripts

Link to comment
Share on other sites

monsterxsync

 


Where do the hash.0x9D77056A530643F6 and hash._0xB87A37EEB7FAA67D come from?They aren't in the native db or scocl scripts
would also like to know this :) cant find em anywhere

 

 

Link to comment
Share on other sites

Guys when I use a native function,the log says "the type or namespace name "Hash" does not exist in the name space 'GTA.Native'(are you missing an assembly reference?)

 

In vs it gives no errors :/

 

Please help

Link to comment
Share on other sites

Guys when I use a native function,the log says "the type or namespace name "Hash" does not exist in the name space 'GTA.Native'(are you missing an assembly reference?)

 

In vs it gives no errors :/

 

Please help

Make sure you use the latest ASI (0.2.0 or higher).

 

I dont know why you have added vector2 as a native return type, there isnt a single native in the game that returns 2 items.

Just in case you use a native returning a Vector3, but you don't care for the Z component.

 

 

This function only print on screen for about 50ms, How exactly do I do get it do stay on screen for a certain duration? Alexander use a function called 'GetTickCount()' but I don't understand when he defined that function in his trainer as it has (or seems) to have no origin.

 

 

He uses...

 

if GetTickCount() < maxTickCount

and getTickCount() + waitTime;

 

As unknown modders said, it has to run every frame. To achieve that set the script "Interval" property to zero.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.