Jump to content

[AYUDA]-[HELP] Auto-Respawn for cars


DarkNeSsOak

Recommended Posts

Hola soy nuevo en esta comunidad, espero que me puedan ayudar, bueno lo que quiero hacer es un auto respawn de autos que diga en el chat vehiculos restaurados en 10 segundos y todos los vehiculos han sido restaurados algo haci pues.

Hi I am new to this community, I hope you can help me, well I want to do is a car auto respawn read in the car chat restored in 10 seconds and all vehicles have been restored as something.

primero este script no es mio lo encontre en mta resources y queria modificarlo y eso pero no me funciona

 


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
Just now, DarkNeSsOak said:

Hola soy nuevo en esta comunidad, espero que me puedan ayudar, bueno lo que quiero hacer es un auto respawn de autos que diga en el chat vehiculos restaurados en 10 segundos y todos los vehiculos han sido restaurados algo haci pues.

Hi I am new to this community, I hope you can help me, well I want to do is a car auto respawn read in the car chat restored in 10 seconds and all vehicles have been restored as something.

primero este script no es mio lo encontre en mta resources y queria modificarlo y eso pero no me funciona

 


local rElement = getRootElement() 
  
function respawnVehicles(player, seconds) 
    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) 
end
  
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

Prueba con esto, esto hará que todos los vehículos hagan respawn

 

local rElement = getRootElement() 
  
function respawnVehicles(player, seconds) 
    local vehicles = getElementsByType ( "vehicle" ) 
    outputChatBox("** Los vehículos hicieron respawn**", rElement, 220, 220, 0, false) 
    for k, vehicle in ipairs ( vehicles ) do 
        if isEmpty( vehicle ) then 
                respawnVehicle ( vehicle ) 
            end 
        end 
    end
setTimer(respawnVehicles, 180000,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

Lo testeé recién, funciona

Link to comment
  • Recently Browsing   0 members

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