Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!   (85,001 visits to this link)

    2. News

    1. GTA Online

      1. Find Lobbies & Players
      2. Guides & Strategies
      3. Vehicles
      4. Content Creator
      5. Help & Support
    2. Crews

      1. Events
      2. Recruitment
    1. Grand Theft Auto Series

    2. GTA Next

    3. GTA V

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

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA Mods
    5. GTA Chinatown Wars

    6. GTA Vice City Stories

    7. GTA Liberty City Stories

    8. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    9. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    10. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    11. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    12. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

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

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption 2

    2. Red Dead Redemption

    3. Rockstar Games

    1. Off-Topic

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

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

    2. Site Suggestions

crosire

Community Script Hook V .NET

Recommended Posts

Loset
        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

Share this post


Link to post
Share on other sites
crosire

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);

Share this post


Link to post
Share on other sites
slik

 

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

Share this post


Link to post
Share on other sites
Loset

can you add

 

Any NETWORK_GET_PLAYER_INDEX(Ped PedHandle) // 0xBE1C1506

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
fengyeblade

thx few years ago HarezX(meybe) make the scripthookdotnet. very good.

Share this post


Link to post
Share on other sites
Loset
                    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 =/

Share this post


Link to post
Share on other sites
r34ld34l

 

                    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?

Share this post


Link to post
Share on other sites
Loset

 

 

                    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

Share this post


Link to post
Share on other sites
xsploit

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

Share this post


Link to post
Share on other sites
Reck1501

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)

Share this post


Link to post
Share on other sites
TheVideoVolcano

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

Share this post


Link to post
Share on other sites
Reck1501

 

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

Share this post


Link to post
Share on other sites
Raxdiam

Any examples of drawing text on-screen?

Share this post


Link to post
Share on other sites
crosire

 

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?

Share this post


Link to post
Share on other sites
TheVideoVolcano

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

Share this post


Link to post
Share on other sites
Raxdiam

 

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

Share this post


Link to post
Share on other sites
crosire

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

Share this post


Link to post
Share on other sites
timnboys

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.

Share this post


Link to post
Share on other sites
crosire

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

Share this post


Link to post
Share on other sites
TheVideoVolcano

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

Share this post


Link to post
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);	}

Share this post


Link to post
Share on other sites
timnboys

 

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

Share this post


Link to post
Share on other sites
Raxdiam

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.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
TheVideoVolcano

 

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

Share this post


Link to post
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

 

 

Share this post


Link to post
Share on other sites
Rugz007

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

Share this post


Link to post
Share on other sites
crosire

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.

Share this post


Link to post
Share on other sites
Rugz007

oh okay :p thanks i forgot that :D thanks for help.

Share this post


Link to post
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

×

Important Information

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