Looping through players
#1

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

pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
    if(PlayerInfo[i][pAdmin] != 0)
        SendClientMessage(i, -1, message);
    else
        break;
}
Try that.
Reply
#3

Код:
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
		}
	}
}
Reply
#4

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)