ODutii Posted July 25, 2019 Share Posted July 25, 2019 I have a little problem with my script. I did for when he goes to the marker, he creates a vehicle, and I'm trying to create for when the player leaves the vehicle, wait 5 minutes, with the player off the vehicle, the vehicle disappears, and it didn't. can help me? Link to comment
HassoN Posted July 25, 2019 Share Posted July 25, 2019 If I understood you, you want that when a player enters a marker he gets a vehicle and after 5 mins of him leaving the marker the vehicle disappear? If so, you may use: onMarkerHit -- when player enters your marker createVehicle -- create your vehicle onMarkerLeave -- when player leaves the marker setTimer -- set a timer of 5 mins destroyElement -- destroy the vehicle. Link to comment
ODutii Posted July 25, 2019 Author Share Posted July 25, 2019 No, I meant that when he enters the marker, he creates a vehicle, and the player teleports to the vehicle, but when he leaves the vehicle, if he doesn't return, the vehicle will disappear in 5 minutes, it's like a work to deliver pizza, if he leaves and doesn't come back(from the vehicle), the vehicle disappears. Link to comment
HassoN Posted July 25, 2019 Share Posted July 25, 2019 In that case: addEventHandler -- onMarkerHit createVehicle -- use a table to create the vehicle so each player has his own vehicle. warpPedIntoVehicle -- warp the player into your newly created vehicle. addEventHandler -- onVehicleExit setTimer -- set it to 5 mins destroyElement -- destroy the vehicle -- also you need: addEventHandler -- onVehicleEnter killTimer -- to kill your timer in case the player return to his vehicle. Link to comment
ODutii Posted July 25, 2019 Author Share Posted July 25, 2019 (edited) the script to pick up the vehicle and teleport until it worked, but the problem is that when I get out of the vehicle the vehicle disappears instantly, I want it to disappear in 5 minutes, see what I'm doing wrong function leavevehicle(player) if veh1[player] and isElement(veh1[player]) then t = setTimer ( leavevehicle, 5000, 1, destroyElement(veh1[player])) -- I put 5 seconds to see the fastest results, but still it disappears instantly end end addEventHandler("onVehicleExit", getRootElement(), leavevehicle)function entervehicle(player) killTimer (t) end addEventHandler("onVehicleEnter", getRootElement(),entervehicle) Edited July 25, 2019 by ODutii Link to comment
HassoN Posted July 25, 2019 Share Posted July 25, 2019 local myTimers = {} function leaveVehicle(player) if veh1[player] and isElement(veh1[player]) then myTimers[player] = setTimer(destroyElement, 5000, 1, veh1[player]) end end addEventHandler("onVehicleExit", getRootElement(), leavevehicle) function entervehicle(player) if (isTimer(myTimers[player])) then killTimer(myTimers[player]) end end addEventHandler("onVehicleEnter", getRootElement(),entervehicle) 1 Link to comment
ODutii Posted July 25, 2019 Author Share Posted July 25, 2019 Thanks man, you helped a lot! Thanks !!!! Link to comment
HassoN Posted July 25, 2019 Share Posted July 25, 2019 4 minutes ago, ODutii said: Thanks man, you helped a lot! Thanks !!!! Anytime 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