Jump to content

Event gets triggered, while it should not get triggered


Recommended Posts

Hi!
As i log into my server, i recieve a lot of warnings, which are really annoying, due to a timer, who is spamming it, i don't even understand why is it spamming my debugscript, while i am not in a vehicle, just standing.pfkXk4l.jpg

 

function bekapcsoltOvEllenorzese(jatekos) --this is line 55
	if isPedInVehicle (jatekos) == true and getElementData (jatekos, "bekapcsoltOv") == false then
		if isTimer(beeping) then
			killTimer (beeping)
			beeping = setTimer ( function()
			triggerClientEvent ("beltWarning", jatekos)
			bindKey (jatekos, "F5", "down", "öv")
			end, 1000, 0)
		else
			beeping = setTimer ( function()
			triggerClientEvent ("beltWarning", jatekos)			
			bindKey (jatekos, "F5", "down", "öv")
			end, 1000, 0)
		end
	end
end
addEventHandler ("onVehicleEnter", getRootElement(), bekapcsoltOvEllenorzese) --this is line 71

I am not even in a vehicle, so i don't know why the function gets called, while it has "onVehicleEnter"... 

Link to comment

Add this to your script

function ss()
  for k,player in ipairs(getElementsByType("player")) do
   bindKey (player, "F5", "down", "öv")
    end
end
addEventHandler("onResourceStart",resourceRoot,ss)
addEventHandler("onPlayerJoin",root,ss)

 

  • Like 1
Link to comment
1 hour ago, #BrosS said:

Add this to your script


function ss()
  for k,player in ipairs(getElementsByType("player")) do
   bindKey (player, "F5", "down", "öv")
    end
end
addEventHandler("onResourceStart",resourceRoot,ss)
addEventHandler("onPlayerJoin",root,ss)

 

Why would you re-bind the command when somebody joins for every single player?

  • Like 1
Link to comment
function ss()
	if source and getElementType(source) == "player" then -- check if it's been called by onPlayerJoin not onResourceStart
   		bindKey (source, "F5", "down", "öv")
	else
  		for k,player in ipairs(getElementsByType("player")) do
  			bindKey (player, "F5", "down", "öv")
  		end
  	end
end
addEventHandler("onResourceStart",resourceRoot,ss)
addEventHandler("onPlayerJoin",root,ss)

 

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