Teamchat error

Started by KAKAN, Aug 10, 2015, 02:16 PM

Previous topic - Next topic

KAKAN

I made a cmd to use teamchat function as in 0.3, but the problem is, the team-CHAT message is getting displayed to everyone
Here is my code:-
http://pastebin.com/v9gfuRbf
oh no

DizzasTeR

First of all I don't even understand how is that a team message, you have made a command which sends a message to the id of the player given, how is that suppose to be team message? more likely its like a PM message to the person whose ID is given.

To send a proper team message you have to run a loop and check if the class is == to player.Class, if so send them message.

Thijn

This is what I use. It simulates the usage from 0.3 using the \ prefix.
The \\ is there to escape the \, otherwise the " would be escaped.
function onPlayerChat( player, message ) {
if ( message.slice(0,1) == "\\" ) {
local text = message.slice(1);
for( local i = 0; i < GetMaxPlayers(); i++ ) {
local plr = FindPlayer( i );
if ( plr && plr.Team == player.Team ) {
ClientMessage( player.Name + ": " + text, plr, 255, 0, 0 );
}
}
return 0;
}
}