Here is the command.
You need to type -hear to activate or deactivate it for yourself.
It won't show you your own messages.
With the player color and name
[spoiler]
Code:
globals
trigger trgStringCommands=CreateTrigger()
boolean array peopleThatCanHear
endglobals
function getPlayerColorCode takes integer pid returns string
if pid==0 then
return "|cffff0000"
elseif pid==1 then
return "|cff0000ff"
elseif pid==2 then
return "|cff00ffff"
elseif pid==3 then
return "|cff550088"
elseif pid==4 then
return "|cffffff00"
elseif pid==5 then
return "|cffff8800"
elseif pid==6 then
return "|cff00ff00"
elseif pid==7 then
return "|cffee55bb"
elseif pid==8 then
return "|cff999999"
elseif pid==9 then
return "|cff77bbff"
elseif pid==10 then
return "|cff116644"
else
return "|cff552200"
endif
endfunction
function showMessageToPeopleThatCanHear takes nothing returns nothing
local string messageToShow=(getPlayerColorCode(GetPlayerId(GetTriggerPlayer())) + GetPlayerName(GetTriggerPlayer()) + ": " + GetEventPlayerChatString())
local integer index=0
loop
exitwhen index>11
if (peopleThatCanHear[index]) and index!=GetPlayerId(GetTriggerPlayer())then
call DisplayTextToPlayer(Player(index),0,0,messageToShow)
endif
set index=index+1
endloop
set messageToShow=""
endfunction
function stringCommands takes nothing returns nothing
if StringCase(GetEventPlayerChatString(),false)=="-hear"then
set peopleThatCanHear[GetPlayerId(GetTriggerPlayer())]=not(peopleThatCanHear[GetPlayerId(GetTriggerPlayer())])
endif
call showMessageToPeopleThatCanHear()
endfunction
function initStringCommands takes nothing returns nothing
local integer index=0
loop
exitwhen index>11
call TriggerRegisterPlayerChatEvent(trgStringCommands,Player(index),"",false)
set index=index+1
endloop
call TriggerAddAction(trgStringCommands,function stringCommands)
endfunction
function main takes nothing returns nothing
call initStringCommands()
endfunction