Jump to content

I need help (destroying vehicles)


Recommended Posts

I write the code just because I'm bored

and I have nothing to do.

you have to try it by yourself.!

  
local destroyDelay = 20; -- delay in minutes (20) 
local hunterID = 425;  
local timers = {};  
  
addEventHandler ("onVehicleExit", getRootElement (), 
  function ()  
    -- check if vehicle is a hunter. 
    if getElementModel (source) ~= hunterID then return; end;  
    -- check if there are any player in the vehicle. 
   local occupants = getVehicleOccupants (source);  
   local anyPlayerInside = false;  
   for _,pairs (occupants) do anyPlayerInside = true; break; end;  
   -- do nothing if there is a player inside. 
   if anyPlayerInside then return; end;  
    
   -- otherwise... 
   timers [source] = setTimer (  
          destroyElement, 
          destroyDelay * 60000, 1, 
          source); 
  end);  
  
addEventHandler ("onVehicleEnter", getRootElement (), 
     function ()  
           -- check if vehicle is a hunter 
           if getElementModel(source) ~= hunterID then return; end;  
            
           if isTimer (timers [source]) then killTimer(timers[source]); end;  
     end);  
  

Link to comment

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...