Team Chat Not Working..
#1

Hey all, ive tried searching SO many Times
and found a Team chat, but it doesnt work :/
im using gTeam btw and Everytime i do ! It shows People From other Teams Chat as well

Example:

[Grove] ! Hi
[Balla] ! Hello

So They Both Can hear the Chat, here is Code

pawn Код:
{
    if(text[0] == '!')
    {
  new name[24], string[256];
  GetPlayerName(playerid, name, 24);
  format(string, sizeof(string), "[Team Chat]%s: %s", name, text[1]);
    printf("%s", string);

  for(new i = 0; i < MAX_PLAYERS; i++)
    {
    if(IsPlayerConnected(i))
    {
    if(gTeam[i] == gTeam[playerid])
    SendClientMessage(i, GetPlayerColor(playerid), string);
        }
    }
    return 0;
}
    return 1;
}
Thanks in Advance
Reply
#2

That code should work fine.
Maybe you haven't set the players teams correctly, and they are all on the same team?
Reply
#3

Quote:
Originally Posted by mansonh
That code should work fine.
Maybe you haven't set the players teams correctly, and they are all on the same team?
Well ive Defined There Team

#define TEAM_GROVE 0
#define TEAM_BALLAS 1

:/ D:
Reply
#4

I mean maybe your not setting the players teams correctly.

Because from your code, you return 0 if its team chat, and you have the == check.

Wait, maybe the text[0]== '!' isn't right.
You may need to use strcmp,

Try this test to see if if(text[0] == '!') is correct.

pawn Код:
{
    if(text[0] == '!')
    {
  SendClientMessage(playerid, 0xAA0000AA, "You are sending a team message");
  new name[24], string[256];
  GetPlayerName(playerid, name, 24);
  format(string, sizeof(string), "[Team Chat]%s: %s", name, text[1]);
    printf("%s", string);

  for(new i = 0; i < MAX_PLAYERS; i++)
    {
    if(IsPlayerConnected(i))
    {
    if(gTeam[i] == gTeam[playerid])
    SendClientMessage(i, GetPlayerColor(playerid), string);
        }
    }
    return 0;
}
    return 1;
}
Reply
#5

Quote:
Originally Posted by mansonh
I mean maybe your not setting the players teams correctly.

Because from your code, you return 0 if its team chat, and you have the == check.

Wait, maybe the text[0]== '!' isn't right.
You may need to use strcmp,

Try this test to see if if(text[0] == '!') is correct.

pawn Код:
{
    if(text[0] == '!')
    {
  SendClientMessage(playerid, 0xAA0000AA, "You are sending a team message");
  new name[24], string[256];
  GetPlayerName(playerid, name, 24);
  format(string, sizeof(string), "[Team Chat]%s: %s", name, text[1]);
    printf("%s", string);

  for(new i = 0; i < MAX_PLAYERS; i++)
    {
    if(IsPlayerConnected(i))
    {
    if(gTeam[i] == gTeam[playerid])
    SendClientMessage(i, GetPlayerColor(playerid), string);
        }
    }
    return 0;
}
    return 1;
}
Alright ill give it a try when i get people on my server :P and ill let you know if it works

EDIT - I Tried It With a Friend,
And I was on balla and he was on grove and he could hear what i was saying through !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)