function respawnVehicle(vehicle)
if vehicle == nil then return end
if getElementType(vehicle) ~= "vehicle" then return end
sx = getElementData(vehicle,"posX");
sy = getElementData(vehicle,"posY");
sz = getElementData(vehicle,"posZ");
rx = getElementData(vehicle,"rotX");
ry = getElementData(vehicle,"rotY");
rz = getElementData(vehicle,"rotZ");
spawnVehicle ( vehicle,sx, sy, sz, rx, ry, rz )
end
function vehicleExplode()
setTimer ( respawnVehicle, 100000, 1, source )
end
addEventHandler ( "onVehicleExplode", getRootElement(), vehicleExplode );
[ Dodano: 2014-08-25, 13:37 ]
A komende chyba ?atwo dorobi?...
kubak14, po co piszesz na nowo funkcje respawnVehicle skoro ju? jest taka funkcja w MTA https://wiki.multitheftauto.com/wiki/RespawnVehicle ? Dodatkowo on chcia? kod na respawn nieu?ywanych pojazd?w co 50 sekund, a nie respawn zniszczonych pojazd?w.
function respawnVehicle(vehicle)
if vehicle == nil then return end
if getElementType(vehicle) ~= "vehicle" then return end
sx = getElementData(vehicle,"posX");
sy = getElementData(vehicle,"posY");
sz = getElementData(vehicle,"posZ");
rx = getElementData(vehicle,"rotX");
ry = getElementData(vehicle,"rotY");
rz = getElementData(vehicle,"rotZ");
spawnVehicle (vehicle, sx, sy, sz, rx, ry, rz)
end
function vehicleExplode()
setTimer (respawnVehicle, 2000, 1, source)
end
addEventHandler ("onVehicleExplode", getRootElement(), vehicleExplode)
function respawnaut()
setTimer(respawnVehicle, 2000, 1, source )
outputChatBox("Za 2 sekund nast?pi respawn nie u?ywanych aut!")
end
addCommandHandler("respawn", respawnaut)
Kod sprawdz czy pojazd jest pusty, je?li jest to wykonuje kod dalej :
local respawn = 30
local r
addCommandHandler("unspawn",function(player)
local accName = getAccountName ( getPlayerAccount ( player ) )
if not isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then return end
if isTimer(r) then
resetTimer(r)
outputDebugString("Srut")
return
end
outputChatBox( "Respawn pojazd?w nast?pi za 30 sekund !",root, 255, 255, 255 )
outputDebugString("Srut")
r = setTimer(function()
for _, vehicle in ipairs ( getElementsByType ( "vehicle" ) ) do
if getElementData ( vehicle, "zapisany" ) then
if isEmpty ( vehicle ) then
local x = getElementData ( vehicle, "x" )
local y = getElementData ( vehicle, "y" )
local z = getElementData ( vehicle, "z" )
local r1 = getElementData ( vehicle, "r1" )
local r2 = getElementData ( vehicle, "r2" )
local r3 = getElementData ( vehicle, "r3" )
setElementPosition ( vehicle, tonumber(x), tonumber(y), tonumber(z) )
setElementRotation ( vehicle, tonumber (r1), tonumber(r2), tonumber(r3) )
end
else
if isEmpty( vehicle ) then
destroyElement ( vehicle )
end
end
end
--end
outputDebugString("Jeeeb unspawn")
outputChatBox("Respawn pojazd?w gotowy", root, 255, 255, 255)
end,respawn*1000,1)
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
Nie możesz pisać nowych tematów Nie możesz odpowiadać w tematach Nie możesz zmieniać swoich postów Nie możesz usuwać swoich postów Nie możesz głosować w ankietach