Page 1 of 1

[Jass] Eavesdrop

Posted: November 15th, 2012, 4:34 pm
by Apple
Can you make a -hear command like how it is in the jjcp but to be functioning independantly?
A short and sweet one please :D

Re: make a command

Posted: November 15th, 2012, 6:32 pm
by Bartimaeus
What's the difference between us copying pasting what JJ's CP did and you looking at it yourself?

Re: make a command

Posted: November 15th, 2012, 8:15 pm
by Apple
Bartimaeus wrote:What's the difference between us copying pasting what JJ's CP did and you looking at it yourself?

because I can't copy it and make it work somehow :(

Re: make a command

Posted: November 19th, 2012, 11:28 am
by haxorico
You are asking for help for (or actually asking us to do it for you) trigger.
Make a topic at the triggering section explaining what you want. For ex: A command that will show me what every one is writing...

Re: make a command

Posted: November 19th, 2012, 11:29 am
by Apple
haxorico wrote:You are asking for help for (or actually asking us to do it for you) trigger.
Make a topic at the triggering section explaining what you want. For ex: A command that will show me what every one is writing...

okay :)

Re: make a command

Posted: November 19th, 2012, 2:27 pm
by haxorico
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: Select all

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

Re: make a command

Posted: November 19th, 2012, 3:27 pm
by Apple
Spoiler:
haxorico wrote: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: Select all

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

Thanks I'll test it now, nicely worked.