Baseplate Posted September 24, 2012 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
Mossy Posted September 24, 2012 Posted September 24, 2012 (edited) getZoneName ? Edited September 24, 2012 by Guest
Anderl Posted September 24, 2012 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 "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
Jaysds1 Posted September 24, 2012 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) My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
Baseplate Posted September 25, 2012 Author 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
robhol Posted September 25, 2012 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. Do NOT PM ME for help unless invited. - New MTA Script Editor Scripting help "etiquette": understandable language, relevant code (ALL code if unsure), [Lua] tags, error messages with line numbers. Super simple stuff.
Baseplate Posted September 25, 2012 Author 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
Baseplate Posted September 25, 2012 Author 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)
Anderl Posted September 25, 2012 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 ) ? "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
Anderl Posted September 27, 2012 Posted September 27, 2012 I don't see any problem in my code, you must be doing anything wrong. Post the meta.xml. "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
TAPL Posted September 27, 2012 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)
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