||BuLLeT|| Posted January 27, 2013 Share Posted January 27, 2013 hey i got respawn vehicles system, when admin do /respawn , unoccupied vehs respawn, but i want it to auto respawn every 10 minutes! respawn.lua (server) local rElement = getRootElement() function respawnVehicles(player, cmd, seconds) if tonumber(seconds) then if not hasObjectPermissionTo(player, "function.banPlayer") then outputChatBox("This command is only executeable for administrators", player, 255, 0, 0, false) return end outputChatBox("** All unoccupied vehicles will be respawned in " .. seconds .. " seconds **", rElement, 220, 220, 0, false) setTimer(function (player) local vehicles = getElementsByType ( "vehicle" ) outputChatBox("** All unoccupied vehicles respawned **", rElement, 220, 220, 0, false) outputDebugString(getPlayerName(player) .. " respawned vehicles.") for k, vehicle in ipairs ( vehicles ) do if isEmpty( vehicle ) then respawnVehicle ( vehicle ) end end end, seconds * 1000, 1, player) else outputChatBox("Syntax: /respawn ", player, 220, 220, 0, false) end end addCommandHandler("respawn",respawnVehicles) function isEmpty( vehicle ) local passengers = getVehicleMaxPassengers( vehicle ) if type( passengers ) == 'number' then for seat = 0, passengers do if getVehicleOccupant( vehicle, seat ) then return false end end end return true end Link to comment
||BuLLeT|| Posted January 27, 2013 Author Share Posted January 27, 2013 thanks but idk where to put it Link to comment
Castillo Posted January 27, 2013 Share Posted January 27, 2013 You must create a new function, which will be executed infinity times with a timer every 10 minutes. 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