Team chat problem
#1

Hi! i got littler problem with my team chat command


Код:
dcmd_t(playerid, cmdtext[])
{
	 	new idx;
		while(cmdtext[idx] == 32) idx++;

		if(cmdtext[idx] == EOS)
	 	return SendClientMessage(playerid,COLOR_GOLD,"USAGE: /t [text]");

 		new string[128];
		new team = GetPlayerTeam(playerid);
		new color = GetPlayerColor(playerid);
		GetPlayerName(playerid,string,MAX_PLAYER_NAME);
		format(string,128,"[Team]%s: %s",string,cmdtext[idx]);
 		SendClientMessage(team,color,string);
 		return 1;
}
The problem is that this just dont work and i dont know what can be wrong.
Reply
#2

You can't use this line

pawn Код:
SendClientMessage(team,color,string);
to send team message.

pawn Код:
dcmd_t(playerid, cmdtext[])
{
        new idx;
        while(cmdtext[idx] == 32) idx++;

        if(cmdtext[idx] == EOS)
        return SendClientMessage(playerid,COLOR_GOLD,"USAGE: /t [text]");

        new string[128];
        new team = GetPlayerTeam(playerid);
        new color = GetPlayerColor(playerid);
        GetPlayerName(playerid,string,MAX_PLAYER_NAME);
        format(string,128,"[Team]%s: %s",string,cmdtext[idx]);

        for(new i=0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i) && GetPlayerTeam(i) == team)
            {
                SendClientMessage(i,color,string);
            }
        }
        return 1;
}
Reply
#3

Quote:
Originally Posted by MadeMan
You can't use this line

pawn Код:
SendClientMessage(team,color,string);
to send team message.

pawn Код:
dcmd_t(playerid, cmdtext[])
{
        new idx;
        while(cmdtext[idx] == 32) idx++;

        if(cmdtext[idx] == EOS)
        return SendClientMessage(playerid,COLOR_GOLD,"USAGE: /t [text]");

        new string[128];
        new team = GetPlayerTeam(playerid);
        new color = GetPlayerColor(playerid);
        GetPlayerName(playerid,string,MAX_PLAYER_NAME);
        format(string,128,"[Team]%s: %s",string,cmdtext[idx]);

        for(new i=0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i) && GetPlayerTeam(i) == team)
            {
                SendClientMessage(i,color,string);
            }
        }
        return 1;
}
It works now but it shows up for all players, not only for team members. And by the way im using gTeam.

How to make it that message will only show up for team members and not for all players.
Reply
#4

If gTeam, then

pawn Код:
dcmd_t(playerid, cmdtext[])
{
        new idx;
        while(cmdtext[idx] == 32) idx++;

        if(cmdtext[idx] == EOS)
        return SendClientMessage(playerid,COLOR_GOLD,"USAGE: /t [text]");

        new string[128];
        new color = GetPlayerColor(playerid);
        GetPlayerName(playerid,string,MAX_PLAYER_NAME);
        format(string,128,"[Team]%s: %s",string,cmdtext[idx]);

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

Quote:
Originally Posted by MadeMan
If gTeam, then

pawn Код:
dcmd_t(playerid, cmdtext[])
{
        new idx;
        while(cmdtext[idx] == 32) idx++;

        if(cmdtext[idx] == EOS)
        return SendClientMessage(playerid,COLOR_GOLD,"USAGE: /t [text]");

        new string[128];
        new color = GetPlayerColor(playerid);
        GetPlayerName(playerid,string,MAX_PLAYER_NAME);
        format(string,128,"[Team]%s: %s",string,cmdtext[idx]);

        for(new i=0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i) && gTeam[i] == gTeam[playerid])
            {
                SendClientMessage(i,color,string);
            }
        }
        return 1;
}
Works thank you :*
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)