Resmurf Posted June 11, 2011 Share Posted June 11, 2011 (edited) gffghfgh Edited June 11, 2011 by Guest Link to comment
JR10 Posted June 11, 2011 Share Posted June 11, 2011 do you want to color it as the players team? local r,g,b = getTeamColor(getPlayerTeam" class="kw2">getPlayerTeam(player)) outputChatBox(msg,r,g,b) Link to comment
Resmurf Posted June 11, 2011 Author Share Posted June 11, 2011 What should i replace in the code? Link to comment
UAEpro Posted June 11, 2011 Share Posted June 11, 2011 this is the code chat_range=100 addEventHandler("onPlayerJoin",getRootElement(), function () bindKey(source,"u","down","chatbox","u") end) addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), function () for index, player in pairs(getElementsByType("player")) do bindKey(player,"u","down","chatbox","u") 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("[Local Chat]"..nick..": #ffffff"..msg,v,r,g,b,true) end end end addCommandHandler("u",onChat) Link to comment
JR10 Posted June 11, 2011 Share Posted June 11, 2011 1- dont replace it with the whole code -.- addEventHandler("onPlayerJoin",getRootElement(), function () bindKey(source,"u","down","chatbox","u") end) addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), function () for index, player in pairs(getElementsByType("player")) do bindKey(player,"u","down","chatbox","u") 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" class="kw2">getPlayerTeam(player)) for _,v in ipairs(getElementsByType("player")) do if isPlayerInRangeOfPoint(v,px,py,pz,chat_range) then local r,g,b = getTeamColor(getPlayerTeam" class="kw2">getPlayerTeam--[[]](player)) outputChatBox("[Local Chat]"..nick..": #ffffff"..msg,v,r,g,b,true) end end end addCommandHandler("u",onChat) Link to comment
karlis Posted June 12, 2011 Share Posted June 12, 2011 whats the point of calling the rgb out of loop too? and you forgot to define chat_range P.S. - i dont use lua tags cuz the broken getPlayerTeam() lcoal chat_range=100 addEventHandler("onPlayerJoin",getRootElement(), function () bindKey(source,"u","down","chatbox","U") end) addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), function () for index, player in pairs(getElementsByType("player")) do bindKey(player,"u","down","chatbox","u") 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) for _,v in ipairs(getElementsByType("player")) do if isPlayerInRangeOfPoint(v,px,py,pz,chat_range) then local r,g,b = getTeamColor(getPlayerTeam(player)) or getPlayerNametagColor(player) outputChatBox("[Local Chat]".. rgbToHex(r,g,b)..nick..": #ffffff"..msg,v,0,180,0,true) end end end addCommandHandler("U",onChat) function rgbToHex ( nR, nG, nB ) local sColor = "#" nR = string.format ( "%X", nR ) sColor = sColor .. ( ( string.len ( nR ) == 1 ) and ( "0" .. nR ) or nR ) nG = string.format ( "%X", nG ) sColor = sColor .. ( ( string.len ( nG ) == 1 ) and ( "0" .. nG ) or nG ) nB = string.format ( "%X", nB ) sColor = sColor .. ( ( string.len ( nB ) == 1 ) and ( "0" .. nB ) or nB ) return sColor 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