Loset Posted April 29, 2015 Share Posted April 29, 2015 (edited) 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 April 29, 2015 by Loset Link to comment Share on other sites More sharing options...
crosire Posted April 29, 2015 Author Share Posted April 29, 2015 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 More sharing options...
slik Posted April 29, 2015 Share Posted April 29, 2015 (edited) 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 April 29, 2015 by slik Link to comment Share on other sites More sharing options...
Loset Posted April 29, 2015 Share Posted April 29, 2015 can you add Any NETWORK_GET_PLAYER_INDEX(Ped PedHandle) // 0xBE1C1506 Link to comment Share on other sites More sharing options...
monsterxsync Posted April 29, 2015 Share Posted April 29, 2015 (edited) 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 April 29, 2015 by monsterxsync Link to comment Share on other sites More sharing options...
fengyeblade Posted April 29, 2015 Share Posted April 29, 2015 thx few years ago HarezX(meybe) make the scripthookdotnet. very good. Link to comment Share on other sites More sharing options...
Loset Posted April 29, 2015 Share Posted April 29, 2015 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 More sharing options...
r34ld34l Posted April 29, 2015 Share Posted April 29, 2015 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 More sharing options...
Loset Posted April 29, 2015 Share Posted April 29, 2015 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 More sharing options...
xsploit Posted April 29, 2015 Share Posted April 29, 2015 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 More sharing options...
Reck1501 Posted April 29, 2015 Share Posted April 29, 2015 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 More sharing options...
identitymatrix Posted April 29, 2015 Share Posted April 29, 2015 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 More sharing options...
Reck1501 Posted April 29, 2015 Share Posted April 29, 2015 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 More sharing options...
Raxdiam Posted April 29, 2015 Share Posted April 29, 2015 Any examples of drawing text on-screen? Link to comment Share on other sites More sharing options...
crosire Posted April 29, 2015 Author Share Posted April 29, 2015 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 More sharing options...
identitymatrix Posted April 29, 2015 Share Posted April 29, 2015 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 More sharing options...
Raxdiam Posted April 29, 2015 Share Posted April 29, 2015 (edited) 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 April 29, 2015 by Raxdiam Link to comment Share on other sites More sharing options...
crosire Posted April 29, 2015 Author Share Posted April 29, 2015 (edited) 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 April 29, 2015 by Crosire Link to comment Share on other sites More sharing options...
timnboys Posted April 29, 2015 Share Posted April 29, 2015 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 More sharing options...
crosire Posted April 29, 2015 Author Share Posted April 29, 2015 (edited) 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 April 29, 2015 by Crosire Link to comment Share on other sites More sharing options...
identitymatrix Posted April 30, 2015 Share Posted April 30, 2015 (edited) 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 April 30, 2015 by TheVideoVolcano Link to comment Share on other sites More sharing options...
unknown modder Posted April 30, 2015 Share Posted April 30, 2015 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 More sharing options...
timnboys Posted April 30, 2015 Share Posted April 30, 2015 (edited) 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 April 30, 2015 by timnboys Link to comment Share on other sites More sharing options...
Raxdiam Posted April 30, 2015 Share Posted April 30, 2015 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. identitymatrix 1 Link to comment Share on other sites More sharing options...
unknown modder Posted April 30, 2015 Share Posted April 30, 2015 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 More sharing options...
identitymatrix Posted April 30, 2015 Share Posted April 30, 2015 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 More sharing options...
monsterxsync Posted April 30, 2015 Share Posted April 30, 2015 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 More sharing options...
Rugz007 Posted April 30, 2015 Share Posted April 30, 2015 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 More sharing options...
crosire Posted April 30, 2015 Author Share Posted April 30, 2015 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 More sharing options...
Rugz007 Posted April 30, 2015 Share Posted April 30, 2015 oh okay thanks i forgot that thanks for help. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now