unknown modder Posted May 19, 2015 Share Posted May 19, 2015 (edited) I did a bit of tweaking to enable initialising outputarguments(set the pointer value) now I can use things like vehicle pointers in functions like this Function.Call(Hash.SET_ENTITY_AS_MISSION_ENTITY, vehicle.ID, false, true);Function.Call(Hash.DELETE_VEHICLE, OutputArgument.Pointer<int>(vehicle.ID)); The issue Im having is it wont actually delete the vehicle all the time, and if I try and call it again on the same vehicle it freezes. Whats stranger is I have a different asi mod that deletes all vehicles around me. once I use this that mod cant delete the vehicle either. That delete vehicle does work using the same SET_ENTITY_AS_MISSION_ENTITY(handle, false, true); DELETE_VEHICLE(&handle); I did a check using the OutputArgument.GetResult<int> and it indeed returned the correct vehicle handle so thats not my issue. This is the code for the pointer argument generic <typename T> void OutputArgument::SetPointer(T data) { Type ^Type = T::typeid; if (Type == Boolean::typeid) *reinterpret_cast<bool *>(mStorage) = (bool)data; else if (Type == Int32::typeid) *reinterpret_cast<int *>(mStorage) = (int)data; else if (Type == Single::typeid) *reinterpret_cast<float *>(mStorage) = (float)data; else throw gcnew InvalidCastException(String::Concat("Unable to cast native value to object of type '", (T::typeid)->FullName, "'")); } generic <typename T> OutputArgument ^OutputArgument::Pointer(T data) { OutputArgument ^out = gcnew OutputArgument(); out->SetPointer<T>(data); return out; } Edited May 19, 2015 by unknown modder Cyron43 1 Link to comment Share on other sites More sharing options...
Cyron43 Posted May 20, 2015 Share Posted May 20, 2015 I did a bit of tweaking to enable initialising outputarguments(set the pointer value) now I can use things like vehicle pointers in functions like this Function.Call(Hash.SET_ENTITY_AS_MISSION_ENTITY, vehicle.ID, false, true);Function.Call(Hash.DELETE_VEHICLE, OutputArgument.Pointer<int>(vehicle.ID)); The issue Im having is it wont actually delete the vehicle all the time, and if I try and call it again on the same vehicle it freezes. Great idea to provide that Pointer property. *thumbs up* About your problem: I remember having read somewhere that whenever we want to delete either a ped or a vehicle, we must mark it as no longer needed before. Link to comment Share on other sites More sharing options...
willywill Posted May 20, 2015 Share Posted May 20, 2015 Is it just me or does SHOOT_SINGLE_BULLET_BETWEEN_COORDS not work at all? I tried literally everything and it does nothing. Can someone post a working example please? Link to comment Share on other sites More sharing options...
Prof_Farnsworth Posted May 20, 2015 Share Posted May 20, 2015 Hey guys, I don't think I am using this right: i1 = Settings.GetValue<int>("SETTINGS", "carjack_Chance", 30); Here is my ini: [sETTINGS]carjack_Chance = 10 Anyone be able to point me in the right direction? Thanks in advance. Link to comment Share on other sites More sharing options...
crosire Posted May 20, 2015 Author Share Posted May 20, 2015 About your problem: I remember having read somewhere that whenever we want to delete either a ped or a vehicle, we must mark it as no longer needed before. Apparently it's the other way round. You need to make them a mission entity before deleting for it to work. "Entity.Delete" already does all that for you and I just checked again, it correctly deleted all peds and props I tested with. Hey guys, I don't think I am using this right: That looks pretty correct to me. What's the problem? Link to comment Share on other sites More sharing options...
Moder L Posted May 20, 2015 Share Posted May 20, 2015 Try like this n see if it will work..? Prop myprop = World.CreateProp(modelString, Game.Player.Character.Position, true, true);myprop.MarkAsNoLongerNeeded();Function.Call<Prop>(Hash.DELETE_OBJECT, myprop.Handle); Please don't! That will definitly crash your game, since DELETE_OBJECT takes a pointer to a handle, not a handle. =) And what is the correct way to delete prop? Link to comment Share on other sites More sharing options...
willywill Posted May 20, 2015 Share Posted May 20, 2015 (edited) Just to reiterate because my last post I was in a rush. I am unable to get SHOOT_SINGLE_BULLET_BETWEEN_COORDS to work in .NET yet it seems to work fine in C++ or lua. The problem is I am most comfortable with programming in C# and I really love how far this has come already, I was just really hoping for this exact functionality to work for my script that I am working on. I checked the Trainer/SDK files directly from Alexander Blade and I even looked into the GTA V decompiled scripts so that I could use them exactly the same, still with no such luck in getting it to work. For example, this is a line directly from the decompiled scripts using https://www.gta5-mods.com/tools/dev-tool-search-gta-v-game-scripts GAMEPLAY::SHOOT_SINGLE_BULLET_BETWEEN_COORDS(v_A, v_D, 15, 1, ${weapon_assaultshotgun}, PLAYER::PLAYER_PED_ID(), 1, 1, 0xbf800000); And here is my line Function.Call(Hash.SHOOT_SINGLE_BULLET_BETWEEN_COORDS, from.X, from.Y, from.Z, to.X, to.Y, to.Z, 15, 1, 0xE284C527, player.Handle, 1, 1, 0xbf800000); And it does nothing at all. No errors were logged in the log file and I put "player.Health--" under that line to test that the scripthook was even working and it was, the healh decreased, yet nothing was fired. Edited May 20, 2015 by willywill Link to comment Share on other sites More sharing options...
crosire Posted May 20, 2015 Author Share Posted May 20, 2015 And what is the correct way to delete prop? Prop myprop = World.CreateProp(modelString, Game.Player.Character.Position, true, true);myprop.Delete(); Link to comment Share on other sites More sharing options...
Inco Posted May 20, 2015 Share Posted May 20, 2015 (edited) Just to reiterate because my last post I was in a rush. I am unable to get SHOOT_SINGLE_BULLET_BETWEEN_COORDS to work in .NET yet it seems to work fine in C++ or lua. The problem is I am most comfortable with programming in C# and I really love how far this has come already, I was just really hoping for this exact functionality to work for my script that I am working on. I checked the Trainer/SDK files directly from Alexander Blade and I even looked into the GTA V decompiled scripts so that I could use them exactly the same, still with no such luck in getting it to work. For example, this is a line directly from the decompiled scripts using https://www.gta5-mods.com/tools/dev-tool-search-gta-v-game-scripts GAMEPLAY::SHOOT_SINGLE_BULLET_BETWEEN_COORDS(v_A, v_D, 15, 1, ${weapon_assaultshotgun}, PLAYER::PLAYER_PED_ID(), 1, 1, 0xbf800000); And here is my line Function.Call(Hash.SHOOT_SINGLE_BULLET_BETWEEN_COORDS, from.X, from.Y, from.Z, to.X, to.Y, to.Z, 15, 1, 0xE284C527, player.Handle, 1, 1, 0xbf800000); And it does nothing at all. No errors were logged in the log file and I put "player.Health--" under that line to test that the scripthook was even working and it was, the healh decreased, yet nothing was fired. Works fine for me: var pos = player.Position;var pos2 = pos.Around( 10f );Function.Call( Hash.SHOOT_SINGLE_BULLET_BETWEEN_COORDS, pos.X, pos.Y, pos.Z, pos2.X, pos2.Y, pos2.Z, 15, true, (int)player.Weapons[ WeaponHash.AssaultRifle ].Hash, player.Handle, 1, 1, 1f ); or with unchecked: var pos = player.Position;var pos2 = pos.Around( 20f );unchecked{ Function.Call( Hash.SHOOT_SINGLE_BULLET_BETWEEN_COORDS, pos.X, pos.Y, pos.Z, pos2.X, pos2.Y, pos2.Z, 15, true, (int)WeaponHash.RPG, player.Handle, 1, 1, 1f );} Edited May 20, 2015 by Inco Link to comment Share on other sites More sharing options...
willywill Posted May 20, 2015 Share Posted May 20, 2015 (edited) Thanks alot Inco, I will try out your example and edit and report back the results! Edit: IT WORKS! Thanks a lot, you are a huge lifesaver. I used the uncheck method you posted. I was unaware of such a modifier but I am very grateful. Thanks again! Edited May 20, 2015 by willywill Link to comment Share on other sites More sharing options...
unknown modder Posted May 20, 2015 Share Posted May 20, 2015 (edited) I did a bit of tweaking to enable initialising outputarguments(set the pointer value) now I can use things like vehicle pointers in functions like this Function.Call(Hash.SET_ENTITY_AS_MISSION_ENTITY, vehicle.ID, false, true);Function.Call(Hash.DELETE_VEHICLE, OutputArgument.Pointer<int>(vehicle.ID)); The issue Im having is it wont actually delete the vehicle all the time, and if I try and call it again on the same vehicle it freezes. Great idea to provide that Pointer property. *thumbs up* About your problem: I remember having read somewhere that whenever we want to delete either a ped or a vehicle, we must mark it as no longer needed before. thats what the set entity as mission entity was for, using that to delete vehicles was tried and tested on console and asi scripts on pc. The vehicle deleted once randomly then never worked again. EDIT: Removing the set_entity_as_mission_entity results in the vehicle not being deleted, but multiple calling of it doesnt result in a freeze. It also lets my asi find and delete the vehicle later. EDIT2: This works, but needs to be called twice, but at least setting the pointer works, if someone tells me how to use github, I'll add a commit for the pointer method, should give VB users more things to work with Function.Call(Hash.SET_ENTITY_AS_MISSION_ENTITY, vehicle.ID, true, false);Function.Call(Hash.DELETE_VEHICLE, OutputArgument.Pointer<int>(vehicle.ID)); Edited May 20, 2015 by unknown modder Link to comment Share on other sites More sharing options...
unknown modder Posted May 20, 2015 Share Posted May 20, 2015 (edited) also for vehicle class(needs tweaking a bit for net hook) public enum class Plates { Blue_on_White_1 = 3, Blue_on_White_2 = 0, Blue_on_White_3 = 4, Yellow_on_Blue = 2, Yellow_on_Black = 1, North_Yankton = 5, }; CarColour Vehicle_Mod::PearlescentColour::get() { int a, b; Natives::GET_VEHICLE_EXTRA_COLOURS(this->mID, &a, &b); return (CarColour)a; } void Vehicle_Mod::PearlescentColour::set(CarColour value) { int a, b; Natives::GET_VEHICLE_EXTRA_COLOURS(this->mID, &a, &b); Natives::SET_VEHICLE_EXTRA_COLOURS(this->mID, (int)value, b); } CarColour Vehicle_Mod::RimColour::get() { int a, b; Natives::GET_VEHICLE_EXTRA_COLOURS(this->mID, &a, &b); return (CarColour)b; } void Vehicle_Mod::RimColour::set(CarColour value) { int a, b; Natives::GET_VEHICLE_EXTRA_COLOURS(this->mID, &a, &b); Natives::SET_VEHICLE_EXTRA_COLOURS(this->mID, a, (int)value); } bool Vehicle_Mod::CustomFrontTyres::get() { return Natives::GET_VEHICLE_MOD_VARIATION(this->mID, 23) != 0; } void Vehicle_Mod::CustomFrontTyres::set(bool value) { Natives::SET_VEHICLE_MOD(this->mID, 23, Natives::GET_VEHICLE_MOD(this->mID, 23), value); } bool Vehicle_Mod::CustomRearTyres::get() { return Natives::GET_VEHICLE_MOD_VARIATION(this->mID, 24) != 0; } void Vehicle_Mod::CustomRearTyres::set(bool value) { Natives::SET_VEHICLE_MOD(this->mID, 24, Natives::GET_VEHICLE_MOD(this->mID, 24), value); } bool Vehicle_Mod::BulletProofTyres::get() { return Natives::GET_VEHICLE_TYRES_CAN_BURST(this->mID) == 0; } void Vehicle_Mod::BulletProofTyres::set(bool value) { Natives::SET_VEHICLE_TYRES_CAN_BURST(this->mID, !value); } Plates Vehicle_Mod::PlateType::get() { return (Plates)Natives::GET_VEHICLE_NUMBER_PLATE_TEXT_INDEX(this->mID); } void Vehicle_Mod::PlateType::set(Plates value) { Natives::SET_VEHICLE_NUMBER_PLATE_TEXT_INDEX(this->mID, (int)value); } Edited May 20, 2015 by unknown modder Link to comment Share on other sites More sharing options...
Reck1501 Posted May 20, 2015 Share Posted May 20, 2015 I'm trying to use the Menu base included, but keep getting "GTA.Menu does not contain a definition for 'Menu'". Any chance someone can make a quick example menu? Link to comment Share on other sites More sharing options...
monsterxsync Posted May 20, 2015 Share Posted May 20, 2015 I'm trying to use the Menu base included, but keep getting "GTA.Menu does not contain a definition for 'Menu'". Any chance someone can make a quick example menu? there is one. its called simpletrainer. Link to comment Share on other sites More sharing options...
Cyron43 Posted May 20, 2015 Share Posted May 20, 2015 (edited) I did a bit of tweaking to enable initialising outputarguments(set the pointer value) now I can use things like vehicle pointers in functions like this Function.Call(Hash.SET_ENTITY_AS_MISSION_ENTITY, vehicle.ID, false, true);Function.Call(Hash.DELETE_VEHICLE, OutputArgument.Pointer<int>(vehicle.ID)); The issue Im having is it wont actually delete the vehicle all the time, and if I try and call it again on the same vehicle it freezes. Great idea to provide that Pointer property. *thumbs up* About your problem: I remember having read somewhere that whenever we want to delete either a ped or a vehicle, we must mark it as no longer needed before. thats what the set entity as mission entity was for, using that to delete vehicles was tried and tested on console and asi scripts on pc. The vehicle deleted once randomly then never worked again. EDIT: Removing the set_entity_as_mission_entity results in the vehicle not being deleted, but multiple calling of it doesnt result in a freeze. It also lets my asi find and delete the vehicle later. EDIT2: This works, but needs to be called twice, but at least setting the pointer works, if someone tells me how to use github, I'll add a commit for the pointer method, should give VB users more things to work with Function.Call(Hash.SET_ENTITY_AS_MISSION_ENTITY, vehicle.ID, true, false);Function.Call(Hash.DELETE_VEHICLE, OutputArgument.Pointer<int>(vehicle.ID)); 1. Create a GitHub account. 2. Fork the project. That creates a copy of it in your own account. 3. I suggest you install SourceTree. That's a free git client and provides the best UI of it's kind. Otoh TortoiseGit has some more neat options. I guess you need to install git before (see link below). I have forgotten because I use SourceTree and TortoiseGit for ages. 4. If you don't know already learn the basics of how to do versioning with git: http://git-scm.com/ 5. Clone your forked project to your local harddisk. SourceTree can help you with that. 6. Add/modify code, commit and push. I recommend you create a develop branch before you make any changes to the code. If everything works then merge the develop branch to the master branch and push. 7. Make a pull request so Crosire can merge your code into the original project. BTW in case you are looking for a git repo hoster who also provides private repos for free I recommend BitBucket. Edited May 20, 2015 by Cyron43 unknown modder 1 Link to comment Share on other sites More sharing options...
Prof_Farnsworth Posted May 20, 2015 Share Posted May 20, 2015 (edited) Hey guys, I don't think I am using this right: i1 = Settings.GetValue<int>("SETTINGS", "carjack_Chance", 30); Here is my ini: [SETTINGS]carjack_Chance = 10 That looks pretty correct to me. What's the problem? It doesn't seem to be taking the value, instead using the default of 30. At least that is what is reported when I print i1.tostring(). Edited May 20, 2015 by Prof_Farnsworth Link to comment Share on other sites More sharing options...
Inco Posted May 20, 2015 Share Posted May 20, 2015 Hey guys, I don't think I am using this right: i1 = Settings.GetValue<int>("SETTINGS", "carjack_Chance", 30); Here is my ini:[sETTINGS]carjack_Chance = 10 That looks pretty correct to me. What's the problem? It doesn't seem to be taking the value, instead using the default of 30. At least that is what is reported when I print i1.tostring(). What name of your ini? Link to comment Share on other sites More sharing options...
unknown modder Posted May 20, 2015 Share Posted May 20, 2015 Hey guys, I don't think I am using this right: i1 = Settings.GetValue<int>("SETTINGS", "carjack_Chance", 30); Here is my ini:[sETTINGS]carjack_Chance = 10 That looks pretty correct to me. What's the problem? It doesn't seem to be taking the value, instead using the default of 30. At least that is what is reported when I print i1.tostring(). easy way to debug, set the value using the script and make sure it saves, then see what it looks like in the file, the issue may be the spaces in the line carjack_Chance = 10 -> carjack_Chance=10 Link to comment Share on other sites More sharing options...
Inco Posted May 20, 2015 Share Posted May 20, 2015 Hey guys, I don't think I am using this right: i1 = Settings.GetValue<int>("SETTINGS", "carjack_Chance", 30); Here is my ini:[sETTINGS]carjack_Chance = 10 That looks pretty correct to me. What's the problem? It doesn't seem to be taking the value, instead using the default of 30. At least that is what is reported when I print i1.tostring(). easy way to debug, set the value using the script and make sure it saves, then see what it looks like in the file, the issue may be the spaces in the line carjack_Chance = 10 -> carjack_Chance=10 API has no method for saving ini files =\ Only load. Link to comment Share on other sites More sharing options...
Reck1501 Posted May 20, 2015 Share Posted May 20, 2015 I'm trying to use the Menu base included, but keep getting "GTA.Menu does not contain a definition for 'Menu'". Any chance someone can make a quick example menu? there is one. its called simpletrainer. I can't find it anywhere, I can only find one for IV Link to comment Share on other sites More sharing options...
Inco Posted May 20, 2015 Share Posted May 20, 2015 I'm trying to use the Menu base included, but keep getting "GTA.Menu does not contain a definition for 'Menu'". Any chance someone can make a quick example menu? there is one. its called simpletrainer. I can't find it anywhere, I can only find one for IV https://github.com/crosire/scripthookvdotnet/blob/master/example/SimpleTrainer.cs Link to comment Share on other sites More sharing options...
Reck1501 Posted May 20, 2015 Share Posted May 20, 2015 (edited) I'm trying to use the Menu base included, but keep getting "GTA.Menu does not contain a definition for 'Menu'". Any chance someone can make a quick example menu? there is one. its called simpletrainer. I can't find it anywhere, I can only find one for IV https://github.com/crosire/scripthookvdotnet/blob/master/example/SimpleTrainer.cs Wow.. I feel really freaking stupid right now.. Thanks though. Getting these errors: 1>------ Build started: Project: ModMenu, Configuration: Debug Any CPU ------1>C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(1697,5): warning MSB3270: There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "ScriptHookVDotNet", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.1>c:\users\thomas\documents\visual studio 2013\Projects\ModMenu\ModMenu\script.cs(32,22,32,33): error CS1061: 'GTA.Viewport' does not contain a definition for 'ActiveMenus' and no extension method 'ActiveMenus' accepting a first argument of type 'GTA.Viewport' could be found (are you missing a using directive or an assembly reference?)1>c:\users\thomas\documents\visual studio 2013\Projects\ModMenu\ModMenu\script.cs(42,17,42,26): error CS0246: The type or namespace name 'MenuLabel' could not be found (are you missing a using directive or an assembly reference?)1>c:\users\thomas\documents\visual studio 2013\Projects\ModMenu\ModMenu\script.cs(46,17,46,26): error CS0246: The type or namespace name 'MenuLabel' could not be found (are you missing a using directive or an assembly reference?)1>c:\users\thomas\documents\visual studio 2013\Projects\ModMenu\ModMenu\script.cs(54,17,54,27): error CS0246: The type or namespace name 'MenuToggle' could not be found (are you missing a using directive or an assembly reference?)1>c:\users\thomas\documents\visual studio 2013\Projects\ModMenu\ModMenu\script.cs(56,17,56,27): error CS0246: The type or namespace name 'MenuToggle' could not be found (are you missing a using directive or an assembly reference?)1>c:\users\thomas\documents\visual studio 2013\Projects\ModMenu\ModMenu\script.cs(63,17,63,27): error CS0246: The type or namespace name 'MenuToggle' could not be found (are you missing a using directive or an assembly reference?)1>c:\users\thomas\documents\visual studio 2013\Projects\ModMenu\ModMenu\script.cs(70,9,70,17): error CS0246: The type or namespace name 'ListMenu' could not be found (are you missing a using directive or an assembly reference?)1>c:\users\thomas\documents\visual studio 2013\Projects\ModMenu\ModMenu\script.cs(70,36,70,44): error CS0246: The type or namespace name 'ListMenu' could not be found (are you missing a using directive or an assembly reference?)========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== Edited May 20, 2015 by Reck1501 Link to comment Share on other sites More sharing options...
flynhigh09 Posted May 20, 2015 Share Posted May 20, 2015 Ini file should have same name as dll yes? Link to comment Share on other sites More sharing options...
Inco Posted May 20, 2015 Share Posted May 20, 2015 (edited) @Reck1501, upload your project somewhere with ScriptHookVDotNet.dll, i will see. Ini file should have same name as dll yes? Yes, or use Settings.Load. Edited May 20, 2015 by Inco Link to comment Share on other sites More sharing options...
Reck1501 Posted May 20, 2015 Share Posted May 20, 2015 (edited) Any idea why this isn't working?: Ped MyPed = Game.Player.Character; Function.Call(Hash.SET_EXPLOSIVE_AMMO_THIS_FRAME, MyPed); (it is in void OnTick) Edited May 20, 2015 by Reck1501 Link to comment Share on other sites More sharing options...
Inco Posted May 20, 2015 Share Posted May 20, 2015 Any idea why this isn't working?: Ped MyPed = Game.Player.Character; Function.Call(Hash.SET_EXPLOSIVE_AMMO_THIS_FRAME, MyPed); (it is in void OnTick) Again... Use MyPed.Handle, not MyPed. Link to comment Share on other sites More sharing options...
Reck1501 Posted May 20, 2015 Share Posted May 20, 2015 Any idea why this isn't working?: Ped MyPed = Game.Player.Character; Function.Call(Hash.SET_EXPLOSIVE_AMMO_THIS_FRAME, MyPed); (it is in void OnTick) Again... Use MyPed.Handle, not MyPed. Doesn't work with that either Link to comment Share on other sites More sharing options...
crosire Posted May 20, 2015 Author Share Posted May 20, 2015 Getting these errors: You did add ScriptHookVDotNet.dll as an assembly reference to the project, did you? Again... Use MyPed.Handle, not MyPed. Makes no difference actually, the "InputArgument" class which handles the "Function.Call" arguments has an overload which takes a "Ped" class value and accesses the Handle property itself. Link to comment Share on other sites More sharing options...
Reck1501 Posted May 20, 2015 Share Posted May 20, 2015 Getting these errors: You did add ScriptHookVDotNet.dll as an assembly reference to the project, did you? Yea, turns out it was because it was an outdated version. I compiled the source myself and it works. Also, I'm looking at the vehicle list in the sample trainer void OpenVehicleSpawnMenu() { ListMenu VehicleMenu = new ListMenu("Spawn Vehicle"); VehicleMenu.Add("Adder", "A fast car"); VehicleMenu.Add("LAZER", "A military jet"); VehicleMenu.Add("BMX", "A bike"); VehicleMenu.Add("Jetpack", "CLASSIFIED"); View.AddMenu(VehicleMenu); } How would I make them spawn when pressed, without making an individual function for each vehicle? Link to comment Share on other sites More sharing options...
flynhigh09 Posted May 20, 2015 Share Posted May 20, 2015 @Reck1501, upload your project somewhere with ScriptHookVDotNet.dll, i will see. Ini file should have same name as dll yes? Yes, or use Settings.Load. there is no Settings.load n it still used default 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