Log in to reply
 

Unloading a Vehicle from memory?



  • Is there a way to get the players last entered vehicle, and then check and verify that vehicles current location on the map relative to the player. (Assuming it has one and is spawned) aka [active in memory], and then unload it from the memory based on 2 conditions?

    Either the player is X distance too far from the vehicle or the vehicles health has less than 5, and if either or both conditions are true, unload the vehicle from the memory, but only if the player is a certain distance away from it?


  • MODERATOR

    @JZersche
    Assuming you need this in C#:

    You can use entity.MarkAsNoLongerNeeded when your conditions are true, which lets the game engine remove the entity when it deems necessary. You can also call entity.Delete right after if you want to get rid of it right away.

    To get player's last entered vehicle: player.LastVehicle

    Distance between two entities: World.GetDistance(entity1.Position, entity2.Postion)

    For vehicle health, there are a few types of health. In Visual Studio you can just type ".health" after your vehicle object and it should show you 3-4 different health integers that you can check.


Log in to reply
 

Looks like your connection to GTA5-Mods.com Forums was lost, please wait while we try to reconnect.