André Henrique Posted September 18, 2019 Share Posted September 18, 2019 Greetings everyone, could you help me with my script? I am creating a local chat script and I am having doubts about the functions, I am creating the chat on the "T" key using the command «Say» but every time I type some command example: /kill it automatically sends to the server instead of execute it. local antiAbuse = {}; local localChatInterval = get("*localChatInterval"); local localChatCommand = get("*localChatCommand"); local localChatKey = get("*localChatKey"); local distanceChat = get("distanceChat"); function string:removeHexCode() local s = self:gsub("#%x%x%x%x%x%x", ""); if #s < 1 then return self; end return s; end local function localChat(responsiblePlayer, _, ...) local username = getPlayerName(responsiblePlayer) local accountid = getAccountID(getPlayerAccount(responsiblePlayer)) if not responsiblePlayer.account.guest then if isPlayerMuted(responsiblePlayer) ~= false then return outputChatBox("#ff4c44ALERTA#f5f5f5: #ff4c44Você está mutado(a), portanto não poderá mandar mensagens..", responsiblePlayer, 255, 170, 0, true); end; if antiAbuse[responsiblePlayer] ~= nil and getTickCount() - antiAbuse[responsiblePlayer] <= localChatInterval then antiAbuse[responsiblePlayer] = getTickCount(); outputChatBox("#ff4c44ALERTA#f5f5f5: #ff4c44Calma "..username..".. Aguarde para poder mandar outra mensagem!", responsiblePlayer, 255, 170, 0, true); else antiAbuse[responsiblePlayer] = getTickCount(); local localMessage = table.concat({...}, " "):removeHexCode(); outputDebugString(("ᴄʜᴀᴛ ʟᴏᴄᴀʟ - %s("..accountid.."): %s"):format(responsiblePlayer.name:removeHexCode(), localMessage), 3, 255, 170, 0, true); local localPlayers = getElementsWithinRange(responsiblePlayer.position, distanceChat, "player"); local i = 0; repeat i = i + 1; outputChatBox(("#f5f5f5* #ffff89ᴄʜᴀᴛ ʟᴏᴄᴀʟ - #f5f5f5%s("..accountid.."): #ffff89%s"):format(responsiblePlayer.name:removeHexCode(), localMessage), localPlayers[i], 255, 255, 255, true); until i == #localPlayers; end else outputChatBox("#ff4c44ALERTA#f5f5f5: #ff4c44Você precisa entrar em sua conta para poder conversar!", responsiblePlayer, 255, 170, 0, true); end end local function onPlayerJoin() bindKey(source, localChatKey, "down", "chatbox", localChatCommand); end local function onPlayerQuit() antiAbuse[source] = nil; end local function onPlayerMuted() antiAbuse[source] = nil; end local function onResourceStart() addCommandHandler(localChatCommand, localChat); local allPlayers = getElementsByType("player"); for i = 1, #allPlayers do bindKey(allPlayers[i], localChatKey, "down", "chatbox", localChatCommand); end addEventHandler("onPlayerJoin", getRootElement(), onPlayerJoin); addEventHandler("onPlayerQuit", getRootElement(), onPlayerQuit); addEventHandler("onPlayerMuted", getRootElement(), onPlayerMuted); end addEventHandler("onResourceStart", resourceRoot, onResourceStart); Link to comment
Furzy Posted September 18, 2019 Share Posted September 18, 2019 Do you want block commands on T ? 1 Link to comment
André Henrique Posted September 18, 2019 Author Share Posted September 18, 2019 when I type a command in T example: / kill it instead of executing the command it simply sends it to the server as a message, I want help fixing it. Link to comment
Furzy Posted September 18, 2019 Share Posted September 18, 2019 (edited) try local command = string.sub(localMessage, 2, string.len(localMessage)) local arguments = table.concat(localMessage, " ") executeCommandHandler( command, thePlayer, arguments ) you can check this too Edited September 18, 2019 by Furzy Link to comment
André Henrique Posted September 18, 2019 Author Share Posted September 18, 2019 @Furzy Thanks men 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