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.there is no Settings.load n it still used default var sett = ScriptSettings.Load( "filename" ); Edited May 20, 2015 by Inco Link to comment Share on other sites More sharing options...
Moder L Posted May 20, 2015 Share Posted May 20, 2015 (edited) Hello, thanks for help everyone) Is there a way to create prop which will be placed under ground? I need to create rams so it will be a little bit underground because this: World.CreateProp(myramp, ped.Position + ped.ForwardVector * distance, true, true); doesn't place it correctly everytime, so I want to place it a little bit under ground level Also, what does "dynamic" means in World.CreateProp? Thanks! Edited May 20, 2015 by Moder L Link to comment Share on other sites More sharing options...
Moder L Posted May 20, 2015 Share Posted May 20, 2015 (edited) I can do it like this GTA.Math.Vector3 vec = new GTA.Math.Vector3(ped.Position.X, ped.Position.Y, ped.Position.Z - 1) Can someone give me an example how to use native function GET_GROUND_Z_FOR_3D_COORD to get this Z coordinate? Edited May 20, 2015 by Moder L Link to comment Share on other sites More sharing options...
flynhigh09 Posted May 20, 2015 Share Posted May 20, 2015 (edited) No clue but still not working falls back to default.. SPraceMod.net.ini[RACE_SETTINGS]VEHICLE=3057713523 ScriptSettings _settings = ScriptSettings.Load("SPraceMod.net");//dont load at all VehicleModel = _settings.GetValue<VehicleHash>("[RACE_SETTINGS]", "VEHICLE", VehicleHash.Dukes2);//loads if use Settings.GetValue to default value only. @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 var sett = ScriptSettings.Load( "filename" ); Edited May 20, 2015 by flynhigh09 Link to comment Share on other sites More sharing options...
NXT Posted May 21, 2015 Share Posted May 21, 2015 (edited) Hello. I can't figure what's wrong (maybe it's all wrong in the first place?). Now let me say something: it may happen for once, or twice, then it starts working normal (just have to press Insert a couple of times). And there's something I noticed, and it is: It won't work when I start the game fresh (or reload any saved game), only by pressing Insert (maybe twice). How can I solve it? I'm a beginner (as most of you can see). Exception message explains it pretty well. You are attempting to create a vehicle inside the constructor, which itself has to stream in the vehicle model, which is a blocking call and thus not allowed. Anything attemping to block (calling "Script.Wait" or "Script.Yield") inside the constructor is not allowed, since the constructor is executed in the base thread and would block the entire Script Hook. You have to do those kind of things in the Tick or KeyDown/Up events. Thanks, it did the work! I may be wrong questioning this in this topic, but: How can I get the actual heading of the player, ingame?If there was an obvious way, I apologize for not getting it in the first place, but anyway I haven't found it yet. float heading = Game.Player.Character.Heading; Thanks for that, it did the work. But now I have another concern, and it is regarding ped|car density. I've been looking for natives and there are some lines that would allegedly work, but I can't get them to do the job: void SET_PED_DENSITY_MULTIPLIER_THIS_FRAME(float multiplier) void SET_VEHICLE_DENSITY_MULTIPLIER_THIS_FRAME(float p0) void SET_RANDOM_VEHICLE_DENSITY_MULTIPLIER_THIS_FRAME(float p0) I tried to set the parameters to 0.0 but it did nothing: GTA.Native.Function.Call(Hash.SET_PED_DENSITY_MULTIPLIER_THIS_FRAME, 0.0) GTA.Native.Function.Call(Hash.SET_VEHICLE_DENSITY_MULTIPLIER_THIS_FRAME, 0.0) GTA.Native.Function.Call(Hash.SET_RANDOM_VEHICLE_DENSITY_MULTIPLIER_THIS_FRAME, 0.0) I may be doing something stupid, but even If I am, can't figure what it is. Could someone help me? Thanks, it did the work too! Now, regarding the 'DrivingStyle' I mentioned before: It seems that the best of those 'styles' is the 6 (AvoidTrafficExtremely). But still, they are slow and, they don't really 'avoid' most of the traffic (AI mainly ramming against it). Curiously, when I tried to use the BJXL (BeeJay XL), the AI was much slower than some other cars (like Dilettante, Emperor, Alpha, etc). And that car isn't that much slower than those. Although this may be related to the 'handling.meta' file: there is a line that says the type of handling the AI has for all cars. The BJXL had 'TRUCK' (like all others trucks in that file), but most of the 'normal cars' had 'AVERAGE'. Maybe that's related to the AI being so much slower with some vehicles. Anyway, that being true or not, AI is not as fast as it has to be (I remember in GTA IV they really pushed the cars to the maximum, and didn't brake in some random spots like here). PD: I know this last has not much to do with scripting, but since there are some interesting projects for race mods, it would be not of hurt to share something I think may be useful. Edited May 21, 2015 by NXT Link to comment Share on other sites More sharing options...
Prof_Farnsworth Posted May 21, 2015 Share Posted May 21, 2015 No clue but still not working falls back to default.. SPraceMod.net.ini[RACE_SETTINGS]VEHICLE=3057713523 ScriptSettings _settings = ScriptSettings.Load("SPraceMod.net");//dont load at all VehicleModel = _settings.GetValue<VehicleHash>("[RACE_SETTINGS]", "VEHICLE", VehicleHash.Dukes2);//loads if use Settings.GetValue to default value only. @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 var sett = ScriptSettings.Load( "filename" ); Same for me still. Can anyone give an example of how they successfully used this? Link to comment Share on other sites More sharing options...
monsterxsync Posted May 21, 2015 Share Posted May 21, 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) Try this.. Function.Call(Hash.SET_EXPLOSIVE_AMMO_THIS_FRAME, Game.Player); Link to comment Share on other sites More sharing options...
Inco Posted May 21, 2015 Share Posted May 21, 2015 (edited) No clue but still not working falls back to default.. SPraceMod.net.ini[RACE_SETTINGS]VEHICLE=3057713523 ScriptSettings _settings = ScriptSettings.Load("SPraceMod.net");//dont load at all VehicleModel = _settings.GetValue<VehicleHash>("[RACE_SETTINGS]", "VEHICLE", VehicleHash.Dukes2);//loads if use Settings.GetValue to default value only. @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 var sett = ScriptSettings.Load( "filename" ); Filename of your ini is SPraceMod.net.ini, not SPraceMod.net , this is first. Second, where is your ini file? In scripts folder? Then scripts\\SPraceMod.net.ini 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) Look at native db, this function require player handle. var player = Game.Player;Function.Call( Hash.SET_EXPLOSIVE_AMMO_THIS_FRAME, player.Handle ); Edited May 21, 2015 by Inco flynhigh09 1 Link to comment Share on other sites More sharing options...
crosire Posted May 21, 2015 Author Share Posted May 21, 2015 (edited) No clue but still not working falls back to default..SPraceMod.net.ini[RACE_SETTINGS] VEHICLE=3057713523 ScriptSettings _settings = ScriptSettings.Load("SPraceMod.net");//dont load at all VehicleModel = _settings.GetValue<VehicleHash>("[RACE_SETTINGS]", "VEHICLE", VehicleHash.Dukes2);//loads if use Settings.GetValue to default value only. And additionally to what Inco already said, the settings key in the script would be "RACE_SETTINGS", not "[RACE_SETTINGS"] for your INI file. Edited May 21, 2015 by Crosire Link to comment Share on other sites More sharing options...
xsploit Posted May 21, 2015 Share Posted May 21, 2015 Dim ReturnPed As Ped = World.CreatePed(GTA.Native.PedHash.SMMMovalien01, loc) ReturnPed.RelationshipGroup = GTA.Relationship.Hate GTA.Native.Function.Call(GTA.Native.Hash.GIVE_WEAPON_TO_PED, ReturnPed, GTA.Native.WeaponHash.AssaultRifle, 420, True, True) 'qqqqqqqqqqqqqqqqqqqqqqqqqqqqqq ReturnPed.BlockPermanentEvents = True ReturnPed.Task.GuardCurrentPosition() ReturnPed.Task.AimAt(loc, 10000) GTA.World.AddRelationShipGroup("ARMY") GTA.World.SetRelationshipBetweenGroups(Relationship.Hate, "PLAYER", "ARMY") GTA.World.SetRelationshipBetweenGroups(Relationship.Hate, "ARMY", "PLAYER") ReturnPed.Task.FightAgainst(Game.Player.Character, 7000) fight.AddTask.FightAgainst(Game.Player.Character, 7000) fight.AddTask.FightAgainstHatedTargets(30.0F) fight.AddTask.AimAt(Game.Player.Character, 7000) fight.AddTask.GuardCurrentPosition() fight.AddTask.PerformSequence(1) ReturnPed.Task.PerformSequence(Tasker) ReturnPed.Money = 5000 I'm trying to get a created ped to fight me but i'm not sure how to set the sequence properly. I tried learning from c# so far no luck Link to comment Share on other sites More sharing options...
monsterxsync Posted May 21, 2015 Share Posted May 21, 2015 how would we go about getting the waypoints position? is this implemented? Link to comment Share on other sites More sharing options...
flynhigh09 Posted May 21, 2015 Share Posted May 21, 2015 (edited) So its finding it now but still only getting default value only? .ini [RACE_SETTINGS]VEHICLE=3057713523 VehicleHash Duk = VehicleHash.Dukes2; _settings = ScriptSettings.Load("scripts\\SPraceMod.net.ini"); if( _settings == null) _settings.SetValue<VehicleHash>("RACE_SETTINGS", "VEHICLE", Duk); else VehicleModel = _settings.GetValue<VehicleHash>("RACE_SETTINGS", "VEHICLE", Duk); Edited May 21, 2015 by flynhigh09 Link to comment Share on other sites More sharing options...
crosire Posted May 21, 2015 Author Share Posted May 21, 2015 _settings = ScriptSettings.Load("scripts\\SPraceMod.net.ini"); ScriptSettings.Load("SPraceMod.net.ini"); All paths are relative to the script folder. Link to comment Share on other sites More sharing options...
Inco Posted May 21, 2015 Share Posted May 21, 2015 _settings = ScriptSettings.Load("scripts\\SPraceMod.net.ini"); ScriptSettings.Load("SPraceMod.net.ini"); All paths are relative to the script folder. Nope. So its finding it now but still only getting default value only? .ini [RACE_SETTINGS]VEHICLE=3057713523 VehicleHash Duk = VehicleHash.Dukes2; _settings = ScriptSettings.Load("scripts\\SPraceMod.net.ini"); if( _settings == null) _settings.SetValue<VehicleHash>("RACE_SETTINGS", "VEHICLE", Duk); else VehicleModel = _settings.GetValue<VehicleHash>("RACE_SETTINGS", "VEHICLE", Duk); There is no checks for VehicleHash. So, VehicleHash veh = (VehicleHash)_settings.GetValue( "RACE_SETTINGS", "VEHICLE", (UInt64)VehicleHash.Dukes2 ); flynhigh09 1 Link to comment Share on other sites More sharing options...
flynhigh09 Posted May 21, 2015 Share Posted May 21, 2015 _settings = ScriptSettings.Load("scripts\\SPraceMod.net.ini"); ScriptSettings.Load("SPraceMod.net.ini");All paths are relative to the script folder. Nope. So its finding it now but still only getting default value only? .ini [RACE_SETTINGS]VEHICLE=3057713523 VehicleHash Duk = VehicleHash.Dukes2; _settings = ScriptSettings.Load("scripts\\SPraceMod.net.ini"); if( _settings == null) _settings.SetValue<VehicleHash>("RACE_SETTINGS", "VEHICLE", Duk); else VehicleModel = _settings.GetValue<VehicleHash>("RACE_SETTINGS", "VEHICLE", Duk); There is no checks for VehicleHash. So, VehicleHash veh = (VehicleHash)_settings.GetValue( "RACE_SETTINGS", "VEHICLE", (UInt64)VehicleHash.Dukes2 );Thanks sir it was the cast to uint64.. Link to comment Share on other sites More sharing options...
Cyron43 Posted May 21, 2015 Share Posted May 21, 2015 (edited) Hello. I can't figure what's wrong (maybe it's all wrong in the first place?). Now let me say something: it may happen for once, or twice, then it starts working normal (just have to press Insert a couple of times). And there's something I noticed, and it is: It won't work when I start the game fresh (or reload any saved game), only by pressing Insert (maybe twice). How can I solve it? I'm a beginner (as most of you can see). Exception message explains it pretty well. You are attempting to create a vehicle inside the constructor, which itself has to stream in the vehicle model, which is a blocking call and thus not allowed. Anything attemping to block (calling "Script.Wait" or "Script.Yield") inside the constructor is not allowed, since the constructor is executed in the base thread and would block the entire Script Hook. You have to do those kind of things in the Tick or KeyDown/Up events. Thanks, it did the work! I may be wrong questioning this in this topic, but: How can I get the actual heading of the player, ingame? If there was an obvious way, I apologize for not getting it in the first place, but anyway I haven't found it yet. float heading = Game.Player.Character.Heading; Thanks for that, it did the work. But now I have another concern, and it is regarding ped|car density. I've been looking for natives and there are some lines that would allegedly work, but I can't get them to do the job: void SET_PED_DENSITY_MULTIPLIER_THIS_FRAME(float multiplier) void SET_VEHICLE_DENSITY_MULTIPLIER_THIS_FRAME(float p0) void SET_RANDOM_VEHICLE_DENSITY_MULTIPLIER_THIS_FRAME(float p0) I tried to set the parameters to 0.0 but it did nothing: GTA.Native.Function.Call(Hash.SET_PED_DENSITY_MULTIPLIER_THIS_FRAME, 0.0) GTA.Native.Function.Call(Hash.SET_VEHICLE_DENSITY_MULTIPLIER_THIS_FRAME, 0.0) GTA.Native.Function.Call(Hash.SET_RANDOM_VEHICLE_DENSITY_MULTIPLIER_THIS_FRAME, 0.0) I may be doing something stupid, but even If I am, can't figure what it is. Could someone help me? Thanks, it did the work too! Now, regarding the 'DrivingStyle' I mentioned before: It seems that the best of those 'styles' is the 6 (AvoidTrafficExtremely). But still, they are slow and, they don't really 'avoid' most of the traffic (AI mainly ramming against it). Curiously, when I tried to use the BJXL (BeeJay XL), the AI was much slower than some other cars (like Dilettante, Emperor, Alpha, etc). And that car isn't that much slower than those. Although this may be related to the 'handling.meta' file: there is a line that says the type of handling the AI has for all cars. The BJXL had 'TRUCK' (like all others trucks in that file), but most of the 'normal cars' had 'AVERAGE'. Maybe that's related to the AI being so much slower with some vehicles. Anyway, that being true or not, AI is not as fast as it has to be (I remember in GTA IV they really pushed the cars to the maximum, and didn't brake in some random spots like here). PD: I know this last has not much to do with scripting, but since there are some interesting projects for race mods, it would be not of hurt to share something I think may be useful. I hear you and I do also believe that DrivingStyle is not just some integer which reflects the forcefulness of the style (the higher the value the more aggressive) but it seems to be a bit mask. For instance the "normal" driving style (obey all traffic laws) is 786603. I don't know what's behind that value but just the fact that it's not simply 1 tells me there must be more to it. Edited May 21, 2015 by Cyron43 Link to comment Share on other sites More sharing options...
Nacorpio Posted May 21, 2015 Share Posted May 21, 2015 I would recommend using lambda-expressions. () => { code here } 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...
monsterxsync Posted May 21, 2015 Share Posted May 21, 2015 I would recommend using lambda-expressions. () => { code here } 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? Can you give a live example please? i also would like to know this. Link to comment Share on other sites More sharing options...
NMDanny Posted May 21, 2015 Share Posted May 21, 2015 Is there a way of accessing a Menu's currently selected item/index and it's menu collection? (In the latest release - 0.9 , C#) Also, a menu related suggestion: I think menus and buttons should have some events, such as OnActivate, OnLeft, OnRight, OnUp, OnDown, OnBack, as done in C# GUI frameworks. Their delegate would pass a sender object(menu/button) and perhaps an EventArgs object. It would be useful for actions that depend on menu/button data. Link to comment Share on other sites More sharing options...
Inco Posted May 21, 2015 Share Posted May 21, 2015 Is there a way of accessing a Menu's currently selected item/index and it's menu collection? (In the latest release - 0.9 , C#) SelectedIndex in the upstream. Link to comment Share on other sites More sharing options...
NMDanny Posted May 21, 2015 Share Posted May 21, 2015 (edited) Is there a way of accessing a Menu's currently selected item/index and it's menu collection? (In the latest release - 0.9 , C#) SelectedIndex in the upstream. Thanks I would recommend using lambda-expressions. () => { code here } 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? Can you give a live example please? i also would like to know this. I have an example with Menu and MenuButtons(from the 0.9 release): public void OpenVehicleSpawnMenu() { Func<VehicleHash, MenuButton> VehAsButton = (hash) => { return new MenuButton(hash.ToString(), () => { World.CreateVehicle(hash, Game.Player.Character.Position); }); }; List<VehicleHash> allVehicles = Enum.GetValues(typeof(VehicleHash)).Cast<VehicleHash>().ToList(); var menu = new GTA.Menu("Vehicle Spawner", allVehicles.Select(VehAsButton).OrderBy(mb => mb.Caption).ToArray()); View.AddMenu(menu); } Edited May 21, 2015 by NMDanny Cyron43 1 Link to comment Share on other sites More sharing options...
Cyron43 Posted May 21, 2015 Share Posted May 21, 2015 @Crosire: The .net script hook for GTA IV has an AlwaysKeepTask property. Has this yet to be implemented or isn't that necessary anymore with GTA V? I'm asking because if not then I can remove those lines of code from my migrated GTA IV mods (currently commented out). Link to comment Share on other sites More sharing options...
Mcfloy Posted May 21, 2015 Share Posted May 21, 2015 @Crosire: The .net script hook for GTA IV has an AlwaysKeepTask property. Has this yet to be implemented or isn't that necessary anymore with GTA V? I'm asking because if not then I can remove those lines of code from my migrated GTA IV mods (currently commented out). There's a native function "PED::SET_PED_KEEP_TASK", but i don't know if it's what you're talking about. ^^' Link to comment Share on other sites More sharing options...
Cyron43 Posted May 21, 2015 Share Posted May 21, 2015 (edited) What a great coincidence(?). @IncoCode implemented it just an hour ago. Thank you Inco. Edited May 21, 2015 by Cyron43 Link to comment Share on other sites More sharing options...
Moder L Posted May 21, 2015 Share Posted May 21, 2015 Can someone give me a hint how can I get entity hash from target? I tried Game.Player.GetTargetedEntity().Model.Hash but it works only on peds and vehicles, and I want to get hash of table, or ramp, or container. Is there a way? Thanks Link to comment Share on other sites More sharing options...
Mcfloy Posted May 21, 2015 Share Posted May 21, 2015 Can someone give me a hint how can I get entity hash from target? I tried Game.Player.GetTargetedEntity().Model.Hash but it works only on peds and vehicles, and I want to get hash of table, or ramp, or container. Is there a way? Thanks Game.Player.GetTargetedEntity().GetHashCode(); And with this ? Link to comment Share on other sites More sharing options...
crosire Posted May 21, 2015 Author Share Posted May 21, 2015 (edited) Game.Player.GetTargetedEntity().GetHashCode(); And with this ? GetHashCode is a function inherited from System.Object. It's part of .NET, nothing related to GTA. It's to be used as key in hash maps etc. Script Hook implements it by returning the entity handle. Edited May 21, 2015 by Crosire Link to comment Share on other sites More sharing options...
Moder L Posted May 21, 2015 Share Posted May 21, 2015 Any other ideas? Link to comment Share on other sites More sharing options...
crosire Posted May 21, 2015 Author Share Posted May 21, 2015 First you may want to define what you mean by "entity hash". GTA doesn't have such a thing, apart from the entity handle in which case Mcfloys suggestion would work (but you could as well use "Entity.Handle" directly). Link to comment Share on other sites More sharing options...
Mcfloy Posted May 21, 2015 Share Posted May 21, 2015 Any other ideas? Game.Player.GetTargetedEntity().Model.Hash It's my last anwser for that, can't find anything else ^^' 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