Looping through players - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Server (
https://sampforum.blast.hk/forumdisplay.php?fid=6)
+--- Forum: Server Support (
https://sampforum.blast.hk/forumdisplay.php?fid=19)
+--- Thread: Looping through players (
/showthread.php?tid=528395)
Looping through players -
jackx3rx - 27.07.2014
I am about to make a /report command which sends a message to ONLY admins. How would I loop through all the online players and send the message to the admins?
I am using an enum btw, all admin ranks are stored in pAdmin.
Re: Looping through players -
Isolated - 27.07.2014
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(PlayerInfo[i][pAdmin] != 0)
SendClientMessage(i, -1, message);
else
break;
}
Try that.
Re: Looping through players -
Redirect Left - 27.07.2014
Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(pAdmin[i] > 0) // alter to actual variable 'pAdmin' is ambiguous at best.
{
// They're admin, send message
}
}
}
Re: Looping through players -
Isolated - 27.07.2014
Quote:
Originally Posted by Redirect Left
Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(pAdmin[playerid] > 0) // alter to actual variable 'pAdmin' is ambiguous at best.
{
// They're admin, send message
}
}
}
|
better then my code ^. Haven't bothered with PAWN in well over a year.
AW: Re: Looping through players -
jackx3rx - 27.07.2014
Quote:
Originally Posted by Redirect Left
Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(pAdmin[playerid] > 0) // alter to actual variable 'pAdmin' is ambiguous at best.
{
// They're admin, send message
}
}
}
|
Works perfect, thanks.