Tete omar Posted May 15, 2012 Share Posted May 15, 2012 (edited) Why localchat like that ? And if i put a color like # 00ff00 say something nothing happens Any color script ? chat_range=100 addEventHandler("onPlayerJoin",getRootElement(), function () bindKey(source,"u","down","chatbox","LocalChat") end) addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), function () for index, player in pairs(getElementsByType("player")) do bindKey(player,"u","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("(LocalChat)"..nick..": #ffffff"..msg,v,r,g,b,true) end end end addCommandHandler("LocalChat",onChat) Edited May 15, 2012 by Guest Link to comment
Tete omar Posted May 15, 2012 Author Share Posted May 15, 2012 can you post the script? chat_range=100 addEventHandler("onPlayerJoin",getRootElement(), function () bindKey(source,"u","down","chatbox","LocalChat") end) addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), function () for index, player in pairs(getElementsByType("player")) do bindKey(player,"u","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("(LocalChat)"..nick..": #ffffff"..msg,v,r,g,b,true) end end end addCommandHandler("LocalChat",onChat) Link to comment
Guest Guest4401 Posted May 15, 2012 Share Posted May 15, 2012 Line 25, If player isn't in any team then r,g,b will be nil. If it's nil, it won't show colors. Link to comment
ben_wright Posted May 15, 2012 Share Posted May 15, 2012 hex code should work, no matter if you're in a team or not Link to comment
Tete omar Posted May 15, 2012 Author Share Posted May 15, 2012 hex code should work, no matter if you're in a team or not But why the color codes doesn't work ? Link to comment
Guest Guest4401 Posted May 15, 2012 Share Posted May 15, 2012 Line 25,If player isn't in any team then r,g,b will be nil. If it's nil, it won't show colors. hex code should work, no matter if you're in a team or not Can you please explain me? Doesn't work: outputChatBox("(LocalChat)"..nick..": #ffffff"..msg,v,r,g,b,true) Doesn't work: outputChatBox("(LocalChat)"..nick..": #ffffff"..msg,v,nil,nil,nil,true) Works: outputChatBox("(LocalChat)"..nick..": #ffffff"..msg,v,255,0,0,true) Link to comment
ben_wright Posted May 15, 2012 Share Posted May 15, 2012 hex code overlaps r g b, im guessing something interferes with it. most likely default mta resource Link to comment
Tete omar Posted May 15, 2012 Author Share Posted May 15, 2012 outputChatBox("(LocalChat)"..nick..": #ffffff"..msg,v,255,0,0,true) Thanks !!! it's working " can i get your e-mail please ? " Link to comment
Guest Guest4401 Posted May 15, 2012 Share Posted May 15, 2012 hex code overlaps r g b, im guessing something interferes with it. most likely default mta resource local r,g,b = getTeamColor(getPlayerTeam(player)) outputChatBox(type(r).." "..type(g).." "..type(b)) Result : boolean nil nil Line 25,If player isn't in any team then r,g,b will be nil. If it's nil, it won't show colors. Link to comment
Tete omar Posted May 15, 2012 Author Share Posted May 15, 2012 hex code overlaps r g b, im guessing something interferes with it. most likely default mta resource local r,g,b = getTeamColor(getPlayerTeam(player)) outputChatBox(type(r).." "..type(g).." "..type(b)) Result : boolean nil nil Line 25,If player isn't in any team then r,g,b will be nil. If it's nil, it won't show colors. But i got a little problem .. :\ Why when i type a code like # 00ff00 or different also doesn't run ? Link to comment
Kenix Posted May 15, 2012 Share Posted May 15, 2012 (edited) local nChatRange = 100 local function isPlayerInRangeOfPoint( pPlayer, fX, fY, fZ, nRange ) local fPx, fPy, fPz = getElementPosition( pPlayer ) return ( ( fX - fPx ) ^ 2 + ( fY - fPy ) ^ 2 + ( fZ - fPz ) ^ 2 ) ^ 0.5 <= nRange end local function onChat( pPlayer, _, ... ) local fPx, fPy, fPz = getElementPosition( pPlayer ) local sMsg = table.concat( { ... }, ' ' ) local sNick = getPlayerName( pPlayer ) local nR, nG, nB = 255, 255, 255 local pTeam = getPlayerTeam( pPlayer ) if pTeam and isElement( pTeam ) then nR, nG, nB = getTeamColor( pTeam ) end for _, pPlayer in ipairs( getElementsByType 'player' ) do if isPlayerInRangeOfPoint( pPlayer, fPx, fPy, fPz, nChatRange ) then outputChatBox( '(LocalChat)' .. sNick .. ': #ffffff' .. sMsg, pPlayer, nR, nG, nB, true ) end end end local function LocalChatBindManager( ) if eventName == 'onPlayerJoin' then bindKey( source, 'u', 'down', 'chatbox', 'LocalChat' ) else for _, pPlayer in ipairs( getElementsByType 'player' ) do bindKey( pPlayer, 'u', 'down', 'chatbox', 'LocalChat' ) end end end addEventHandler( 'onPlayerJoin', root, LocalChatBindManager ) addEventHandler( 'onResourceStart', resourceRoot, LocalChatBindManager ) addCommandHandler( 'LocalChat', onChat ) Edited May 15, 2012 by Guest Link to comment
ben_wright Posted May 15, 2012 Share Posted May 15, 2012 even though it's nil, hexcode should/will overlap it. outputChatBox("(LocalChat)"..nick..": #ffffff"..msg,v,r,g,b,true) color before message returns nil outputs: (localChat)ben_wright: message Link to comment
Guest Guest4401 Posted May 15, 2012 Share Posted May 15, 2012 even though it's nil, hexcode should/will overlap it. outputChatBox("(LocalChat)"..nick..": #ffffff"..msg,v,r,g,b,true) color before message returns nil outputs: (localChat)ben_wright: message No, if r and g and b is nil it won't. Test it yourself. EDIT : There, http://i.imgur.com/SUHuE.png Link to comment
Tete omar Posted May 15, 2012 Author Share Posted May 15, 2012 local nChatRange = 100 local function isPlayerInRangeOfPoint( pPlayer, fX, fY, fZ, fRange ) local fPx, fPy, fPz = getElementPosition( pPlayer ) return ( ( fX - fPx ) ^ 2 + ( fY - fPy ) ^ 2 + ( fZ - fPz ) ^ 2 ) ^ 0.5 <= fRange end local function onChat( pPlayer, _, ... ) local fPx, fPy, fPz = getElementPosition( pPlayer ) local sMsg = table.concat( { ... }, ' ' ) local sNick = getPlayerName( pPlayer ) local nR, nG, nB = 255, 255, 255 local pTeam = getPlayerTeam( pPlayer ) if pTeam and isElement( pTeam ) then nR, nG, nB = getTeamColor( pTeam ) end for _, pPlayer in ipairs( getElementsByType 'player' ) do if isPlayerInRangeOfPoint( pPlayer, fPx, fPy, fPz, nChatRange ) then outputChatBox( '(LocalChat)' .. sNick .. ': #ffffff' .. sMsg, pPlayer, nR, nG, nB, true ) end end end local function LocalChatBindManager( ) if eventName == 'onPlayerJoin' then bindKey( source, 'u', 'down', 'chatbox', 'LocalChat' ) else for _, pPlayer in ipairs( getElementsByType 'player' ) do bindKey( pPlayer, 'u', 'down', 'chatbox', 'LocalChat' ) end end end addEventHandler( 'onPlayerJoin', root, LocalChatBindManager ) addEventHandler( 'onResourceStart', resourceRoot, LocalChatBindManager ) addCommandHandler( 'LocalChat', onChat ) Kenix how can i make the Local chat color different than player color and the chat color is white 3 colors Local chat color and the player color and the chat color 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