orcun99 Posted July 4, 2017 Share Posted July 4, 2017 addEvent("respawnVehicle",true) function respawnVehicleAdmin(player,sec) if tonumber(sec) then setTimer(function(player) local vehicles = getElementsByType("vehicle") for i,v in ipairs(vehicles) do if not getVehicleOccupant(v,0) and not getVehicleOccupant(v,1) and not getVehicleOccupant(v,2) and not getVehicleOccupant(v,3) then respawnVehicle (v) end end end,sec * 1000 , 1 ,player ) end end addEventHandler("respawnVehicle",getRootElement(),respawnVehicleAdmin) this code is working but I wanna auto respawn in every 5min some one can edit pls? Link to comment
keymetaphore Posted July 4, 2017 Share Posted July 4, 2017 (edited) The event must be called every five minutes. Or setTimer () function autoRespawn() -- changed the name because it was misleading local vehicles = getElementsByType("vehicle") for i,v in ipairs(vehicles) do if not getVehicleOccupant(v,0) and not getVehicleOccupant(v,1) and not getVehicleOccupant(v,2) and not getVehicleOccupant(v,3) then respawnVehicle (v) end end end setTimer(autoRespawn, 5000, 0) -- timer that runs every 5 mins all the time. If you want to keep the admin function, you'll have to get it into this one or just leave the last one and add this. @orcun99 Edited July 4, 2017 by Gourmet. Link to comment
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