Baseplate Posted September 24, 2012 Share Posted September 24, 2012 Well, I wanted to know how to add the city name behind the playername when he types something e.g: (LS)Samer:Hello Link to comment
Mossy Posted September 24, 2012 Share Posted September 24, 2012 (edited) getZoneName ? Edited September 24, 2012 by Guest Link to comment
Anderl Posted September 24, 2012 Share Posted September 24, 2012 addEventHandler('onPlayerChat', root, function(message) cancelEvent() local fX, fY, fZ = getElementPosition(source) message = string.format('(%s)%s:#ffffff %s', getZoneName(fX, fY, fZ, true), getPlayerName(source), message) outputChatBox(message, root, 255, 255, 255, true) end end Link to comment
Jaysds1 Posted September 24, 2012 Share Posted September 24, 2012 addEventHandler('onPlayerChat', root, function(message) cancelEvent() local fX, fY, fZ = getElementPosition(source) message = string.format('(%s)%s:#ffffff %s', getZoneName(fX, fY, fZ, true), getPlayerName(source), message) outputChatBox(message, root, 255, 255, 255, true) end end Wouldn't that output this: (Los Santos)Jaysds1: Hey ??? try this: addEventHandler("onPlayerChat",root,function(msg) cancelEvent() local x,y,z = getElementPosition(localPlayer) local zone = getZoneName(x,y,z,true) local curZone if zone=="Los Santos" then curZone = "LS" elseif zone == "Las Venturas" then curZone = "LV" elseif zone == "San Fierro" then curZone = "SF" else curZone = zone end outputChatBox("("..curZone..")"..getPlayerName(source)..":"..msg) end) Link to comment
Baseplate Posted September 25, 2012 Author Share Posted September 25, 2012 (edited) You forgot to get the player jay now it dosen't get my team color in the chat, how to? Edited September 25, 2012 by Guest Link to comment
robhol Posted September 25, 2012 Share Posted September 25, 2012 You know, you could try thinking about this yourself too. The function name "getTeamColor" is pretty obvious. As for the city names, it's probably easiest to just make a dictionary with "Los Santos"=>"LS" etc. Link to comment
Baseplate Posted September 25, 2012 Author Share Posted September 25, 2012 You know, you could try thinking about this yourself too. The function name "getTeamColor" is pretty obvious.As for the city names, it's probably easiest to just make a dictionary with "Los Santos"=>"LS" etc. I've fixed the script anyways..i'll see about this now Link to comment
Baseplate Posted September 25, 2012 Author Share Posted September 25, 2012 addEventHandler("onPlayerChat",root, function(msg) cancelEvent() local playerTeam = getPlayerTeam( source ) local r, g, b = getTeamColor( playerTeam ) localPlayer = getPlayerFromName ( msg ) local x,y,z = getElementPosition ( source ) local zone = getZoneName(x,y,z,true) local curZone if zone=="Los Santos" then curZone = "LS" elseif zone == "Las Venturas" then curZone = "LV" elseif zone == "San Fierro" then curZone = "SF" else curZone = zone end outputChatBox("("..curZone..")"..getPlayerName(source)..":"..msg) end) Link to comment
Anderl Posted September 25, 2012 Share Posted September 25, 2012 addEventHandler("onPlayerChat",root, function(msg) cancelEvent() local playerTeam = getPlayerTeam( source ) local r, g, b = getTeamColor( playerTeam ) localPlayer = getPlayerFromName ( msg ) local x,y,z = getElementPosition ( source ) local zone = getZoneName(x,y,z,true) local curZone if zone=="Los Santos" then curZone = "LS" elseif zone == "Las Venturas" then curZone = "LV" elseif zone == "San Fierro" then curZone = "SF" else curZone = zone end outputChatBox("("..curZone..")"..getPlayerName(source)..":"..msg) end) local zoneNames = {['Los Santos'] = 'LS', ['San Fierro'] = 'SF', ['Las Venturas'] = 'LV'} addEventHandler('onPlayerChat', root, function(message) cancelEvent() local fX, fY, fZ = getElementPosition(source) message = string.format('(%s)%s:#ffffff%s', zoneNames[getZoneName(fX, fY, fZ, true)], getPlayerNametagText(source), message) outputChatBox(message, root, 255, 255, 255, true) end ) ? Link to comment
Baseplate Posted September 25, 2012 Author Share Posted September 25, 2012 Dosen't work Link to comment
Anderl Posted September 27, 2012 Share Posted September 27, 2012 I don't see any problem in my code, you must be doing anything wrong. Post the meta.xml. Link to comment
TAPL Posted September 27, 2012 Share Posted September 27, 2012 addEventHandler('onPlayerChat', root, function(message,type) if type == 0 then cancelEvent() local fX, fY, fZ = getElementPosition(source) local r, g, b = getTeamColor(getPlayerTeam(source)) message = string.format('#%02X%02X%02X(%s)%s:#ffffff%s', r or 255, g or 255, b or 255, zoneNames[getZoneName(fX, fY, fZ, true)], getPlayerName(source), message) outputChatBox(message, root, 255, 255, 255, true) end 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