/unban command
#1

Anyone know how to make unban?

If I do /unban [Exact Name]

this dini_IntSet(file, "Status", 2); will change to dini_IntSet(file, "Status", 0);

So the status will reset to 0 or offline.

Код:
Status (0 = offline, 1 = online, 2 = banned)
and lastly check if player is not banned, else SendClientMessage(playerid, RED, "Player is not banned.");




pawn Код:
COMMAND:ban(playerid,params[])
{
    if(PlayerInfo[playerid][AdminLevel] >= LEVEL_ban)
    {
        new player, reason[128];
        if(sscanf(params, "rs[128]", player, reason))
        {
            SendClientMessage(playerid, WHITE,"{FFFF00}Usage: /ban [PlayerID/PartOfName] [Reason]");
            return 1;
        }
        if(PlayerInfo[player][AdminLevel] != MAX_ADMIN_LEVEL)
        {
            if(IsPlayerConnected(player) && player != INVALID_PLAYER_ID && player != playerid && PlayerInfo[player][AdminLevel] != MAX_ADMIN_LEVEL && PlayerInfo[player][Logged] == true)
            {
                new year,month,day, string[128], string2[128];
                getdate(year, month, day);
                format(string,sizeof(string),"** %s has been banned from the server by %s [Reason: %s]",GetName(player),GetName(playerid),reason);
                SendClientMessageToAll(GREY,string);
                print(string);
                CreateBan(player, GetName(playerid), reason);
                format(string2, sizeof(string2),""red"You have been banned!"white"\n\nAdmin:\t\t%s\nReason:\t%s\n",GetName(playerid),reason);
                ShowPlayerDialog(player, BAN_DIALOG, DIALOG_STYLE_MSGBOX, "Notice", string2, "Close", "");
                Kick(player);
                return 1;
            }
            else
            {
                SendClientMessage(playerid, WHITE, "{FF0000}>> Player is not connected or is yourself or is the highest level admin");
            }
        }
        else
        {
            new warnstring[128];
            format(warnstring,sizeof(warnstring),"WARNING: %s just tried to ban you with reason: %s", GetName(playerid), reason);
            SendClientMessage(player, RED, warnstring);
            SendClientMessage(playerid, RED, ">> I hope thats a joke");
        }
    }
    else
    {
        SendClientMessage(playerid, WHITE, NO_PERM);
    }
    return 1;
}



pawn Код:
stock CreateBan(playerid, adminname[], reason[])
{
    new Date[16], year, month, day;
    getdate(year, month, day);
    format(Date, sizeof(Date), "%d/%d/%d", day, month, year);
    #if USE_MYSQL == true
    new query[256];
    mysql_real_escape_string(reason, reason);
    mysql_real_escape_string(adminname, adminname);
    format(query, sizeof(query), "UPDATE `"#MYSQL_TABLE"` SET `Status` = 2, `BannedBy` = '%s', `BanReason` = '%s', `BanDate` = '%s' WHERE `PlayerName` = '%s'", adminname, reason, Date, GetName(playerid));
    if(mysql_ping(gSQL))
    {
        mysql_query(query, _THREAD_BAN_USER, 0, gSQL);
    }
    #else
    new file[128];
    format(file, sizeof(file), "/%s/%s.ini", DINI_PATH, GetName(playerid));
    dini_IntSet(file, "Status", 2);
    dini_Set(file, "BannedBy", adminname);
    dini_Set(file, "BanReason", reason);
    dini_Set(file, "BanDate", Date);
    #endif
    return 1;
}
Reply
#2

How do you check if the player is banned? (OnPlayerconnect i guess)
Reply
#3

Basically, make a command /unban [player name] and check if the player name submitted exists in the database.
If it exists check if there banned status is in place, if so change it to offline status and save the changes.
And the player has been unbanned.

This way you can unban them even if there offline.
Reply
#4

I have a /Unbanip command.

PHP код:
CMD:unbanip(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] >= || PlayerInfo[playerid][pBanAppealer] >= 1)
    {
        if(
isnull(params)) return SendClientMessageEx(playeridCOLOR_WHITE"USAGE: /unbanip [ip]");
        if(
IsValidIP(params)) return SendClientMessageEx(playeridCOLOR_WHITE"That is not a valid IP address!");
        new 
string[128], yearmonth,day;
        
getdate(yearmonthday);
        
RemoveBan(params);
        
format(string128"AdmCmd: %s has unbanned IP %s"GetPlayerNameEx(playerid), params);
        
ABroadCast(COLOR_LIGHTRED,string,2);
        
format(stringsizeof(string), "AdmCmd: %s has unbanned IP %s (%d-%d-%d)"GetPlayerNameEx(playerid), paramsmonthdayyear);
        
Log("logs/ban.log"string);
        print(string);
    }
    return 
1;

Unban by name:
PHP код:
CMD:unban(playeridparams[])
{
    if(
PlayerInfo[playerid][pAdmin] >= || PlayerInfo[playerid][pBanAppealer] >= 1)
    {
        new 
string[128];
        if(
isnull(params)) return SendClientMessageEx(playeridCOLOR_WHITE"USAGE: /unban [playername]");
        if(
doesAccountExist(params))
        {
            
OnPlayerOfflineLogin(params);
            if( 
PlayerInfo[MAX_PLAYERS][pPermaBanned] == )
            {
                
SendClientMessageExplayeridCOLOR_WHITE"Permanently banned accounts can only be unbanned via FTP." );
            }
            else
            {
                if( 
PlayerInfo[MAX_PLAYERS][pBanned] >= )
                {
                    
PlayerInfo[MAX_PLAYERS][pBanned] = 0;
                    
PlayerInfo[MAX_PLAYERS][pWarns] = 0;
                    
PlayerInfo[MAX_PLAYERS][pDisabled] = 0;
                    
RemoveBan(PlayerInfo[MAX_PLAYERS][pIP]);
                    print(
"OnPlayerOfflineLogin: Saving variables to file");
                    
OnPlayerOfflineSave(params);
                    print(
"OnPlayerOfflineLogin: Variables saved properly");
                    
format(string128"AdmCmd: %s (IP:%s) was unbanned by %s."paramsPlayerInfo[MAX_PLAYERS][pIP], GetPlayerNameEx(playerid));
                    
ABroadCast(COLOR_LIGHTRED,string,2);
                    new 
yearmonth,day;
                    
getdate(yearmonthday);
                    
format(stringsizeof(string), "AdmCmd: %s (IP:%s) was unbanned by %s. (%d-%d-%d)"paramsPlayerInfo[MAX_PLAYERS][pIP], GetPlayerNameEx(playerid),month,day,year);
                    
Log("logs/ban.log"string);
                    print(string);
                }
                else
                {
                    
SendClientMessageExplayeridCOLOR_WHITE"Not a banned account!" );
                }
            }
        }
        else
        {
            
SendClientMessageExplayeridCOLOR_WHITE"That account doesn't exist." );
        }
    }
    else
    {
        
SendClientMessageEx(playeridCOLOR_GRAD1"You are not authorized to use that command!");
    }
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)