yomisimie Posted November 1, 2017 Share Posted November 1, 2017 (edited) I am trying to spawn an object (which I succeeded) but when I spawn another one to delete the first. I am using scripthook dot net and I cannot seem to find the function to delete an object other than the Native DB. I tried using the CREATE_OBJECT method but in DELETE_OBJECT i can't put the variable. I am new to scripting and maybe it's something I'm missing. An explanation would be much helpful. if(e.KeyCode == Keys.J) { Vector3 pos = street.GetResult<Vector3>(); //Game.Player.Character.Position = street.pos; model.Request(); if (model.IsInCdImage && model.IsValid) { // Ensure the model is loaded before we try to create it in the world while (!model.IsLoaded) Script.Wait(50); // Create the prop in the world World.CreateProp(model, pos, true, true); //mod = Function.Call<object>(Hash.CREATE_OBJECT, model.Hash, pos.X, pos.Y, pos.Z, 0, 0, 0); } } if (e.KeyCode == Keys.K) { Function.Call(Hash.GET_CLOSEST_VEHICLE_NODE_WITH_HEADING, player.X, player.Y, player.Z, street, heading, nodeTypeAsphaltRoad, 3, 0); } Thanks! Edited November 1, 2017 by yomisimie Link to comment Share on other sites More sharing options...
Guest Posted November 2, 2017 Share Posted November 2, 2017 (edited) The problem you are having, is because you are not keeping a reference to the prop you have created. If you were only using a single prop, you could declare a global Prop myProp in your declaration section and then do: myProp = World.CreateProp(model, pos, true, true); Then when you wanted to delete it, you could do: myProp.Delete(); If you wanted to spawn multiple props, you could use a List<Prop> myProps and do myProps.Add(World.CreateProp(etc... )); When you wanted to delete them, you would just go through each Prop in the list and delete it as you did with the single prop. Just remember to declare your Prop or List<Prop> as global variables, outside your key handling function, otherwise the minute you exit that function, the references will disappear and the Props will remain and you won't be able to delete them again. If you add a Script.Aborted handler, you can also use that to remove any spawned props when you hit Insert to reload the scripts. If you don't, the second time your mod runs, it spawns a new set of Props and leaves the old ones in the map to eat your memory. I don't know if there are other/better ways of doing what I have written here, I don't tend to use props that much, so this is the only way I know how to handle them. Edited November 2, 2017 by Guest Link to comment Share on other sites More sharing options...
yomisimie Posted November 2, 2017 Author Share Posted November 2, 2017 This was a logic fail on my part. I could not find the Delete() function because I didn't had a prop. Thank you! One small thing because I can't seem to find it. How do I get intersections? Or how do I get the directions of the GPS route? I am looking through the Native DB but some names must pass over my head. Sorry to bother you again, I'm trying to learn the logic Link to comment Share on other sites More sharing options...
ikt Posted November 2, 2017 Share Posted November 2, 2017 PATHFIND::GET_STREET_NAME_AT_COORD should do what you want. Link to comment Share on other sites More sharing options...
yomisimie Posted November 2, 2017 Author Share Posted November 2, 2017 PATHFIND::GET_STREET_NAME_AT_COORD should do what you want. Sorry, I meant names of Native functions. I want to get the node and detect if it's an intersection, if that is possible. Link to comment Share on other sites More sharing options...
Guest Posted November 3, 2017 Share Posted November 3, 2017 (edited) There's some info in this thread about GPS information http://gtaforums.com/topic/869246-gps-points-native/ that might be useful. But that native that ikt linked to will also give back useful info related to road details. If you check a coordinate and it is an intersection, it will return two street names, if not, it will only return one name. Other than that, you can used the VEHICLE_NODE related Natives. If you click Expand All on that page ikt linked to, then search (on the page, not in the Function Name or Hash... box) for VEHICLE_NODE you should be able to find all the ones that match. There should be 12 matches based on the search I just tried when I added this comment. Edited November 3, 2017 by Guest Link to comment Share on other sites More sharing options...
yomisimie Posted November 4, 2017 Author Share Posted November 4, 2017 There's some info in this thread about GPS information http://gtaforums.com/topic/869246-gps-points-native/ that might be useful. But that native that ikt linked to will also give back useful info related to road details. If you check a coordinate and it is an intersection, it will return two street names, if not, it will only return one name. Other than that, you can used the VEHICLE_NODE related Natives. If you click Expand All on that page ikt linked to, then search (on the page, not in the Function Name or Hash... box) for VEHICLE_NODE you should be able to find all the ones that match. There should be 12 matches based on the search I just tried when I added this comment. Thanks a lot! Managed to do what I wanted, will look into the GPS too. Managed with the native proposed by ikt to find intersections. Although they are about 5 nodes in an intersection, but I suppose that's to help the AI driving. PATHFIND::GET_STREET_NAME_AT_COORD should do what you want. Sorry, didn't knew what the native did. Proved to be pretty useful. Thanks man! Link to comment Share on other sites More sharing options...
Guest Posted November 6, 2017 Share Posted November 6, 2017 (edited) Try checking bit 7 in the flags returned by GET_VEHICLE_NODE_PROPERTIES, that seems to get set at a junction node, based on the video I made when I was checking for node info related to speed limits. In the desert, Route 68 was normally setting the flags to 00000010 until it got to a junction, then it was setting them to 10000010 for a single node. Edited November 6, 2017 by Guest Link to comment Share on other sites More sharing options...
yomisimie Posted November 6, 2017 Author Share Posted November 6, 2017 Try checking bit 7 in the flags returned by GET_VEHICLE_NODE_PROPERTIES, that seems to get set at a junction node, based on the video I made when I was checking for node info related to speed limits. In the desert, Route 68 was normally setting the flags to 00000010 until it got to a junction, then it was setting them to 10000010 for a single node. Oh, wow, that's very helpful. Will try to check that. You the best, thanks a lot! 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