Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

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

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

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

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

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

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

    2. Support

    3. Suggestions

DELETE_OBJECT C#


yomisimie
 Share

Recommended Posts

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 by yomisimie
Link to comment
Share on other sites

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 by Guest
Link to comment
Share on other sites

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 :D

Link to comment
Share on other sites

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 by Guest
Link to comment
Share on other sites

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

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 by Guest
Link to comment
Share on other sites

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

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
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

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