SA-MP Forums Archive
SendClientMessage to PlayerTeam - 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: SendClientMessage to PlayerTeam (/showthread.php?tid=258966)



SendClientMessage to PlayerTeam - Rolyy - 02.06.2011

I am together with an friends starting to script TDM server, and we were about to create Team_Chat for ther own Team.

And I was wondering if it would be possible to SendClientMessage work together with PlayerTeam in some kind of way.
Anyone have suggestions or comments/opinions? Please reply here.

Please read before posting.


Re: SendClientMessage to PlayerTeam - Steve M. - 02.06.2011

Well, you can make a new function. Something like this:
pawn Код:
stock SendTeamMessage(color, const message[], team)
{
    for(new p; p < MAX_PLAYERS; ++p)
    {
        if(IsPlayerConnected(p) && GetPlayerTeam(p) == team) SendClientMessage(p, color, message);
    }
    return 1;
}



Re: SendClientMessage to PlayerTeam - Laronic - 02.06.2011

pawn Код:
//Usage
SendTeamMessage(15, 0xFFFFFFAA, "Hello team, we are team 15 and this text color is white, Awesum!");
pawn Код:
//Paste this somewhere in ur script but not in inside of any callbacks
stock SendTeamMessage(team, color, const message[]) //CyberGhost
{
    for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i))
    {
        if(GetPlayerTeam(i) == team)
        {
            SendClientMessage(i, color, message);
        }
    }
    return 1;
}
Edit: Too late


Re: SendClientMessage to PlayerTeam - Rolyy - 02.06.2011

I am not really familiar with making new Functions.
But I tryed the code script of CyberGhost, but it doesn't displays.

Код:
SendTeamMessage(TEAM_USA,COLOR_DARKGREEN, string);
All defines & string message are correct.

Код:
	stock SendTeamMessage(teamid, color, const string[]) //CyberGhost
	{
	    for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i))
	    {
	        if(GetPlayerTeam(i) == teamid)
	        {
	            SendClientMessage(i, color, string);
	        }
	    }
	    return 1;
	}
Note: No Error's but it Doesn't display on any SAMP Client's.


Код:
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase



Re: SendClientMessage to PlayerTeam - Laronic - 02.06.2011

Hmm, i just tested it, i tested with gTeam and not GetPlayerTeam. and if im not wrong GetPlayerTeam are buggy.


Re: SendClientMessage to PlayerTeam - Rolyy - 02.06.2011

Then how do you use it?
Could you give me an example?


Re: SendClientMessage to PlayerTeam - Laronic - 02.06.2011

Quote:
Originally Posted by Rolyy
Посмотреть сообщение
Then how do you use it?
Could you give me an example?
Do something like

pawn Код:
//at top
new gTeam[MAX_PLAYERS];

//Somewhere in your sctipt but not inside any callback
stock GetPlayerTeamEx(playerid)
{
    return gTeam[playerid];
}

stock SetPlayerTeamEx(playerid, teamid)
{
    return gTeam[playerid] = teamid;
}
and then change all "GetPlayerTeam" and "SetPlayerTeam" to "GetPlayerTeamEx" and "SetPlayerTeamEx"

pawn Код:
stock SendTeamMessage(team, color, const message[]) //CyberGhost
{
    for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i))
    {
        if(GetPlayerTeamEx(i) == team)
        {
            SendClientMessage(i, color, message);
        }
    }
    return 1;
}



Re: SendClientMessage to PlayerTeam - Jack Shred - 02.06.2011

Quote:

new gTeam[MAX_PLAYERS];

stock SendTeamMessage(playerid, color, string)
{
new teamid;
teamid = gTeam[playerid];
for (new i; i < MAX_PLAYERS; i++)
{
if(gTeam[i] == teamid)
{
SendClientMessage(i, color, string);
}
}
return 1;
}

If you use any other variable, change gTeam into yours.
This will work with any team id.
You can now use the function SendTeamMessage(playerid, color, string)

I might've scripted it wrong, did it blind without any pawno help.