/unbanall
#1

I need command which will open ban files and take "BanName" from all of it and than go to the account of banned user and set Banned to 0....

This is just for one player, and you need to type his ip....
new banFILE[128],ip[32];
format(banFILE, 128, "NooBotRP/Users/Bans/%s.ban", ip);
new banneduser = dini_Get(banFILE,"BanName"));
format(file, sizeof(file),"NooBotRP/Users/%s.ini", banneduser);
dini_IntSet(file, "Banned", 0);

Ban files are named by ip_address.ban
Ban file contains:
BannedBy=DraGoN
BanDate=19/7/2011 at 16:57:46
BanReason=Cheat
BanName=Jeremy_Hakwins
Reply
#2

Wrong Section.
Reply
#3

Try doing a loop.
Reply
#4

But how to make script to open all files from contain folder...
Reply
#5

pawn Код:
for(new i = 0; i != 200; ++i)
{
    format(str,sizeof(str),"BAN_DIRECTORY_GOES_HERE/%s.ini",i);
    //other code goes here...
}
Try sumthing like that..
Reply
#6

That wouldn't work becuse ban files are ip.ban
for example 12.34.567.890.ban
Reply
#7

So what?
That doesn't matter at all.
It's still a string.
Reply
#8

This code works
pawn Код:
CMD:unbanipname(playerid, params[])
{
    new banFILE[128],file[64],ip[64],string[128];
    if(PlayerInfo[playerid][pAdmin] < 1337) return SendClientMessage(playerid, COLOR_GREY, "You are not allowed to use this command.");
    if(sscanf(params, "s[32]", ip)) return SendClientMessage(playerid, COLOR_WHITE, "Koriscenje: /unbanipname [playersIP]");
    format(banFILE, 128, "NooBotRP/Users/Bans/%s.ban", ip);
    new banneduser[MAX_STRING];
    banneduser = dini_Get(banFILE,"BanName");
    format(string, sizeof(string), "* Played unbanned %s.", banneduser);
    SendClientMessage(playerid, COLOR_GREY, string)
    format(file, sizeof(file),"NooBotRP/Users/%s.ini", banneduser);
    dini_IntSet(file, "BanovanAcc", 0);
    return 1;
}
Trying to loop but dont work...
pawn Код:
CMD:unbanall(playerid, params[])
{
    new banFILE[128],file[64];
    if(PlayerInfo[playerid][pAdmin] < 1337) return SendClientMessage(playerid, COLOR_GREY, "You are not allowed to use this command.");
    if (isnull(params))
    {
        for(new i = 0; i != 200; ++i)
        {
            format(banFILE, 128, "NooBotRP/Users/Bans/%s.ban", i);
            new banneduser[MAX_STRING];
            banneduser = dini_Get(banFILE,"BanName");
            format(file, sizeof(file),"NooBotRP/Users/%s.ini", banneduser);
            dini_IntSet(file, "BanovanAcc", 0);
        }
    }
    return 1;
}
Anyone? How to loop?
Reply
#9

Quote:
Originally Posted by Delux13
Посмотреть сообщение
So what?
That doesn't matter at all.
It's still a string.
Ofc it matters. You can't use a string like an int inside the loop expression. That would look like this.

pawn Код:
for(new "lol"; "lol" < "rofl"; "lol"++)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)