[HELP] /admins!! [SOLVED]
#1

Hey I use this code
pawn Код:
if (strcmp(cmd, "/admins", true) == 0)
    {
        new string[256];
        new player[250];
        SendClientMessage(playerid, COLOR_FINALSCORE, "|---------------Online Admins---------------|");
        new count=0;
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if (IsPlayerConnected(i))
            {
                if(PlayerInfo[playerid][pAdmin] >= 1 && PlayerInfo[playerid][pAdmin] <= 6)
                {
                    GetPlayerName(i, player, sizeof(player));
                    format(string, 256, "Administrators: %s(%d)-%d",player, i, PlayerInfo[playerid][pAdmin]);
                    SendClientMessage(playerid, COLOR_CYAN, string);
                    count++;
                }
            }
        }
        if(count == 0)
        {
          SendClientMessage(playerid, COLOR_CYAN, "No admin online at the moment.");
        }
        SendClientMessage(playerid, COLOR_FINALSCORE, "|--------------------------------------------------|");
        return 1;
    }
I get this warning
Код:
warning 219: local variable "i" shadows a variable at a preceding level
On line where is
Код:
		for(new i = 0; i < MAX_PLAYERS; i++)
when I do /admins ingame, I get
|-----------------------------------------|
No admin online at the moment
|-----------------------------------------|

Please HELP it's URGENTLY!!!!!!
Reply
#2

You have more one:
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
in OnPlayerCommandText, try remove this!
Reply
#3

Oh thanks © Tђэ LυxυяiσN™ !! Now I don't have warnings...

Only when I do /admins
Still shows as no admin online, what to do please help!?
Reply
#4

Quote:
Originally Posted by LyQue
Oh thanks © Tђэ LυxυяiσN™ !! Now I don't have warnings...

Only when I do /admins
Still shows as no admin online, what to do please help!?
Try this (Not Tested):
pawn Код:
if (strcmp(cmd, "/admins", true) == 0)
{
new string[256];
new player[250];
SendClientMessage(playerid, COLOR_FINALSCORE, "|---------------Online Admins---------------|");
new count;
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerInfo[i][pAdmin] >= 1 && PlayerInfo[i][pAdmin] <= 6)
{
GetPlayerName(i, player, sizeof(player));
format(string, 256, "Administrators: %s(%d)-%d",player, i, PlayerInfo[playerid][pAdmin]);
SendClientMessage(playerid, COLOR_CYAN, string);
count++;
}
}
}
if(count == 0)
{
SendClientMessage(playerid, COLOR_CYAN, "No admin online at the moment.");
}
SendClientMessage(playerid, COLOR_FINALSCORE, "|--------------------------------------------------|");
return 1;
}
Reply
#5

easy way downlaod luxorian's fs for admin syst
Reply
#6

Thanks for the replies, but I still get "No admin online at the moment"...

Anybody know what's the problem? It's simply not counting admins...
Reply
#7

Quote:
Originally Posted by LyQue
Thanks for the replies, but I still get "No admin online at the moment"... :'(

Anybody know what's the problem? It's simply not counting admins... :'(
I think you're doing something wrong, because here it worked perfectly:

Reply
#8

Ohh damn, what is wrong!??
What I'm doing wrong...

Maybe that i variable is the problem, since I removed it

Please help it's urgently.... Please!
Reply
#9

Hey © Tђэ LυxυяiσN™, sorry for double post man!

I found another code here, and it's working without deleting i thing..
pawn Код:
dcmd_admins(playerid, params[])
{
  if(strlen(params)) return SendClientMessage(playerid, COLOR_RED, "Use /admins");
  new count = 0;
  new string[128];
  for(new i = 0; i < MAX_PLAYERS; i ++)
  {
    if(IsPlayerConnected(i))
    {
      new player[24];
      GetPlayerName(i, player, 24);
      if(PlayerInfo[playerid][pAdmin] >= 1 && PlayerInfo[playerid][pAdmin] <= 6)
      {
        format(string, sizeof(string), "Present Admins: %s(%i)-%i ",player,i,PlayerInfo[playerid][pAdmin]);
        SendClientMessage(playerid, COLOR_CYAN, string);
        count++;
      }
    }
  }
  if(count == 0)
  {
    SendClientMessage(playerid, COLOR_CYAN, "No admins online at the moment");
  }
  return 1;
}
But now, when admin uses /admins, it gives list of all players online with the admin level of admin which used command

Like, I am admin lvl4 and I use /admins it gives this

Present Admins: Player1-4
Present Admins: Player2-4
Present Admins: Player3-4
Present Admins: Player4-4
Present Admins: Player5-4
........................
........................

And when player (non admin user) uses /admins, it gives him "No admins online at the moment"

Do you maybe know the problem now?
Reply
#10

Anyone please, it's urgently, help me please
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)