Guest Posted April 6, 2009 Share Posted April 6, 2009 local bind = 1 function pJoin() bindKey( source, "arrow_r", "down", cSelect ) end addEventHandler( "onPlayerJoin", getRootElement(), pJoin ) function onpSpawn() if ( bind == 1 ) then unBindKey( source, "arrow_r", "down", cSelect ) bind = 0 end end addEventHandler( "onPlayerSpawn", getRootElement(), onpSpawn ) I have the bind variable, because i do not want this code to unbind every time the player spawns. I want it to run just the first time he spawns. Everything works fine, but i get this error. "Attempt to call global 'UnBindKey' " Could someone please help. I'd appreciate it very much. Thanks :] Link to comment
robhol Posted April 6, 2009 Share Posted April 6, 2009 Congratulations, you actually spelled the function wrong. (Well, capitalized the wrong letters, but to the computer that's the same.) unbindKey Link to comment
Lordy Posted April 6, 2009 Share Posted April 6, 2009 And another one who has not yet seen the debugging tutorial on wiki (it has an example of outputChatbox and outputChatBox) Link to comment
50p Posted April 7, 2009 Share Posted April 7, 2009 You have one global variable bind. Whenever a player spawns another player will have the key bound even when he spawns, why? Because that one global variable is 0. You don't have to use that global var to check if the key was bound. You can use isKeyBound() to check if the key "arrow_r" is bound already.. then you can unbindKey if isKeyBound() returned true. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now