Hello, Need abit of a help with..
#1

Hello,
I need litle help with unbanning player, actualy, I wanna set every single user account's Permbanned to 0, and I'm struggling with the command.. Here is what i made little..

pawn Код:
CMD:unbanallplayers(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 8)
    {
        SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
        return 1;
    }

    foreach(Player,i)
    OnPlayerOfflineLogin(i);
    if( PlayerInfo[i][pPermaBanned] >= 1)
    {
        PlayerInfo[i][pPermaBanned] = 0;
        PlayerInfo[i][pBanned] = 0;
        PlayerInfo[i][pWarns] = 0;
        PlayerInfo[i][pDisabled] = 0;
        RemoveBan(PlayerInfo[i][pIP]);
        print("DEBUG: Saving variables to file");
        OnPlayerOfflineSave(i);
        print("DEBUG: Variables saved properly");
    }
    else { //Still sets it to 0 even if not banned.
    PlayerInfo[i][pPermaBanned] = 0;
    PlayerInfo[i][pBanned] = 0;
    print("DEBUG: (ELSE MODE) Players has successfully been unbanned");
    OnPlayerOfflineSave(i);
    print("DEBUG: (ELSE MODE) All player accounts has been saved.");
    }
    return 1;
}
foreach is for al players right, I'm abit confused .. if i can use it for ofline loop aswell..
Is my setup correct?

Please do explain and help me out .. Thank you.
Reply
#2

You can't use it for offline players this way as you don't know their ID that they will connect or even the name.

there are several options.
1.make a file containing every single name that has played your server and use it for looping those players so then you will know they will have a save file on your server with the ban status.
2. There was a file/directory plugin which listed the files in a directory.

Other then that don't think there's another way to know the offline players
Reply
#3

Quote:
Originally Posted by park4bmx
Посмотреть сообщение
You can't use it for offline players this way as you don't know their ID that they will connect or even the name.

there are several options.
1.make a file containing every single name that has played your server and use it for looping those players so then you will know they will have a save file on your server with the ban status.
2. There was a file/directory plugin which listed the files in a directory.

Other then that don't think there's another way to know the offline players
No there must be some other way, like get all the user.ini files.., read from it one by one and set Ban to 0.. anyone else knows
Reply
#4

Foreach only works for online players. You would need some other way to go through all player files.
Reply
#5

Quote:
Originally Posted by dominik523
Посмотреть сообщение
Foreach only works for online players. You would need some other way to go through all player files.
Any other way anyone can help me out?
Reply
#6

There is a way, but it's an absolute datafuck. You would have to loop through each individual character from A-Z, 0-9 and including symbols, 24 times over for each character to see if the file exists. If it exists, change the variable to 0. So in short terms, don't do it. Either that, or you create a ban log, get the server to loop through the text file contents, and search for the contents line by line with the usernames. Then edit that user file. Again, it's a big time waster though..
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)