/unban-command?
#1

Hey everyone!

I've scripted a long time ago a "ban"-command, but now, I'm clueless on how to script an "unban"-command in ZCMD? What should I do, get the player's IP? But how to remove it from "samp.ban"? Any help would be appreciated, and please explain the unban-step clearly! ^^
Reply
#2

PHP код:
CMD:unbanip(playerid,params[])
{
    new 
ip[32], dformat[64];
    if(
PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid,0xff0000ff,"You have to be admin LVL 3 at least");
    if(
sscanf(params,"s[32]",ip)) return SendClientMessage(playerid,0xff0000ff,"USAGE: /unbanip [ip]");
    
format(dformat,sizeof dformat,"unbanip %s",ip);
    
SendRconCommand(dformat);
    return 
1;

Reply
#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
#4

How is that easier then using the default ban system?
Reply
#5

@Skribblez

Did I ever say that I'm using MySQL / SQlite? I don't think so...

@new

Hmm, that's cool! But is the IP really a string? Because you wrote this: s[64]

Anyways, I'mma try it out, thank you!
Reply
#6

I think the ip might actually be a float lols, I wrote that in the browser, let me know if it works.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)