Jump to content

[HELPx8]Auto-Respawn vehicles


||BuLLeT||

Recommended Posts

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

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...