SendClientMessage to PlayerTeam
#1

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.
Reply
#2

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;
}
Reply
#3

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
Reply
#4

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
Reply
#5

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

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

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;
}
Reply
#8

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)