Jump to content

[HELP]Whats the problem here ?


Recommended Posts

WARNING:Wasted/server.lua:5:Bad argument "addEventHandler" [Expected element at argument 2,got nil].

 

The code:

function respawnOnWasted ()
        spawnPlayer (source, 0, 0, 5, 0, math.random (0,288), 0, 0)
	end	
		
addEventHandler( "onPlayerWasted", thePlayer,
    function()
         bindKey ( player, "F", "both", respawnOnWasted )
		  
	end
)

 

 

Link to comment
8 minutes ago, Soapbosnia said:

WARNING:Wasted/server.lua:5:Bad argument "addEventHandler" [Expected element at argument 2,got nil].

 

The code:


function respawnOnWasted ()
        spawnPlayer (source, 0, 0, 5, 0, math.random (0,288), 0, 0)
	end	
		
addEventHandler( "onPlayerWasted", thePlayer,
    function()
         bindKey ( thePlayer, "F", "both", respawnOnWasted )
		  
	end
)

 

 

 

Link to comment
  • Moderators
-- SERVER SIDE

function respawnOnWasted(player)
  	spawnPlayer(player, 0, 0, 5, 0, math.random (0,288), 0, 0)
	unbindKey(player, "F", "both", respawnOnWasted)
end	
		
addEventHandler("onPlayerWasted", getRootElement(), function()
    bindKey(source, "F", "both", respawnOnWasted)
end)

 

  • Thanks 1
Link to comment

Your code doesn't work because you used unknown "thePlayer" element instead of passing getRootElement which literally means "all players". Passing "thePlayer" instead of "source" in the bindKey function also causes errors.

Edited by NeverUnbeatable
  • Thanks 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...