justn Posted March 16, 2014 Share Posted March 16, 2014 So hi, can someone help me with a script? if theres no player in a vehicle for 30 seconds, then the vehicle will destroy, and if the vehicle gets blown, then the blown car will be destroyed.. I really need this because it prevents lag. Link to comment
manawydan Posted March 16, 2014 Share Posted March 16, 2014 one example(just example): local Vtimers = {} addEventHandler("onVehicleExit",root, function() if not Vtimers[source] then Vtimers[source] = setTimer(destroyElement,30000,1,source) end end) addEventHandler("onVehicleEnter",root, function() if Vtimers[source] and isTimer(Vtimers[source]) then killTimer(Vtimers[source]) end end) Link to comment
JR10 Posted March 16, 2014 Share Posted March 16, 2014 addEventHandler('onVehicleExplode', root, function() setTimer(destroyElement, 5000, 1, source) end) Link to comment
Mr_Moose Posted March 17, 2014 Share Posted March 17, 2014 A complete vehicle system might also be a good solution: https://community.multitheftauto.com/index.php?p=resources&s=details&id=8338 This one let the players spawn or rent vehicles from markers with GUI's and destroys the vehicles when the player logs out, spawn another one or destroy it by themselves with a command, exploded vehicles are cleaned up as well so it's very performance effective. Since it's also using pointers in a table it's easy to create an admin GUI for instance with a list over all existing vehicles where you as a staff can manage them or whatever, and of course it also includes some other interesting features like headlight control by pressing the L key, locking system etc. Luckily vehicles doesn't require very much performance in the first place and the whole idea of removing a vehicle after 30 seconds unused as you suggested may lead to complaints from your players since most players finds it annoying to loose a vehicle in this game. 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