Carmelo12 Posted July 11, 2018 Share Posted July 11, 2018 How can I make this resource like the globalchat? I mean that by touching a key I can open the chat and send the text, so I do not have to type a command / u [text] function ADMINCHAT ( thePlayer, cmd, ... ) local accountname = getAccountName(getPlayerAccount(thePlayer)) if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Admin" )) then message = table.concat({...}," ") outputChatBox ("#5594FF[CHAT]-#FE5757"..getPlayerName(thePlayer)..": #FFFFFF"..message.."",getRootElement(thePlayer),255,255,255, true) end end addCommandHandler ( "u", ADMINCHAT ) Link to comment
Storm-Hanma Posted July 12, 2018 Share Posted July 12, 2018 did you tested the code got any erros ? Link to comment
Dimos7 Posted July 12, 2018 Share Posted July 12, 2018 (edited) addEventHandler("onResourceStart", resourceRoot, function() for _, v in ipairs(getElementsByType("player")) do bindKey(v, "down" , ADMINCHAT) end end) addEventHandler("onPlayerJoin", root, function () bindKey(source, "down", ADMINCHAT) end) Edited July 12, 2018 by Dimos7 Link to comment
Overkillz Posted July 12, 2018 Share Posted July 12, 2018 5 hours ago, Dimos7 said: addEventHandler("onResourceStart", resourceRoot, function() for _, v in ipairs(getElementsByType("player")) do bindKey(v, "down" , ADMINCHAT) end end) addEventHandler("onPlayerJoin", root, function () bindKey(source, "down", ADMINCHAT) end) And the key ? bindKey ( player thePlayer, string key, string keyState, function handlerFunction, [ var arguments, ... ] ) Link to comment
Dimos7 Posted July 12, 2018 Share Posted July 12, 2018 addEventHandler("onResourceStart", resourceRoot, function() for _, v in ipairs(getElementsByType("player")) do bindKey(v, "j" , "down" , ADMINCHAT) -- change j with key you want end end) addEventHandler("onPlayerJoin", root, function () bindKey(source,"j" , "down", ADMINCHAT) -- change j with key you want end) 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