I never got this when my server was 1.0.5. A bunch of problems presented themselves (which I think I've gotten fixed) when I updated to 1.1. Well, I just noticed that when I respawn all the vehicles, the vehicles owned by players spawn with black smoke and blown up doors. Weird thing is, the faction vehicles (ex. LSPD, News, Taxi, Bus) don't respawn all messed up. Only vehicles owned by players.
Note: I don't get any errors/warnings about it on debugscript 3
Here's the vehicle respawn command code/script:
function respawnAllVehicles(thePlayer, commandName, timeToRespawn)
if (exports.global:isPlayerAdmin(thePlayer)) then
if commandName then
if isTimer(respawnTimer) then
outputChatBox("There is already a Vehicle Respawn active, /respawnstop to stop it first.", thePlayer, 255, 0, 0)
else
timeToRespawn = tonumber(timeToRespawn) or 30
timeToRespawn = timeToRespawn < 10 and 10 or timeToRespawn
for k, arrayPlayer in ipairs(exports.global:getAdmins()) do
local logged = getElementData(arrayPlayer, "loggedin")
if (logged) then
if exports.global:isPlayerLeadAdmin(arrayPlayer) then
outputChatBox( "LeadAdmWarn: " .. getPlayerName(thePlayer) .. " executed a vehicle respawn.", arrayPlayer, 255, 194, 14)
end
end
end
outputChatBox("*** All vehicles will be respawned in "..timeToRespawn.." seconds! ***", getRootElement(), 255, 194, 14)
outputChatBox("You can stop it by typing /respawnstop!", thePlayer)
respawnTimer = setTimer(respawnAllVehicles, timeToRespawn*1000, 1, thePlayer)
end
return
end
local tick = getTickCount()
local vehicles = exports.pool:getPoolElementsByType("vehicle")
local counter = 0
local tempcounter = 0
local tempoccupied = 0
local occupiedcounter = 0
local unlockedcivs = 0
local notmoved = 0
local dimensions = { }
for k, p in ipairs(getElementsByType("player")) do
dimensions[ getElementDimension( p ) ] = true
end
for k, theVehicle in ipairs(vehicles) do
if isElement( theVehicle ) then
local dbid = getElementData(theVehicle, "dbid")
if not (dbid) or (dbid<0) then -- TEMP vehicle
local driver = getVehicleOccupant(theVehicle)
local pass1 = getVehicleOccupant(theVehicle, 1)
local pass2 = getVehicleOccupant(theVehicle, 2)
local pass3 = getVehicleOccupant(theVehicle, 3)
if (dbid and dimensions[dbid + 20000]) or (pass1) or (pass2) or (pass3) or (driver) or (getVehicleTowingVehicle(theVehicle)) or #getAttachedElements(theVehicle) > 0 then
tempoccupied = tempoccupied + 1
else
destroyElement(theVehicle)
tempcounter = tempcounter + 1
end
else
local driver = getVehicleOccupant(theVehicle)
local pass1 = getVehicleOccupant(theVehicle, 1)
local pass2 = getVehicleOccupant(theVehicle, 2)
local pass3 = getVehicleOccupant(theVehicle, 3)
if (dimensions[dbid + 20000]) or (pass1) or (pass2) or (pass3) or (driver) or (getVehicleTowingVehicle(theVehicle)) or #getAttachedElements(theVehicle) > 0 then
occupiedcounter = occupiedcounter + 1
else
if isVehicleBlown(theVehicle) or isElementInWater(theVehicle) then
fixVehicle(theVehicle)
if armoredCars[ getElementModel( theVehicle ) ] then
setVehicleDamageProof(theVehicle, true)
else
setVehicleDamageProof(theVehicle, false)
end
for i = 0, 5 do
setVehicleDoorState(theVehicle, i, 4) -- all kind of stuff missing
end
setElementHealth(theVehicle, 300) -- lowest possible health
end
exports['anticheat-system']:changeProtectedElementDataEx(theVehicle, 'i:left')
exports['anticheat-system']:changeProtectedElementDataEx(theVehicle, 'i:right')
if getElementData(theVehicle, "owner") == -2 and getElementData(theVehicle,"Impounded") == 0 then
if isElementAttached(theVehicle) then
detachElements(theVehicle)
end
respawnVehicle(theVehicle)
setVehicleLocked(theVehicle, false)
unlockedcivs = unlockedcivs + 1
else
local checkx, checky, checkz = getElementPosition( theVehicle )
local x, y, z, rx, ry, rz = unpack(getElementData(theVehicle, "respawnposition"))
if (round(checkx, 6) == x) and (round(checky, 6) == y) then
notmoved = notmoved + 1
else
if isElementAttached(theVehicle) then
detachElements(theVehicle)
end
setElementPosition(theVehicle, x, y, z)
setVehicleRotation(theVehicle, rx, ry, rz)
setElementInterior(theVehicle, getElementData(theVehicle, "interior"))
setElementDimension(theVehicle, getElementData(theVehicle, "dimension"))
counter = counter + 1
end
end
-- fix faction vehicles
if getElementData(theVehicle, "faction") ~= -1 then
fixVehicle(theVehicle)
if (getElementData(theVehicle, "Impounded") == 0) then
exports['anticheat-system']:changeProtectedElementDataEx(theVehicle, "enginebroke", 0, false)
if armoredCars[ getElementModel( theVehicle ) ] then
setVehicleDamageProof(theVehicle, true)
else
setVehicleDamageProof(theVehicle, false)
end
end
end
end
end
end
end
local timeTaken = (getTickCount() - tick)/1000
outputChatBox(" =-=-=-=-=-=- All Vehicles Respawned =-=-=-=-=-=-=")
outputChatBox("Respawned " .. counter .. "/" .. counter + notmoved .. " vehicles. (" .. occupiedcounter .. " Occupied) .", thePlayer)
outputChatBox("Deleted " .. tempcounter .. " temporary vehicles. (" .. tempoccupied .. " Occupied).", thePlayer)
outputChatBox("Unlocked and Respawned " .. unlockedcivs .. " civilian vehicles.", thePlayer)
outputChatBox("All that in " .. timeTaken .." seconds.", thePlayer)
end
end
addCommandHandler("respawnall", respawnAllVehicles, false, false)
Question
Benevolence
I never got this when my server was 1.0.5. A bunch of problems presented themselves (which I think I've gotten fixed) when I updated to 1.1. Well, I just noticed that when I respawn all the vehicles, the vehicles owned by players spawn with black smoke and blown up doors. Weird thing is, the faction vehicles (ex. LSPD, News, Taxi, Bus) don't respawn all messed up. Only vehicles owned by players.
Note: I don't get any errors/warnings about it on debugscript 3
Here's the vehicle respawn command code/script:
Link to comment
4 answers to this question
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