SA-MP Forums Archive
Player Loop - 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: Player Loop (/showthread.php?tid=321790)



Player Loop - Chris' - 28.02.2012

Hi, i'm trying to make a command that loops throught all accounts, and finds admins

So i made like:

pawn Код:
if(strcmp(cmdtext, "/adminsearch", true) == 0)
    {
        new string2[512], string[256];
        GetPlayerName(playerid, giveplayername, sizeof(giveplayername));
        format(string, sizeof(string), "Accounts/%s.ini", giveplayername);
        dini_Get(string, "AdminLevel");
        format(string2, sizeof(string2), "Administrators\nName: %s | AdminLevel: %d", giveplayername, AccInfo[playerid][AdminLevel]);
        SendClientMessage(playerid, 0xFFFFFF, string2);
        string2++;
    }
pawn Код:
C:\Documents and Settings\Administrator\Desktop\Stunt World\gamemodes\SW.pwn(2252) : error 022: must be lvalue (non-constant)
C:\Documents and Settings\Administrator\Desktop\Stunt World\gamemodes\SW.pwn(2252) : warning 215: expression has no effect
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
Can you help me?


Re: Player Loop - Twisted_Insane - 28.02.2012

Isn't an adminlevel usually in numbers?

pawn Код:
dini_GetInt



Re: Player Loop - Vince - 28.02.2012

It's impossible to check all accounts using dini (or any ini writer for that matter) without causing severe lag.

You'd need to have a file that contains a list of all registered accounts. Then you'd need to open that file, read one value and store it. Then use the value that was just stored to open a player's file. Retrieve the admin level variable, close the file. Repeat for each registered account (possibly 1000+).


Re: Player Loop - Roperr - 28.02.2012

I have a better solution.

Why not storing admin names after /setadmin or /setlevel inside a separate file and then reading from there?

EDIT:

I mean it's absolute madness to read all player files on a server, where you could have like over 50,000 or 100,000 player files.

So upon /setadmin -> save name inside "/Admins.ini"
And upon /setadmin (id) 0 (DEMOTE) -> remove name inside "/Admins.ini"


Re: Player Loop - Chris' - 28.02.2012

Ok, i'll try, thanks


Re: Player Loop - Chris' - 28.02.2012

I like your idea rooper


Re: Player Loop - Roperr - 28.02.2012

Quote:
Originally Posted by Chris'
Посмотреть сообщение
I like your idea rooper
I'm pleased that you like it