GamerDeMTA Posted July 29, 2013 Share Posted July 29, 2013 Hey! I need some help, I want to destroy the vehicles which ID is 425 (HUNTER), it destroys if nobody uses it for 20 mins. how to? [but only Hunter!] Link to comment
PaiN^ Posted July 29, 2013 Share Posted July 29, 2013 Events : onResourceStart -onVehicleEnter - onVehicleExit . Functions : table - isTimer - setTimer - destroyElement . Link to comment
GamerDeMTA Posted July 29, 2013 Author Share Posted July 29, 2013 and for do it only for 425 ID? D: that's too hard for me isn't there any resource or something Link to comment
Castillo Posted July 29, 2013 Share Posted July 29, 2013 You must check the vehicle model with: getElementModel Link to comment
Vector Posted July 29, 2013 Share Posted July 29, 2013 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now