Author Topic: redirecting chat  (Read 595 times)

I'm making a new game for my server called mafia. Some of the features of my game that I would like to include are the dead being unable to talk to living people, only mafia can see mafia chat at night, only law enforcement can see law enforcement chat at night, and so forth. I know how to stop a message from being sent to the server, but I don't know how to make it so only certain people can see a message. Any help would be great =).
« Last Edit: May 22, 2011, 09:08:06 PM by Gartanium »

That's more simple than you think.

Code: [Select]
package myTeamChattyThing
{
function serverCmdMessageSent(%client, %text)
{
if($isNight)
{
parent::serverCmdMessageSent(%client, %text);
}
else
{
switch$(%client.currentTeam)
{
case "Mafia":
for(%i = 0; %i < clientGroup.getCount(); %i++)
{
if(clientGroup.getObject(%i).currentTeam $= "Mafia")
messageClient(clientGroup.getObject(%i),'',"\c3"@%client.getPlayerName()@" (MAFIA)\c6: "@%text);
}
case "Law":
for(%i = 0; %i < clientGroup.getCount(); %i++)
{
if(clientGroup.getObject(%i).currentTeam $= "Law")
messageClient(clientGroup.getObject(%i),'',"\c3"@%client.getPlayerName()@" (LAW)\c6: "@%text);
}
}
}
}
};
activatePackage(myTeamChattyThing);

Adapt to your code.


Just don't release that, it'll break a lot of stuff because it redirects chat to a server message.

Please do not use untagged messageClient() functions.

Please do use commandToClient(%cl = clientGroup.getObject(%i),'chatmessage','\c3%2 (MAFIA)\c5: %4',%cl.clanprefix,%cl.getPlayerName(),%cl.clanSuffix,%text);

Thank you for having regards to client add-ons that don't want to break due to faulty chat modifying server add-ons.

Thank you for having regards to client add-ons that don't want to break due to faulty chat modifying server add-ons.
Uh, what.

Uh, what.
Both of my add-ons relating to chat (client sided) happen to break when servers run add-ons that don't send messages properly.

For example, special kills in TDM will still show up in the normal chat, rather than being in the split death chat.
The chat sound will not play when people talk while dead in a TDM match.
In certain zombie mods, some blank lines show up in the death messages, some show up normally in the death messages, and some show up in the chat.

This is because they're using untagged messageClient/messageAll functions.

Thanks for saying that, Chrono.

I had no clue.