SA-MP Forums Archive
Team chat problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Team chat problem (/showthread.php?tid=116680)



Team chat problem - kamilbam - 29.12.2009

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.


Re: Team chat problem - MadeMan - 29.12.2009

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;
}



Re: Team chat problem - kamilbam - 29.12.2009

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.


Re: Team chat problem - MadeMan - 29.12.2009

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;
}



Re: Team chat problem - kamilbam - 29.12.2009

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 :*