Add respawning drown vehicles

This commit is contained in:
ChronosX88 2020-04-01 20:23:57 +04:00
parent c4572734fa
commit 36ad4f11f6

View File

@ -46,11 +46,14 @@ addEvent("onPlayerTeamSelected", true)
addEventHandler("onPlayerTeamSelected", root, mainOnPlayerTeamSelected) addEventHandler("onPlayerTeamSelected", root, mainOnPlayerTeamSelected)
addEventHandler("onPlayerJoin", root, mainOnPlayerJoin) addEventHandler("onPlayerJoin", root, mainOnPlayerJoin)
-- respawn exploded vehicle
function respawnExplodedVehicle() function respawnExplodedVehicle()
setTimer(respawnVehicle, 9000, 1, source) setTimer(respawnVehicle, 9000, 1, source)
end end
addEventHandler("onVehicleExplode", root, respawnExplodedVehicle) addEventHandler("onVehicleExplode", root, respawnExplodedVehicle)
--
-- respawn wasted player
addEventHandler("onPlayerWasted", root, addEventHandler("onPlayerWasted", root,
function() function()
local team = getPlayerTeam(source) local team = getPlayerTeam(source)
@ -60,6 +63,21 @@ addEventHandler("onPlayerWasted", root,
end end
end end
) )
--
-- respawn drown vehicle
function respawnDrownVehicle()
for _, vehicle in ipairs(getElementsByType("vehicle")) do
if isElementInWater(vehicle) then
local isOccupied, _ = next(getVehicleOccupants(vehicle))
if not isOccupied then
respawnVehicle(vehicle)
end
end
end
end
setTimer(respawnDrownVehicle, 20000, 0)
--
addEventHandler("onResourceStart", root, addEventHandler("onResourceStart", root,
function () function ()