SA-MP Forums Archive
Detect players in team? - 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)
+--- Thread: Detect players in team? (/showthread.php?tid=328133)



Detect players in team? - Admigo - 23.03.2012

Heey all,
How can i detect the players in a team like:
/detectcops

Cops:
Admigo

Thanks Admigo


Re: Detect players in team? - Kindred - 23.03.2012

I suggest adding more detail to your request.

For example, are you talking about something like this?

pawn Код:
CMD:detectcops(playerid, params[])
    {
        if(IsPlayerConnected(playerid))
        {
            SendClientMessage(playerid, COLOR_GREY, "(Online) Cops:");
            for(new i = 0; i < MAX_PLAYERS; i++)
            {
                if(IsPlayerConnected(i))
                {
                    if(PlayerInfo[i][pFaction] == 1)
                    {
                        new factiontext[64], sendername[MAX_PLAYER_NAME], string[128];
                        if(PlayerInfo[i][pRank] == 6) { factiontext = "Rank 6"; }
                        else if(PlayerInfo[i][pRank] == 5) { factiontext = "Rank 5"; }
                        else if(PlayerInfo[i][pRank] == 4) { factiontext = "Rank 4"; }
                        else if(PlayerInfo[i][pRank] == 3) { factiontext = "Rank 3"; }
                        else if(PlayerInfo[i][pRank] == 2) { factiontext = "Rank 2"; }
                        else if(PlayerInfo[i][pRank] == 1) { factiontext = "Rank 1"; }
                        else { factiontext = "Rank default"; }
                        GetPlayerName(i, sendername, sizeof(sendername));
                        sendername[strfind(sendername,"_")] = ' ';
                        if(FactionDuty[i] == 0)
                        {
                            format(string, 128, "%s: %s [Duty: No]", factiontext, sendername);
                            SendClientMessage(playerid, random(0xFFFFFFFF), string);
                        }
                        else
                        {
                            format(string, 128, "%s: %s [Rank: %d] [Duty: Yes]", factiontext, sendername);
                            SendClientMessage(playerid, 0xFAAFBEFF, string);

                        }
                    }
                }
            }
        }
        return 1;
}
Note: Above was just an example, it uses ZCMD aswell as sscanf and other includes/plugins you might not have.

If you have an enum like above, and have Rank and Faction in it, you can see their name and rank they are.

Sorry if I didn't answer your question, didn't really specify much in it.

*Note2: Command is untested, made this from my /admins command that displayed the online admins*


Re: Detect players in team? - antonio112 - 23.03.2012

Like KurtBag stated, all you need to do, is a loop through all online players and check the team variable. In order to help you more, we'll need your team variable.