TavinhoMTA Posted March 30, 2019 Share Posted March 30, 2019 chat_range=100 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[Local Chat] #ffffff"..nick..": #00ff00"..msg,v,r,g,b,true) end end end addCommandHandler("LocalChat",onChat) Alguem ajudar quero este chat local no t mais o comando / não funciona aparecer no chat Olha ai: https://prnt.sc/n51lzs Link to comment
Jonas^ Posted March 30, 2019 Share Posted March 30, 2019 (edited) Deveria olhar mais a wiki. Aqui: chat_range = 100 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 _, v in ipairs (everybody) do if isPlayerInRangeOfPoint (v, px, py, pz, chat_range) then outputChatBox ("#00FF00[Local Chat] #FFFFFF"..getPlayerName(source)..": #00FF00"..msg, v, r, g, b, true) end end end end ) Edited March 30, 2019 by Jonas^ 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