myonlake Posted November 8, 2011 Share Posted November 8, 2011 (edited) Hello again, What seems to be the problem? It just doesn't show anything or respawn anything. local rElement = getRootElement() function respawnVehicles(player, cmd, seconds) local vehicles = getElementsByType("vehicle") if seconds then if hasObjectPermissionTo(player, "function.banPlayer") then for k, vehicle in ipairs(vehicles) do if getVehicleOccupants(vehicle) == 0 then outputChatBox("** All unoccupied vehicles will be respawned in " .. seconds .. " seconds **", rElement, 220, 220, 0, false) setTimer(function() respawnVehicle(rElement) outputChatBox("** All unoccupied vehicles respawned **", rElement, 220, 220, 0, false) outputDebugString(getPlayerName(player) .. " respawned vehicles.") end, seconds * 1000, 1) end end else outputChatBox("This command is only executeable for administrators", player, 255, 0, 0, false) end else outputChatBox("Syntax: /respawn ", player, 220, 220, 0, false) end end addCommandHandler("respawn", respawnVehicles) Edited May 30, 2019 by myonlake Link to comment
Castillo Posted November 8, 2011 Share Posted November 8, 2011 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 Works (tested). Link to comment
tim260 Posted November 8, 2011 Share Posted November 8, 2011 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 Works (tested). How can i set it to respawn exploded cars who where made in the editor, so are set in the .map file now it only respawns if they are onoccupied Link to comment
myonlake Posted November 8, 2011 Author Share Posted November 8, 2011 How can i set it to respawn exploded cars who where made in the editor, so are set in the .map file now it only respawns if they are onoccupied Use function named: isVehicleBlown(). 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