C0DE Posted April 2, 2019 Share Posted April 2, 2019 (edited) Bom eu tenho um script que baixei de chats Para RP só que o chatlocal e no U e eu queria substituir ele e colocar no t so que quando eu vou mandar um comando exemplo /admin ele não vai ele simplesmente aparece no chat /admin print abaixo bom também percebi que quando vai no F8 e digita say "mensagem" fala no chat normal - Print1 -- Print2 - chat_range=70 addEventHandler("onPlayerJoin",getRootElement(), function () bindKey(source,"t","down","chatbox","LocalChat") end) addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), function () for index, player in pairs(getElementsByType("player")) do bindKey(player,"t","down","chatbox","LocalChat") end end) function isPlayerInRangeOfPoint(player,x,y,z,range) local px,py,pz=getElementPosition(player) return ((x-px)^2+(y-py)^2+(z-pz)^2)^0.5<=range end function onChat(player,_,...) local px,py,pz=getElementPosition(player) local msg = table.concat({...}, " ") local nick=getPlayerName(player) local r,g,b = getTeamColor(getPlayerTeam(player)) for _,v in ipairs(getElementsByType("player")) do if isPlayerInRangeOfPoint(v,px,py,pz,chat_range) then outputChatBox("᠉ #00ff00 ChatLocal - #ffffff"..nick.."#00ff00 - #ffffff"..msg,v,r,g,b,true) end end end addCommandHandler("LocalChat",onChat) function MensagemTwitter(source, cmd, ...) local MessagemT = table.concat ( { ... }, " " ) local name = getPlayerName(source); for _,v in ipairs(getElementsByType("player")) do outputChatBox("᠉ #00BFFFTwitter - #ffffff"..name.."#00BFFF - #FFFFFF"..MessagemT,v, 255, 255, 255, true) end end addCommandHandler("twitter", MensagemTwitter) function Mensagemfrp(source, cmd, ...) local Messagemr = table.concat ( { ... }, " " ) local name = getPlayerName(source); for _,v in ipairs(getElementsByType("player")) do outputChatBox("᠉ #87CEFAFora do RP - /frp - #ffffff"..name.."#00BFFF - #FFFFFF"..Messagemr,v, 255, 255, 255, true) end end addCommandHandler("frp", Mensagemfrp) function Mensagemrp(source, cmd, ...) local Messagemp = table.concat ( { ... }, " " ) local name = getPlayerName(source); for _,v in ipairs(getElementsByType("player")) do outputChatBox("᠉ #1E90FFDentro RP - /rp - #ffffff"..name.."#00BFFF - #FFFFFF"..Messagemp,v, 255, 255, 255, true) end end addCommandHandler("rp", Mensagemrp) addCommandHandler( "deepweb", function ( source, cmd, ... ) local message2 = #{...} > 0 and table.concat({...}," ") or nil if message2 then for _, p in ipairs (getElementsByType("player")) do if hasObjectPermissionTo(p, "command.mute", true) then outputChatBox("᠉ #696969 DeepWeb - #ffffff"..getPlayerName(source).."#696969 - #696969"..message2, p, 255, 255, 255, true) else outputChatBox("᠉ #696969 DeepWeb - #696969"..message2, p, 255, 255, 255, true) end end else end end ) addEventHandler("onPlayerJoin", getRootElement(), function() bindKey(source, "y", "down", "chatbox", "twitter") end ) addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function() for index,player in pairs(getElementsByType("player")) do bindKey(player,"y", "down", "chatbox", "twitter") end end ) addEventHandler("onPlayerJoin", getRootElement(), function() bindKey(source, "i", "down", "chatbox", "frp") end ) addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function() for index,player in pairs(getElementsByType("player")) do bindKey(player,"i", "down", "chatbox", "frp") end end ) addEventHandler("onPlayerJoin", getRootElement(), function() bindKey(source, "o", "down", "chatbox", "rp") end ) addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function() for index,player in pairs(getElementsByType("player")) do bindKey(player,"o", "down", "chatbox", "rp") end end ) addEventHandler("onPlayerJoin", getRootElement(), function() bindKey(source, "u", "down", "chatbox", "deepweb") end ) addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), function() for index,player in pairs(getElementsByType("player")) do bindKey(player,"u", "down", "chatbox", "deepweb") end end ) Edited April 2, 2019 by C0DE Link to comment
Jonas^ Posted April 2, 2019 Share Posted April 2, 2019 (edited) Porque 350 loops pra fazer a mesma coisa? Faça assim: local chat_range = 70 function isPlayerInRangeOfPoint (player, x, y, z, range) local px, py, pz = getElementPosition (player) return ( (x-px) ^ 2 + (y-py) ^ 2+ (z-pz) ^ 2) ^ 0.5 <= range end addEventHandler ("onPlayerChat", root, function (msg, type) if type == 0 then -- < ---- cancelEvent () local px, py, pz = getElementPosition (source) local r, g, b = getPlayerNametagColor (source) local everybody = getElementsByType ("player") for k, v in ipairs (everybody) do if isPlayerInRangeOfPoint (v, px, py, pz, chat_range) then outputChatBox ("᠉ #00FF00 ChatLocal - #FFFFFF"..getPlayerName(source).."#00ff00 - #ffffff"..msg, v, r, g, b, true) end end end end ) function MensagemTwitter (source, cmd, ...) local MessagemT = table.concat ( { ... }, " " ) local everybody = getElementsByType ("player") for _, v in ipairs (everybody) do outputChatBox ("᠉ #00BFFFTwitter - #ffffff"..getPlayerName(source).."#00BFFF - #FFFFFF"..MessagemT, v, 255, 255, 255, true) end end addCommandHandler ("twitter", MensagemTwitter) function Mensagemfrp (source, cmd, ...) local Messagemr = table.concat ( { ... }, " " ) local everybody = getElementsByType ("player") for _, v in ipairs (everybody) do outputChatBox ("᠉ #87CEFAFora do RP - /frp - #ffffff"..getPlayerName(source).."#00BFFF - #FFFFFF"..Messagemr, v, 255, 255, 255, true) end end addCommandHandler ("frp", Mensagemfrp) function Mensagemrp (source, cmd, ...) local Messagemp = table.concat ( { ... }, " " ) local everybody = getElementsByType ("player") for _, v in ipairs (everybody) do outputChatBox ("᠉ #1E90FFDentro RP - /rp - #ffffff"..getPlayerName(source).."#00BFFF - #FFFFFF"..Messagemp, v, 255, 255, 255, true) end end addCommandHandler ("rp", Mensagemrp) addCommandHandler ("deepweb", function (source, cmd, ...) local message2 = #{...} > 0 and table.concat({...}," ") or nil if message2 then local everybody = getElementsByType ("player") for _, p in ipairs (everybody) do if hasObjectPermissionTo(p, "command.mute", true) then outputChatBox ("᠉ #696969 DeepWeb - #ffffff"..getPlayerName(source).."#696969 - #696969"..message2, p, 255, 255, 255, true) else outputChatBox ("᠉ #696969 DeepWeb - #696969"..message2, p, 255, 255, 255, true) end end end end ) addEventHandler ("onPlayerJoin", getRootElement(), function () bindKey (source, "y", "down", "chatbox", "twitter") bindKey (source, "i", "down", "chatbox", "frp") bindKey (source, "o", "down", "chatbox", "rp") bindKey (source, "u", "down", "chatbox", "deepweb") end ) addEventHandler ("onResourceStart", resourceRoot, function () local everybody = getElementsByType ("player") for index, player in pairs (everybody) do bindKey (player, "y", "down", "chatbox", "twitter") bindKey (player, "i", "down", "chatbox", "frp") bindKey (player, "o", "down", "chatbox", "rp") bindKey (player, "u", "down", "chatbox", "deepweb") end end ) OBS: Não aconselho usar 4 binds assim, as vezes o jogador aperta uma tecla do teclado sem querer e abre o chat, ainda mais com 4 chats diferente assim, aconselho tirar e deixar somente pelo chat local "T" Edited April 2, 2019 by Jonas^ Correção de Indentação. 1 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