team chat
#1

public OnPlayerText(playerid, text[])
{
if(PlayerIsMuted[playerid] == 1)
{
SendClientMessage(playerid, COLOR_BRIGHTRED, "You are muted and cannot talk.");
return false;
}

if(text[0] == '@')
{
new string[256], pName[24];
if(PlayerInfo[playerid][AdminLevel] < 1)
{
GetPlayerName(playerid,pName,sizeof(pName));
format(string, sizeof(string), "Admin Chat - %s: %s", pName, text[1]);
SendModMsg(COLOR_YELLOW, string);
}
return 0;
}
if(text[0] == '!')
{
new string[128];
GetPlayerName(playerid, string, sizeof(string));
format(string, sizeof(string), "[Team] %s: %s", string, text[1]);
printf("%s", string);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && gTeam[i] == gTeam[playerid]) SendClientMessage(i, GetPlayerColor(playerid), string);
}
return 0;
}
return 1;
}


Why I can see other team text?
Reply
#2

pawn Код:
if(IsPlayerConnected(i) && gTeam[i] == gTeam[playerid]) SendClientMessage(i, GetPlayerColor(playerid), string);
Reply
#3

Try and use pawn tags next time please

pawn Код:
public OnPlayerText(playerid, text[])
{
    new pName[MAX_PLAYER_NAME], string[128];
    GetPlayerName(playerid, pName, sizeof(pName));
   
    if(PlayerIsMuted[playerid] == 1)
    {
        SendClientMessage(playerid, COLOR_BRIGHTRED, "You are muted and cannot talk.");
        return 0;
    }

    if(text[0] == '@')
    {
        if(PlayerInfo[playerid][AdminLevel] >= 1)
        {
        format(string, sizeof(string), "Admin Chat - %s: %s", pName, text[1]);
        SendModMsg(COLOR_YELLOW, string);
        return 1;
        }
        return 0;
  }
  if(text[0] == '!')
    {
    format(string, sizeof(string), "[Team] %s: %s", pName, text[1]);
    printf("%s", string);
    for(new i=0,b=GetMaxPlayers();i<b;i++)
    {
            if(gTeam[i] == gTeam[playerid]) SendClientMessage(i, GetPlayerColor(playerid), string);
        }
        return 1;
    }
    return 1;
}
It SHOULD work, not tested

I also cleaned up your code.
Instead of two times making a varible, I made it only once, I also shortened the array 'string' to 128 cells instead of 256 (Not needed!!)
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)