novo Posted December 22, 2012 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.
AhmadQTR Posted December 22, 2012 Posted December 22, 2012 unbindKey(thePlayer, "l") bindKey(thePlayer, "l", "both", chatbox Ad)
novo Posted December 22, 2012 Author Posted December 22, 2012 unbindKey(thePlayer, "l") bindKey(thePlayer, "l", "both", chatbox Ad) bindKey(thePlayer, "l", "both", chatbox Ad) Error - chatbox Ad
AhmadQTR Posted December 22, 2012 Posted December 22, 2012 Can you put the script or tell me the function name?
novo Posted December 22, 2012 Author 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)
AhmadQTR Posted December 22, 2012 Posted December 22, 2012 bindKey ( thePlayer, "l", "up", joinLang )
novo Posted December 22, 2012 Author 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)
csiguusz Posted December 22, 2012 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
novo Posted December 22, 2012 Author 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?
csiguusz Posted December 22, 2012 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.
novo Posted December 22, 2012 Author 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
Castillo Posted December 22, 2012 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.
novo Posted December 22, 2012 Author 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
csiguusz Posted December 22, 2012 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.
Castillo Posted December 22, 2012 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 )
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