Dealman Posted May 24, 2014 Share Posted May 24, 2014 Recently I started working a bit on adding a global chat, using the default chatbox. I figured out that I can use bindKey like this to enable chatbox input with a custom prefix, in this case, "Global"; bindKey("G", "down", "chatbox", "Global", activateGlobalChat_Handler); However, this seem to be the only way of doing this, and I can't make use of executeCommandHandler which is preventing me from doing what I want with it - a double-bind. What I mean with double-bind is for example, Left Shift+G, Left Alt+G and so on. I'd rather have something like this, than a separate key for each one of them. Does anyone happen to have a workaround to solve this? Edit: I stumbled upon some information while reading about Control_names. This sentence in particular caught my interest; The following are names of hard-coded MTA commands which do not use bindKey, but can act as bindKey by using them in an addCommandHandler. However, I fail to understand what on earth they are trying to say with that. Link to comment
pa3ck Posted May 24, 2014 Share Posted May 24, 2014 I done something like this for my own server, what I did was, I binded a bind. I mean like: function bindChatKey() bindKey("a", "down", chatFunction) end function unbindChatKey() unbindKey("a", "down", chatFunction) end bindKey ( "lshift", "down", bindChatKey) bindKey ( "lshift", "up", unbindChatKey) That's the way I done it, there might be an easier way though. Link to comment
Dealman Posted May 24, 2014 Author Share Posted May 24, 2014 Cheers, it works, but only once. Then it gets stuck. This is how I made it; function activateTeamGlobal_Bind() bindKey("G", "down", "chatbox", "TeamGlobal"); end bindKey("lshift", "down", activateTeamGlobal_Bind); function deactivateTeamGlobal_Bind() unbindKey("G", "down", "chatbox", "TeamGlobal"); bindKey("G", "down", "chatbox", "Global"); -- In case unbind doesn't work end bindKey("lshift", "up", deactivateTeamGlobal_Bind); After I've done LShift+G, it forever gets stuck on TeamGlobal and I can't revert it back to Global. Not even if I bind it again. Link to comment
pa3ck Posted May 25, 2014 Share Posted May 25, 2014 Try to unbind the Global when you bind the TeamGlobal. Link to comment
#RooTs Posted May 25, 2014 Share Posted May 25, 2014 That would be nice, to be able to change the officer who is the "T" Link to comment
'LinKin Posted May 25, 2014 Share Posted May 25, 2014 This client-side bindKey( "g", "down", "Global Chat", function () if getKeyState( "lshift" ) == true then -- Here you'd do your code end end ) Link to comment
Dealman Posted May 25, 2014 Author Share Posted May 25, 2014 Sorry but that doesn't help. Pa3ck's solution is as close as I can get. Link to comment
pa3ck Posted June 2, 2014 Share Posted June 2, 2014 Well, as I said, you never unbind the "bindKey("G", "down", "chatbox", "Global");", so actually there are 2 handlers called when you press Shift + G. 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