Jump to content

How can I respawn vehicles which aren't being used


Recommended Posts

Posted

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

Posted (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:

Edited by 7inage
  • Like 1
Posted
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:

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.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...