Jump to content

como hacer que los coches se respawnen cada 10 minutos


Chaky

Recommended Posts

function respawnVehicles() 
     outputChatBox("#FFFF00*Reiniciando vehiculos vacios en 30s *", root, 255, 255, 255, true)     
    outputChatBox("#0040FF*Respawning All Empty Vehicles in 30s *", root, 255, 255, 255, true) 
    setTimer(function () 
    local vehicles = getElementsByType ( "vehicle" ) 
    outputChatBox("#0EF629*Vehiculos vacios han sido reiniciados*", root, 255, 255, 255, true) 
    outputChatBox("#00ccFf*Empty Vehicles has been respawned*", root, 255, 255, 255, true) 
    for k, vehicle in ipairs ( vehicles ) do 
        if isEmpty( vehicle ) then 
            respawnVehicle ( vehicle ) 
        end 
    end 
    end, 30000, 1) -- edita el tiempo en el qe se respawnean los autos 
end 
setTimer(respawnVehicles, 1000000, 0)-- edita el tiempo de diferencia entre cada respawn. Suerte 
  
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

Version con variantes, solo he añadido un poco de aritmetica

Tiempo_de_aviso = 30 -- En segundos 
Tiempo_de_respawn = 10  -- En minutos 
  
function respawnVehicles() 
    outputChatBox("#FFFF00*Reiniciando vehiculos vacios en 30s *", root, 255, 255, 255, true)     
    outputChatBox("#0040FF*Respawning All Empty Vehicles in 30s *", root, 255, 255, 255, true) 
    setTimer(function () 
    local vehicles = getElementsByType ( "vehicle" ) 
    outputChatBox("#0EF629*Vehiculos vacios han sido reiniciados*", root, 255, 255, 255, true) 
    outputChatBox("#00ccFf*Empty Vehicles has been respawned*", root, 255, 255, 255, true) 
    for k, vehicle in ipairs ( vehicles ) do 
        if isEmpty( vehicle ) then 
            respawnVehicle ( vehicle ) 
        end 
    end 
    end, (Tiempo_de_aviso * 1000), 1) 
end 
setTimer(respawnVehicles, (Tiempo_de_respawn * 60000), 0) 
  
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 
-- Creditos a Alex 

YouTube video de este post:

Edited by Guest
Link to comment
function respawnVehicles() 
     outputChatBox("#FFFF00*Reiniciando vehiculos vacios en 30s *", root, 255, 255, 255, true)     
    outputChatBox("#0040FF*Respawning All Empty Vehicles in 30s *", root, 255, 255, 255, true) 
    setTimer(function () 
    local vehicles = getElementsByType ( "vehicle" ) 
    outputChatBox("#0EF629*Vehiculos vacios han sido reiniciados*", root, 255, 255, 255, true) 
    outputChatBox("#00ccFf*Empty Vehicles has been respawned*", root, 255, 255, 255, true) 
    for k, vehicle in ipairs ( vehicles ) do 
        if isEmpty( vehicle ) then 
            respawnVehicle ( vehicle ) 
        end 
    end 
    end, 30000, 1) -- edita el tiempo en el qe se respawnean los autos 
end 
setTimer(respawnVehicles, 1000000, 0)-- edita el tiempo de diferencia entre cada respawn. Suerte 
  
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 

okay pero esto lo pongo en el Lua ?

Link to comment
  • Recently Browsing   0 members

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