Team chat prob..
#1

I did this.. but team chat doesn't work at all, im in team but it says that im not in team.. could someone help me? E_E
Код:
public OnPlayerText(playerid, text[])
{

    if(text[0] == '!')
    {
    if(GetPlayerTeam(playerid) == 255)
    {
    SendClientMessage(playerid, TEST_COLOUR, "You have to be in a clan to use clan chat");
    }
    else
    {
    new string[256];
    GetPlayerName(playerid, string, sizeof(string));
    format(string, sizeof(string), "[Clan chat]: %s: %s", string, text[1]);
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
    if(IsPlayerConnected(i) && gTeam[i] == gTeam[playerid]) SendClientMessage(i, GetPlayerColor(playerid), string);
    }
    }
    return 0;
    }

    return 1;
}
Reply
#2

Hi,
pawn Код:
if(text[0] == '!')
    {
        new name[24], string[256];
        GetPlayerName(playerid, name, 24);
        format(string, sizeof(string), "[Team Chat]%s: %s", name, text[1]);
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                if(team[i] == team[playerid])
                SendClientMessage(i, GetPlayerColor(playerid), string);
            }
        }
        return 0;
    }
Customize it how you want

And I think that the problem is in the "string" .. You use the string name and string to text ..
Reply
#3

Oh.. kkai, thanks.. but how can I make that if player's team = NO_TEAM that he recives a sendclientmessage with an error..?
Reply
#4

pawn Код:
if(GetPlayerTeam(playerid) == 0)
           {
                 SendClientMessage(playerid,-1,"[ ERROR ]You must choose Team !");
                 return 1;
           }
           if(text[0] == '!')
    {
        new name[24], string[256];
        GetPlayerName(playerid, name, 24);
        format(string, sizeof(string), "[Team Chat]%s: %s", name, text[1]);
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                if(team[i] == team[playerid])
                SendClientMessage(i, GetPlayerColor(playerid), string);
            }
        }
        return 0;
    }
and.. You must change OnPlayerText return 1 to return 0 !!
Reply
#5

Kkaaaaai, thank ya very much..
Reply
#6

I think xD
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)