Jump to content

[HELPx8]Auto-Respawn vehicles


||BuLLeT||

Recommended Posts

Posted

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 
  

aC is doing recruitment, we need expirienced drivers! contact me on skype: drevenvan

Our topic: http://forum.mtasa.com/viewtopic.php?f=115&t=68142

n-560x95_FFFFF_FFFFF_00000_00000.png

Posted

You must create a new function, which will be executed infinity times with a timer every 10 minutes.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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