cmd:admins - 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: cmd:admins (
/showthread.php?tid=394544)
cmd:admins -
Socan - 22.11.2012
Well when I type /admins in game it also shows the players that have level 0 admin, any fix? heres the code;
pawn Code:
CMD:admins(playerid, params[])
{
new admins, szString[128], id;
SendClientMessage(playerid, 0x99FF00AA, ""NAME" online administrators.");
loop(i, MAX_PLAYERS) {
if (IsPlayerConnected(i)) {
if (GetAdminLevel(id) >= 1) {
new PlayerName[MAX_PLAYER_NAME];
GetPlayerName(i, PlayerName, sizeof(PlayerName));
admins++;
format(szString, sizeof(szString), "{EA8015}Admin %s(%d) (Level: %d) (%s)", PlayerName, id, GetAdminLevel(i), staffrank(i));
SendClientMessage(playerid, 0x99FF00AA, szString);
}
}
}
if (admins == 0) {
SendClientMessage(playerid, 0x99FF00AA, "{EA8015}[{C0C0C0}ERROR{EA8015}] No admins connected.");
}
else {
format(szString, sizeof(szString), "{EA8015}[{C0C0C0}INFO{EA8015}] There are currently %d Admins online.", admins);
SendClientMessage(playerid, 0x99FF00AA, szString);
}
return 1;
}
Heres the ranks also;
pawn Code:
stock staffrank(i)
{
new szString[128];
switch(GetAdminLevel(i))
{
case 0: szString = "Player";
case 1: szString = "Trial Admin";
case 2: szString = "Moderator";
case 3: szString = "Senior Moderator";
case 4: szString = "Lead Admin";
case 5: szString = "Head Admin";
case 6: szString = "Owner";
}
return szString;
}
Re: cmd:admins -
tyler12 - 22.11.2012
Do > 0
Re: cmd:admins -
park4bmx - 22.11.2012
Quote:
Originally Posted by tyler12
Do > 0
|
It's the same thing.
But have you done any debugging see what ids the loop returns, what admin levels and why.
Also show your
GetAdminLevel
Re: cmd:admins -
Socan - 22.11.2012
Code:
GetAdminLevel(playerid)
{
new file[128]; format(file, 128, USER_FILE, GetPName(playerid));
return dini_Int(file, "AdminLevel");
}
Re: cmd:admins -
park4bmx - 22.11.2012
Why do you use
id
pawn Code:
if (GetAdminLevel(i) >= 1) {
Your want to check the players from the loop right ?
AW: cmd:admins -
Skimmer - 22.11.2012
The problem is here.
Instead of
id, use
i.
pawn Code:
CMD:admins(playerid, params[])
{
new admins, szString[128], id;
SendClientMessage(playerid, 0x99FF00AA, ""NAME" online administrators.");
loop(i, MAX_PLAYERS) {
if (IsPlayerConnected(i)) {
if (GetAdminLevel(i) >= 1) {
new PlayerName[MAX_PLAYER_NAME];
GetPlayerName(i, PlayerName, sizeof(PlayerName));
admins++;
format(szString, sizeof(szString), "{EA8015}Admin %s(%d) (Level: %d) (%s)", PlayerName, id, GetAdminLevel(i), staffrank(i));
SendClientMessage(playerid, 0x99FF00AA, szString);
}
}
}
if (admins == 0) {
SendClientMessage(playerid, 0x99FF00AA, "{EA8015}[{C0C0C0}ERROR{EA8015}] No admins connected.");
}
else {
format(szString, sizeof(szString), "{EA8015}[{C0C0C0}INFO{EA8015}] There are currently %d Admins online.", admins);
SendClientMessage(playerid, 0x99FF00AA, szString);
}
return 1;
}
Re: cmd:admins -
Socan - 22.11.2012
That made it work, thanks for that but theres one problem. It only shows ONE admin not the rest ?
Re: cmd:admins -
park4bmx - 22.11.2012
I thinks it's becouse the
GetAdminLevel returns a value and it breaks the loop.
Again I'm saying do some debuging
Re: cmd:admins -
Socan - 22.11.2012
Hmm, I've never acctually debugged anything...