Jump to content

timer


Amine#TN

Recommended Posts

function carDestroy () 
  if  not (isGuestAccount (getPlayerAccount (source))) then
    if (isPedInVehicle (source)) then
      if (getElementID(getPedOccupiedVehicle(source)) == getAccountName (getPlayerAccount(source))) then
        setElementHealth (getElementData (source, "hisCar"), 0)
        destroyElement (getPedOccupiedVehicle (source))
        removeElementData (source, "hisCar")
        outputChatBox ("Car Destroyed.", source, 255, 0, 0)
      else
        outputChatBox ("This not your car!", source, 255, 0, 0)
      end
    elseif (not (isPedInVehicle (source))) and (getElementData (source, "hisCar")) and (getElementData (source, "hisCar") ~= nil) then
      car=getElementData(source, "hisCar")
      destroyElement(car)
      outputChatBox ("Car Destroyed.", source, 255, 0, 0)
      removeElementData (source, "hisCar")
  
    end
  end
end
addEventHandler ("carDestroy", getRootElement(), carDestroy)




------------
last times no one gives help i hope that time one pro scripter give help 
i need when player use that fonction he will not use it again only after 10 min 
i try but i fail to add that timer

Link to comment

What about this?

local timer = false

function carDestroy () 
	if timer == false then
		if  not (isGuestAccount (getPlayerAccount (source))) then
			if (isPedInVehicle (source)) then
				if (getElementID(getPedOccupiedVehicle(source)) == getAccountName (getPlayerAccount(source))) then
					setElementHealth (getElementData (source, "hisCar"), 0)
					destroyElement (getPedOccupiedVehicle (source))
					removeElementData (source, "hisCar")
					outputChatBox ("Car Destroyed.", source, 255, 0, 0)
					timer = true
					setTimer(function ()
						timer = false
						--outputChatBox ("Event available again", source, 255, 0, 0)
					end, 600000, 1)
				else
					outputChatBox ("This not your car!", source, 255, 0, 0)
				end
			elseif (not (isPedInVehicle (source))) and (getElementData (source, "hisCar")) and (getElementData (source, "hisCar") ~= nil) then
				car=getElementData(source, "hisCar")
				destroyElement(car)
				outputChatBox ("Car Destroyed.", source, 255, 0, 0)
				removeElementData (source, "hisCar")
				timer = true
				setTimer(function ()
					timer = false
					--outputChatBox ("Event available again", source, 255, 0, 0)
				end, 600000, 1)
			end
		end
	else
	--	outputChatBox ("10 minutes", source, 255, 0, 0)
	end
end
addEventHandler ("carDestroy", getRootElement(), carDestroy)

 

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