Unban Command, From DINI to Y_INI.
#1

[SOLVED]
Reply
#2

NoOne !?
Reply
#3

pawn Код:
if (strcmp(cmd, "/unban", true)==0)
    {
        if(PlayerInfo[playerid][pAdmin] >=1)
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_WHITE, "USAGE: /unban [PlayerName]");
                return 1;
            }
            format(string, sizeof(string), "users/%s.ini", tmp);
            new File:hFile = fopen(string, io_read);
            //new File: hFile = fopen(string, io_append);
            if (hFile)
            {
                new Data[ 256 ],val [ 256 ];
                while ( fread( hFile , Data , sizeof( Data ) ) )
                    if( strcmp( ini_GetKey( Data ) , "Locked" , true ) == 0 )
                        val = ini_GetValue( Data );
                if(strval( val ) == 1)
                {
                    new var[64];
                    format(var, sizeof(var), "Locked=1\n");
                    //fdeleteline(string,var);
                    fclose(hFile);
                    hFile = fopen(string, io_append);
                    format(var, 64, "Locked=0\n");
                    fwrite(hFile, var);
                    fclose(hFile);
                }
                else
                {
                    fclose(hFile);
                    return SendClientMessage(playerid, COLOR_WHITE, "  ERROR : Player account doesn`t locked!!");
                }
            }
            GetPlayerName(playerid, sendername, sizeof(sendername));
            SendClientMessage(playerid, COLOR_WHITE, "Player unlocked please ask for his IP and use /unbanip [IP]");
            format(string, 128, "AdmWarning: %s has unbanned %s", sendername, tmp);
            ABroadCast(COLOR_LIGHTRED,string,1);
            new year, month,day;
            getdate(year, month, day);
            format(string, 128, "AdmWarning: %s has unbanned %s (%d-%d-%d)", sendername, tmp,day,month,year);
            BanLog(string);
        }
        else
        {
            SendClientMessage(playerid, COLOR_GRAD1, "   you are not authorized to use that command!");
        }
        return 1;
    }
Try this. Rep if helped
Reply
#4

PurpleDragon, that command has nothing to do with y_ini.
y_ini is name = whatever, not name=whatever
Reply
#5

Yes! Can someone help me, to make it with Y_INI !?
Reply
#6

Maybe try this can't say it will work because I am also understanding y_ini.
pawn Код:
CMD:unban(playerid, params[])
{
    if(PlayerInfo[playerid][AdminLevel] >= 3)
    {
        new File[50], string[128];
        if(sscanf(params, "u[50]",File)) return SendClientMessage(playerid, COLOR_YELLOW, "-XSBot-: Correct Usage: /unban [Player Name]");
        format(File, sizeof(File), "Users/%s.ini", params);
        if(!fexist(File)) return SendClientMessage(playerid, COLOR_RED, "-XSBot-: This player is not registered.");
        if(INT_Int(File, "Banned") == 0) return SendClientMessage(playerid, COLOR_RED, "-XSBot-: This player is not marked as banned, unable to proceed with unbanning.");
        INT_IntSet(File, "Banned", 0);
        format(string, sizeof(string), "%s has been unbanned by %s", File, GetName(playerid));
        SaveIn("UnbanLog",string);
        format(string, sizeof(string), "-XSBot-: {FF0000}%s {FFFF00}has been unbanned by %s{FFFF00}.", params, GetColorNameID(playerid));
        SendClientMessageToAll(COLOR_YELLOW, string);
    }
    else return SendErrorMessage(playerid, ADMIN_ERROR);
    return 1;
}
Reply
#7

Maybe try this?
pawn Код:
CMD:unban(playerid, params[])
{
    if(PlayerInfo[playerid][AdminLevel] >= 3)
    {
        new File[50], string[128];
        if(sscanf(params, "u[50]",File)) return SendClientMessage(playerid, COLOR_YELLOW, "-XSBot-: Correct Usage: /unban [Player Name]");
        format(File, sizeof(File), "Users/%s.ini", params);
        if(!fexist(File)) return SendClientMessage(playerid, COLOR_RED, "-XSBot-: This player is not registered.");
        new Bnd;
        new INI:File = INI_Open(File);
        Bnd = INI_Int("Banned", Bnd);
        if(Bnd == 0) return SendClientMessage(playerid, COLOR_RED, "-XSBot-: This player is not marked as banned, unable to proceed with unbanning.");
        INI_WriteInt(File, "Banned", 0);
        INI_Close(File);
        format(string, sizeof(string), "%s has been unbanned by %s", File, GetName(playerid));
        SaveIn("UnbanLog",string);
        format(string, sizeof(string), "-XSBot-: {FF0000}%s {FFFF00}has been unbanned by %s{FFFF00}.", params, GetColorNameID(playerid));
        SendClientMessageToAll(COLOR_YELLOW, string);
    }
    else return SendErrorMessage(playerid, ADMIN_ERROR);
    return 1;
}
Reply
#8

I'm not really sure how to check if the player wasn't banned without ParseFile, so I'm just posting a code that unbans the player but no ban check.
pawn Код:
CMD:unban(playerid, params[])
{
    if(PlayerInfo[playerid][AdminLevel] >= 3)
    {
        new path[36], string[128];
        if (isnull(params)) return SendClientMessage(playerid, COLOR_YELLOW, "-XSBot-: Correct Usage: /unban [Player Name]");
        format(path, sizeof(path), "Users/%s.ini", params);
        if(!fexist(path)) return SendClientMessage(playerid, COLOR_RED, "-XSBot-: This player is not registered.");
        new file = INI_Open(path);
       
        // If you have a tag, write it here or it will not work.
       
        INI_WriteInt(file, "Banned", 0);
        INI_Close(file);
        format(string, sizeof(string), "%s has been unbanned by %s", File, GetName(playerid));
        SaveIn("UnbanLog",string);
        format(string, sizeof(string), "-XSBot-: {FF0000}%s {FFFF00}has been unbanned by %s{FFFF00}.", params, GetColorNameID(playerid));
        SendClientMessageToAll(COLOR_YELLOW, string);
    }
    else return SendErrorMessage(playerid, ADMIN_ERROR);
    return 1;
}
Reply
#9

IT Doesn't Work !!!
Reply
#10

ANyone !
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)