Jump to content

[Question] destroy vehicle


Stranger

Recommended Posts

Posted

hey guys, i was wondering how if i was in a vehicle , and i make code that if the player enter the vehicle, the code will work if

he exit not work, but how to make it if the vehicle destroyed not work ?

Posted

will i tried, but not work:

setTimer (function () 
local vehicle = getPedOccupiedVehicle (source) 
if not isElement (vehicle) and not isPedInVehicle (source) then 
killTimer (timer[source]) 
timer[source] = nil 
end 
end, 3000, 0) 

  • Moderators
Posted

Please use google translate and tell us again what you are trying to do.

I understood you wanted to destroy the vehicle after 3 secs when someone enters but not when he leave the car before the 3 secs. This make no sense so I'm waiting for your explanations.

Posted

i said, that if the player entered the vehicle, and there is a timer, the timer will work , but if he go out the vehicle the timer stop, i want it if the vehicle destroyed the timer stop.

i make like that but not working:

setTimer (function (source) 
veh = getPedOccupiedVehicle (source) 
if veh then 
if isElement (veh) and not isPedInVehicle (source) then 
killTimer (timer[source]) 
timer[source] = nil 
end 
end 
end, 2000, 0) 

Posted
  
addEventHandler("onVehicleEnter",yourvehicle, 
function (ply) 
veh = getPlayerOccupiedVehicle(ply) 
timer = setTimer(des,5000,1,ply,veh) 
end 
) 
function  des (play,vehi) 
if isElement(vehi) and isPedInVehicle(play) then 
destroyElement(vehicle) 
end 
  

Posted

will, thanks for your help, but this is not what i meant,i will try to tell you what i meant in easy way , ok i meant if there is a timer ok ? and the timer not work if the player out of the car, if he enterd the car , the timer will start, but if he exit from the vehicle, the timer stop, and this i can use to make like what i said now, 'onVehicleEnter', 'onVehicleExit' setTimer .. killTimer .. ok ? but i want it if the player in the vehicle and lit's say an admin destroyed the vehicle ok ? how to make the timer stop ?

if the vehicle destroyed and the player in the vehicle the timer will keep going not gonna stop until i restart the mode, so i hope that what I have said to you very clear.

Posted

Look dude, you don't need to stop the timer, because it already will check if the player is still in the vehicle after the timer finish, so i made it for you in an easier way, test it, it's the same of what you wanted, and good luck in what you're doing.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...