novo Posted December 22, 2012 Share Posted December 22, 2012 Hello. I'm trying to unbind the key "L" but it doesn't seem to work. I'm using server-sided script I'm using the following code; (Not working) unbindKey(thePlayer, "l") bindKey(thePlayer, "l", "both", "chatbox Ad") I've tried also with using: if(executeCommandHandler ( "unbind", thePlayer, "l" )) then else outputDebugString("COULDN'T unBIND") end if(executeCommandHandler ( "bind", thePlayer, "l chatbox Ad" )) then else outputDebugString("COULDN'T BIND") end But it's outputing COULDN'T messages. Link to comment
AhmadQTR Posted December 22, 2012 Share Posted December 22, 2012 unbindKey(thePlayer, "l") bindKey(thePlayer, "l", "both", chatbox Ad) Link to comment
novo Posted December 22, 2012 Author Share Posted December 22, 2012 unbindKey(thePlayer, "l") bindKey(thePlayer, "l", "both", chatbox Ad) bindKey(thePlayer, "l", "both", chatbox Ad) Error - chatbox Ad Link to comment
AhmadQTR Posted December 22, 2012 Share Posted December 22, 2012 Can you put the script or tell me the function name? Link to comment
novo Posted December 22, 2012 Author Share Posted December 22, 2012 function joinLang(thePlayer,commandName,lang) local languageNames = {} for i = 1, #languageNames do if ( lang == languageNames[ i ] ) then bindKey ( thePlayer, "l", "up", "chatbox "..lang ) addCommandHandler(lang, chatMSG) setElementData(thePlayer, "lang", lang) end end end addCommandHandler("join", joinLang) Link to comment
AhmadQTR Posted December 22, 2012 Share Posted December 22, 2012 bindKey ( thePlayer, "l", "up", joinLang ) Link to comment
novo Posted December 22, 2012 Author Share Posted December 22, 2012 I don't wanna do that, I've made another function called chatMSG, that's why there's addCommandHandler(lang, chatMSG) Link to comment
csiguusz Posted December 22, 2012 Share Posted December 22, 2012 unbindKey(thePlayer, "l") bindKey(thePlayer, "l", "both", chatbox Ad) bindKey(thePlayer, "l", "both", chatbox Ad) Error - chatbox Ad space is not allowed in commands' and funtions' names Link to comment
novo Posted December 22, 2012 Author Share Posted December 22, 2012 Still not working. I want to use executeCommandHandler because with using bindKey when you press "L", it doesn't show "Language:". Any ideas? Link to comment
csiguusz Posted December 22, 2012 Share Posted December 22, 2012 I dont really know what you want to do, so its hard to help. Bindkey should work also, maybe there are some other mistakes. If you would post the whole script it would be easier because the code that you wrote here before doesn't makes much sense to me. Link to comment
novo Posted December 22, 2012 Author Share Posted December 22, 2012 I just want to do that when you press L it shows you English: and then you can type, like T (added by MTA) The following code is outputing CANT BIND if not executeCommandHandler("bind l chatbox English", thePlayer, "") then outputChatBox("CANT BIND") end Link to comment
Castillo Posted December 22, 2012 Share Posted December 22, 2012 What you can do instead is create just one bind, for "Language" chat, and then it checks the player language and sends it to only these with the same language. Link to comment
novo Posted December 22, 2012 Author Share Posted December 22, 2012 What you can do instead is create just one bind, for "Language" chat, and then it checks the player language and sends it to only these with the same language. I only need to know how to make a bind for L that when you press L it shows you Language: and then you can type.. Only that Link to comment
csiguusz Posted December 22, 2012 Share Posted December 22, 2012 Your code is not correct, there should be just one word, the name of the command at argument one, and the additional parameters at the end of the function, like this: executeCommandHandler("bind", thePlayer, "l chatbox English") And I think you cant use executeCommandHandler on commands like say, bind, quit (etc.) and commands from other resources, only on commands that you added with addCommandHandler in the same resource. Link to comment
Castillo Posted December 22, 2012 Share Posted December 22, 2012 Try this: addEventHandler ( "onPlayerJoin", root, function ( ) bindKey ( source, "l", "down", "chatbox", "Language" ) end ) addEventHandler ( "onResourceStart", resourceRoot, function ( ) for _, player in ipairs ( getElementsByType ( "player" ) ) do bindKey ( player, "l", "down", "chatbox", "Language" ) end end ) addCommandHandler ( "Language", function ( thePlayer, _, ... ) local playerLanguage = getElementData ( thePlayer, "lang" ) for _, player in ipairs ( getElementsByType ( "player" ) ) do if ( getElementData ( player, "lang" ) == playerLanguage ) then outputChatBox ( playerLanguage ..": ".. getPlayerName ( thePlayer ) ..": ".. table.concat ( { ... }, " " ), player, 255, 255, 255 ) end end end ) Link to comment
novo Posted December 22, 2012 Author Share Posted December 22, 2012 It's working Solid ^ Thank you ! 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