Jump to content

Question


Baseplate

Recommended Posts

Posted
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

Posted
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/

 

sE5Qm.png

TiV3C.png

img.php?id=0&text=Lua%20Scripter

Posted

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.

Posted
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

Posted
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) 

:S

Posted
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) 

:S

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

Posted

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

Posted
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) 

CiTLh.png

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...