Jump to content

Vanishing vehicle


ODutii

Recommended Posts

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

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

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

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
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 by ODutii
Link to comment
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)

 

  • Like 1
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...