/unban-command?
#3

if you want to have an easy one, create a player variable that determines whether he is banned or not. then when you ban someone, set this variable as banned.

for the ban lifting(unban) command:
most convenient way of having it is to use mysql.

then, something like this:
pawn Код:
command(unban, playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
        new name[24], query[128], string[128];
        if(sscanf(params, "s[24]", name)) return SendClientMessage(playerid, 0xFFFFFFFF, "Syntax: /unban [player name] CASE SENSITIVE!");
        if(!pl[playerid][admin]) return SendClientMessage(playerid, 0xFFFF00FF, "You can't use this command!");
       
        format(query, sizeof(query), "SELECT * FROM users WHERE username='%s'", name);
        mysql_query(query);
        mysql_store_result();
       
        new row = mysql_num_rows();
        new isplayerbanned, getdata[64];
        if(row == 1)
        {
            mysql_fetch_field_row(getdata, "isbanned"); isplayerbanned = strval(getdata);
           
            if(isplayerbanned == 1)
            {
                format(string, sizeof(string), "UPDATE users SET isbanned='0' WHERE username='%s'", name);
                mysql_query(string);
               
                format(string, sizeof(string), "You have lifted %s's ban.", name);
                SendClientMessage(playerid, 0xFFFF00FF, string);
            }
            else SendClientMessage(playerid, 0xAAAAAAFF, "That player isn't banned.");
        }
        else SendClientMessage(playerid, 0xAAAAAAFF, "USER DOESN'T EXIST!");
        mysql_free_result();
    }
    return 1;
}
and then, before the player spawns or when he connects:
pawn Код:
if(pl[playerid][isbanned] == 1)
{
    SendClientMessage(playerid, 0xFF0000FF, "You are banned from this server!");
    pl[playerid][isbanned] = 1;
    Ban(playerid);
}
edit: i used "pl" which in most RP servers is declared as "PlayerInfo", if you want to unban their IP, same procedure, just change the variables used.
Reply


Messages In This Thread
/unban-command? - by Twisted_Insane - 23.03.2012, 01:08
Re: /unban-command? - by new121 - 23.03.2012, 01:20
Re: /unban-command? - by Skribblez - 23.03.2012, 01:31
Re: /unban-command? - by new121 - 23.03.2012, 02:54
Re: /unban-command? - by Twisted_Insane - 23.03.2012, 09:32
Re: /unban-command? - by new121 - 23.03.2012, 15:34

Forum Jump:


Users browsing this thread: 1 Guest(s)