/hidden
#1

I want to make admins hidden on the admins list with a simple cmd i tried but got no luck, tell me whats wrong D:
pawn Код:
if (strcmp(cmd, "/admins", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            SendClientMessage(playerid, COLOR_GRAD1, "Admins Online:");
            for(new i = 0; i < MAX_PLAYERS; i++)
            {
                if(IsPlayerConnected(i))
                {
                    if(PlayerInfo[i][pAdmin] >= 1 && PlayerInfo[i][paHidden] = 0)
                    {
                        GetPlayerName(i, sendername, sizeof(sendername));
                        format(string, 256, "Admin: %s", sendername);
                        SendClientMessage(playerid, COLOR_GRAD2, string);
                    }
                }
            }
        }
        return 1;
    }
    if (strcmp(cmd, "/ahidden", true) == 0)
    {
      if(PlayerInfo[playerid][pAdmin] >= 1)
       {
           SendClientMessage(playerid, COLOR_YELLOW,"aHidden Loaded!");
           PlayerInfo[playerid][paHidden] = 1;
           return 1;
       }
    }
Help me pl0x
Reply
#2

You have this line:

pawn Код:
if(PlayerInfo[i][pAdmin] >= 1 && PlayerInfo[i][paHidden] = 0)
When it should really be:

pawn Код:
if(PlayerInfo[i][pAdmin] >= 1 && PlayerInfo[i][paHidden] == 0)
I'm surprised PAWNO didn't return any errors. You were missing an 'equal sign'. If that doesn't work, let me know.
Reply
#3

Didnt work man The thing is it sends a message if it succesfully changed, the aHidden Loaded! never comes :S I'm admin Lvl 10 on the server as a test
Reply
#4

Do you get any errors when you compile the script?
Reply
#5

The if(IsPlayerConnected(playerid)) code on the 3rd line is pointless from what I can see. Because theirs no real point in checking if playerid is online when that id typed the command.

I can't see any other problems with the script apart from the double equals that RealCop pointed out. It should work.
Reply
#6

Same... there is nothing wrong with it...
Reply
#7

its sposoed to send aHidden loaded if it successfully works, but it doesnt show
Reply
#8

Try using a a PVar, instead of the "aHidden" variable.
Reply
#9

Код:
C:\Users\Administrator\Documents\SAMP 0.3a\gamemodes\erp.pwn(1502) : warning 217: loose indentation
C:\Users\Administrator\Documents\SAMP 0.3a\gamemodes\erp.pwn(16198) : warning 217: loose indentation
C:\Users\Administrator\Documents\SAMP 0.3a\gamemodes\erp.pwn(26226) : warning 235: public function lacks forward declaration (symbol "OnPlayerPrivmsg")
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase

Header size:           5988 bytes
Code size:          1097304 bytes
Data size:          4426132 bytes
Stack/heap size:      16384 bytes; estimated max. usage=5103 cells (20412 bytes)
Total requirements: 5545808 bytes

3 Warnings.
just some minor indention errors
Reply
#10

Quote:
Originally Posted by Criss_Angel
Посмотреть сообщение
Код:
C:\Users\Administrator\Documents\SAMP 0.3a\gamemodes\erp.pwn(1502) : warning 217: loose indentation
C:\Users\Administrator\Documents\SAMP 0.3a\gamemodes\erp.pwn(16198) : warning 217: loose indentation
C:\Users\Administrator\Documents\SAMP 0.3a\gamemodes\erp.pwn(26226) : warning 235: public function lacks forward declaration (symbol "OnPlayerPrivmsg")
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase

Header size:           5988 bytes
Code size:          1097304 bytes
Data size:          4426132 bytes
Stack/heap size:      16384 bytes; estimated max. usage=5103 cells (20412 bytes)
Total requirements: 5545808 bytes

3 Warnings.
just some minor indention errors
And a lack of forward declaration. Use:
pawn Код:
forward OnPlayerPrivmsg(playerid, toplayerid, cmdtext[])
Or something like this. Idk if there is a toplayerid, or something like that, just check how your callback looks like. I don't know if this effects the functionality, but you should also fix the indentation warnings.

If you care, mine looks like this:

pawn Код:
cmd_admins(playerid)
{
    new admincount=0;
    new hidden=0;
    for(new i=0, tx=GetMaxPlayers(); i<=tx; i++)
    {
        if(IsPlayerConnected(i)&&IsPlayerLoggedIn(i)&&IsAdminAtLeast(i,1))
        {
            admincount++;
            if(GetPVarInt(i, "AdminHidden")==1)hidden++;
        }
    }
    if(admincount!=0&&admincount!=hidden)
    {
        new ames[50];
        SendClientMessage(playerid, COLOR_GREEN, "");
        if(admincount==1)format(ames, sizeof(ames), "There is %i Admin online.(Hidden: %i)", admincount, hidden);
        else format(ames, sizeof(ames), "There are %i Admins online.(Hidden: %i)", admincount, hidden);
        SendClientMessage(playerid, COLOR_GREEN, ames);
        SendClientMessage(playerid, COLOR_GREEN, "");
        SendClientMessage(playerid, COLOR_GREEN, "########ADMINS########");
        for(new i=0, tx=GetMaxPlayers(); i<=tx; i++)
        {
            if(IsPlayerConnected(i)&&IsPlayerLoggedIn(i)&&IsAdminAtLeast(i,1)&&GetPVarInt(i, "AdminHidden")!=1)
            {
                new adname[MAX_PLAYER_NAME],adetmes[50];
                GetPlayerName(i, adname, sizeof(adname));
                format(adetmes, sizeof(adetmes), "Name: %s | Level: %i", adname, GetPlayerAdminLevel(i));
                SendClientMessage(playerid, COLOR_GREEN, adetmes);
            }
        }
        SendClientMessage(playerid, COLOR_GREEN, "#######################");
    }
    else if(admincount==hidden&&admincount!=0)
    {
        new ames[50];
        if(admincount==1)format(ames, sizeof(ames), "There is %i Admin online.(Hidden: %i)", admincount, hidden);
        else format(ames, sizeof(ames), "There are %i Admins online.(Hidden: %i)", admincount, hidden);
        SendClientMessage(playerid, COLOR_GREEN, ames);
    }
    else
    {
        SendClientMessage(playerid, COLOR_GREEN, "There is 1 Admin online. (Hidden: 1)");
    }
    return 1;
}
And the commands to hide yourself:
pawn Код:
cmd_adminhide(playerid)
{
    SetPVarInt(playerid, "AdminHidden", 1);
    SendClientMessage(playerid, COLOR_GREEN, "You have successfully hidden your Admin level.");
    return 1;
}

cmd_adminshow(playerid)
{
    SetPVarInt(playerid, "AdminHidden", 0);
    SendClientMessage(playerid, COLOR_GREEN, "You have successfully shown your Admin level.");
    return 1;
}
Don't wonder, it automatically shows one admin, even if none is online. That's for hack-prevention, cuz most hackers just hack if no admin is online, i've noticed.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)