rawzner Posted February 21, 2021 Posted February 21, 2021 I'd like to respawn vehicles which haven't been used for 5 minutes to respawn to their original spawn location.. (I'm creating a deathmatch script where each gang spawn has vehicles pre-spawned) If anyone could help me out I'd greatly appreciate it
7inage Posted February 21, 2021 Posted February 21, 2021 (edited) You can try to impose a variable with a timer on the vehicle when the player leaves the car. And also, if someone got into this car, clear this timer.Source: https://wiki.rage.mp/index.php?title=PlayerEnterVehicle https://wiki.rage.mp/index.php?title=PlayerExitVehicle https://wiki.rage.mp/index.php?title=Entity::setVariable https://wiki.rage.mp/index.php?title=Vehicle::destroy Edited February 21, 2021 by 7inage 1
MrPancakers Posted February 22, 2021 Posted February 22, 2021 12 hours ago, 7inage said: You can try to impose a variable with a timer on the vehicle when the player leaves the car. And also, if someone got into this car, clear this timer.Source: https://wiki.rage.mp/index.php?title=PlayerEnterVehicle https://wiki.rage.mp/index.php?title=PlayerExitVehicle https://wiki.rage.mp/index.php?title=Entity::setVariable https://wiki.rage.mp/index.php?title=Vehicle::destroy It could be an idea to setup some kind of cron job that runs maybe every 5 minutes. On player exit vehicle, set the current timestamp, and inside the cron job loop through all vehicles and compare if the current timestamp was 5 minutes or longer and if so, respawn vehicle. Your cron job could run like every minutes or 5 minutes, in this case you won't have to create a new timer every single time someone gets out of a vehicle. Use Vehicle.spawn() in this case as well so you don't have to destroy it and recreate the vehicle. Using vehicle spawn should repair the vehicle and put it back to the position you wanted. If using vehicle.spawn() doesn't repair the vehicle or anything ignore this. Just another idea of implementing this.
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