artyom2206 Posted September 13, 2018 Share Posted September 13, 2018 Hello, I have a problem to figure out, how should I save used vehicles. I want to reuse them like explode last 5 vehicles, which i used or something like this.. Thank you. Link to comment Share on other sites More sharing options...
Guest Posted September 13, 2018 Share Posted September 13, 2018 Storing them in a List<Vehicle>, (or a Dictionary<int, Vehicle> with the Vehicle.Handle as the key) is the easiest way but I can't remember if holding a reference to the vehicle is enough to stop the game from removing it when it is out of view. If that's the case, then you have to make them persistent when you get into them but then you also have to be careful, as that will stop the game from deleting them to make room for new car spawns. So you will have to remove the persistent flag when you remove them from the list when you add new vehicles, so the game can clean them up. Also mark them as No Longer Needed, so the game knows you're done with them. Also be aware that you will need to monitor the state of any vehicles in the list, as them being destroyed by the game can leave null references in the List/Dictionary. It just requires a bit of micro-management but it's not too bad. When you get into a vehicle, check if it's in the list, if not add it. If the list is full (which you decide by choosing how many vehicles you want to store if (myList.Count == MaxVehicles) ), remove the first vehicle in the list, then add the new one. Link to comment Share on other sites More sharing options...