Jump to content

One timer or more for same ID cars


ds1-e

Recommended Posts

  • Scripting Moderators

Hey, i have a problem. When player leave from vehicle, timer starts and after it blow vehicle. My problem is that if i spawn 2 cars with same ID, one of them will explode, and another one will stay in a place. So my question is how to do one or more timer for the same ID cars, because i don't have any idea.

Edited by majqq
Link to comment
  • Scripting Moderators
34 minutes ago, Patrick2562 said:

Paste the code.

function onPlayerExitDayzVehicle(veh, seat)
	if isVehicleBlown(veh) then return end
	if isTimer(vehTimer) then return end

		if not isVehicleEmpty(veh) then return end
		local vehTimer = setTimer(function () 
		local col = getElementData(veh, "parent")
		if col then
			setElementData(veh, "vehicle:station", 0)
			setElementPosition(veh, 2490.99316, -1666.45313, 13.34375)
			blowVehicle(veh, false)
		end
		end, 20000, 1)
	end

	if seat == 0 then
		setVehicleEngineState(veh, false)

	unbindKey(source, "k", "down", setEngineState)
	unbindKey(source, "l", "down", consoleVehicleLights)
end
addEventHandler("onPlayerVehicleExit", getRootElement(), onPlayerExitDayzVehicle)

 

Link to comment
  • Moderators
10 minutes ago, majqq said:

function onPlayerExitDayzVehicle(veh, seat)
	if isVehicleBlown(veh) then return end
	if isTimer(vehTimer) then return end

		if not isVehicleEmpty(veh) then return end
		local vehTimer = setTimer(function () 
		local col = getElementData(veh, "parent")
		if col then
			setElementData(veh, "vehicle:station", 0)
			setElementPosition(veh, 2490.99316, -1666.45313, 13.34375)
			blowVehicle(veh, false)
		end
		end, 20000, 1)
	end

	if seat == 0 then
		setVehicleEngineState(veh, false)

	unbindKey(source, "k", "down", setEngineState)
	unbindKey(source, "l", "down", consoleVehicleLights)
end
addEventHandler("onPlayerVehicleExit", getRootElement(), onPlayerExitDayzVehicle)

 

 

You do not specify the vehicle ID anywhere.

(Write down what you want exactly. If have 2 Infernus spawned and all passengers get out from one infernus, then blow up both?)

Link to comment
  • Scripting Moderators

Well i wanna fix the timer. For now if u spawn another or same car while timer is running, another vehicle don't blow up. Only the last which was used.

Link to comment
  • Moderators
11 hours ago, majqq said:

Well i wanna fix the timer. For now if u spawn another or same car while timer is running, another vehicle don't blow up. Only the last which was used.

Ye, because this is in that script.

How you spawn the vehicle?

Edited by Patrick2562
Link to comment

the code says that if you leave the vehicle it will blow up, what you want is when you leave the sultan for example, all the sultan's in the game will be blown up? because i can see that you are talking about the vehicle's ID's are the same idk if you mean the model or what

Link to comment
  • 2 weeks later...
  • Scripting Moderators
On 27/11/2018 at 12:44, savour said:

the code says that if you leave the vehicle it will blow up, what you want is when you leave the sultan for example, all the sultan's in the game will be blown up? because i can see that you are talking about the vehicle's ID's are the same idk if you mean the model or what

I need something like unique timer for each car, because on server players spawn a lot of cars, and f.e if player leave a car with id 411 it set up a timer which should destroy vehicle if noone was inside,  after X seconds. However if player spawn 2 same vehicles there's a problem with the timer, as i said above one vehicle will disappear and other not.

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