Get online admins number - 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: Get online admins number (
/showthread.php?tid=480951)
Get online admins number -
Blackazur - 13.12.2013
How to get the online admins number to make something like "There are 2 admins online." ?
Re: Get online admins number - Astralis - 13.12.2013
Count them in a stock.
AW: Get online admins number -
Blackazur - 13.12.2013
A short example please?
Re: AW: Get online admins number -
tyler12 - 13.12.2013
Quote:
Originally Posted by Blackazur
A short example please?
|
pawn Код:
stock CountAdmins()
{
new count = 0;
foreach(new i:Player)
{
if(IsPlayerAdmin(i)) count ++;
}
return count;
}
Re: Get online admins number -
Wizza - 13.12.2013
Here is an example.
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(PlayerInfo[i][pAdmin]) // just change the variable name to your admin system variable name.
{
online ++;
}
}
pawn Код:
format(str, sizeof(str), "Administrators online: %d", online);
SendClientMessage(playerid, -1, str);
AW: Re: AW: Get online admins number -
Blackazur - 13.12.2013
Quote:
Originally Posted by tyler12
pawn Код:
stock CountAdmins() { new count = 0; foreach(new i:Player) { if(IsPlayerAdmin(i)) count ++; } return count; }
|
And how to use it in a SendClientMessage? Just "CountAdmins" or "count"?
Re: AW: Re: AW: Get online admins number -
tyler12 - 13.12.2013
Quote:
Originally Posted by Blackazur
And how to use it in a SendClientMessage? Just "CountAdmins" or "count"?
|
format(string,sizeof(string),"%d admins",CountAdmins());
Re: Get online admins number -
Kyance - 13.12.2013
pawn Код:
CMD:admins(playerid, params[]) {
new count = 0;
new string[128];
for(new i = 0; i < MAX_PLAYERS; i ++)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][pAdmin] > 0)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(i, name, sizeof(name));
count++;
format(string, sizeof(string), "* There are currently %d admins online.", count);
SendClientMessage(playerid, COLOR_GREEN, string);
}
}
}
if(count == 0)
{
SendClientMessage(playerid, COLOR_RED,"* There are currently 0 admins online.");
}
return 1;
}
Re: Get online admins number -
Beckett - 13.12.2013
You want to COUNT your administrators online or you want to show them up in a command like /admins?