Hello friends. I did a panel to create vehicles, and after 5 seconds after I created. I want it to be destroyed.
and I want the time to stop, after I enter the vehicle
my attempt
-- onDestroyVehicle
----------------------------------------------------------------------------------------
addEventHandler("onVehicleEnter", veiculo[source],
function()
if isTimer(veiculo[source]) then
killTimer(veiculo[source])
end
end)
addEventHandler("onVehicleExit", veiculo[source],
function()
veiculo[source] = setTimer(function(source)
if isPedInVehicle(source)== false then
if ( isElement ( veiculo[source] ) ) then
destroyElement ( veiculo[source] )
end
end
end, 5000, 1, source) -- arrume o tempo em milisegundos nessa linha tempo atual ? "5000"
end)
part of my script that is working perfect
function destroirCarro()
if veiculo[source] and isElement(veiculo[source]) then
destroyElement(veiculo[source])
end
end
addEventHandler("onPlayerLogout", getRootElement(), destroirCarro)
addEventHandler("onPlayerQuit", getRootElement(), destroirCarro)
addEventHandler("onPlayerWasted", getRootElement(), destroirCarro)
-- onVehicleExplode
function VehicleExplode()
local isCreatedByPlayer = false;
for k, v in pairs( veiculo ) do
if ( v == source ) then
isCreatedByPlayer = k;
break;
end
end
if ( isCreatedByPlayer ) then
setTimer (
function( vehicle, owner )
destroyElement( vehicle )
veiculo[owner] = nil
end
, 5000, 1, source, isCreatedByPlayer )
end
end
addEventHandler("onVehicleExplode", root, VehicleExplode)