Ban Problem
#1

Hello Guys ,i`ve a problem with /ban command ,when i do /ban the player gets kicked not banned.
if you have any idea of how to fix it post it please
pawn Код:
CMD:ban(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 2) return Error(playerid, "You are not authorized to use this command");
    new giveplayerid, time, reason[64], string[128];
    if(sscanf(params, "uis[64]", giveplayerid, time, reason)) return Syntax(playerid, "ban", "[playerid] [time(days) 0 = perm] [reason]");
    if(!IsPlayerConnected(giveplayerid)) return Error(playerid, "Invalid player specified!");
    if(playerid == giveplayerid) return Error(playerid, "You cannot ban youself.");
    if(PlayerInfo[playerid][pAdmin] < PlayerInfo[giveplayerid][pAdmin]) return Error(playerid, "You cannot ban a equal or higher level admin.");
    BanPlayer(playerid, giveplayerid, time, reason);
    format(string, sizeof(string), "AdmCmd: %s was banned by %s for %s, reason: %s ", GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), time, reason);
    Log("logs/ban.log", string);
    return 1;
}
Thanks
Reply
#2

Well, it would be really helpful if you'd show us "BanPlayer" function code.
Reply
#3

Show us BanPlayer function maybe?
Reply
#4

Cant find it
Reply
#5

i only found this
pawn Код:
stock BanPlayer(playerid, giveplayerid, time, reason[])
{
    new name[24], namegive[24];
    if(playerid == 501) format(name, sizeof(name), "Squidward (Anti-Cheat)");
    else GetPlayerName(playerid, name, sizeof(name));
    GetPlayerName(giveplayerid, namegive, sizeof(namegive));
    new curtime = gettime();
    new expire;
    if(!time)
    {
        expire = 1577836800;
    }
    else
    {
        new Float:banminutes = time * 24 * 60 * 60;
        new bantime = floatround(banminutes);
        expire = curtime + bantime;
    }
    new q[400];
    new ip[16];
    GetPlayerIp(giveplayerid, ip, sizeof(ip));
    //AddBan(ip);
    format(q, sizeof(q), "INSERT INTO bans (name, reason, ban_time, issue_time, expiry_time, admin, ip) VALUES ('%s', '%s', %d, %d, %d, '%s', '%s')", namegive, reason, time, curtime, expire, name, ip);


    new string[128];
    if(time)
    format(STRING, "AdmCmd: %s was banned for %d days by %s: %s", GetPlayerNameEx(giveplayerid), time, GetPlayerNameEx(playerid), reason);
    else
    format(STRING, "AdmCmd: %s was banned permanently by %s: %s", GetPlayerNameEx(giveplayerid), name, reason);
    SendClientMessageToAllEx(COLOR_LIGHTRED, string);
    if(time)
    format(STRING, "You were banned by Admin %s for %d days: %s", GetPlayerNameEx(playerid), time, reason);
    else
    format(STRING, "You were banned permanently by Admin %s: %s", name, reason);
    SendClientMessage(giveplayerid, 0x00FF00FF, string);
    new dialogstring[512];
   
    ShowPlayerDialog(giveplayerid, 4564, DIALOG_STYLE_MSGBOX, "Banned!", dialogstring, "Close", "");
    Kick(giveplayerid);
    return 1;
}
Reply
#6

Just do Ban(giveplayerid);
pawn Код:
CMD:ban(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 2) return Error(playerid, "You are not authorized to use this command");
    new giveplayerid, time, reason[64], string[128];
    if(sscanf(params, "uis[64]", giveplayerid, time, reason)) return Syntax(playerid, "ban", "[playerid] [time(days) 0 = perm] [reason]");
    if(!IsPlayerConnected(giveplayerid)) return Error(playerid, "Invalid player specified!");
    if(playerid == giveplayerid) return Error(playerid, "You cannot ban youself.");
    if(PlayerInfo[playerid][pAdmin] < PlayerInfo[giveplayerid][pAdmin]) return Error(playerid, "You cannot ban a equal or higher level admin.");
    BanPlayer(playerid, giveplayerid, time, reason);
    format(string, sizeof(string), "AdmCmd: %s was banned by %s for %s, reason: %s ", GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), time, reason);
    Log("logs/ban.log", string);
    Ban(giveplayerid);
    return 1;
}
Reply
#7

Quote:
Originally Posted by Drago987
Посмотреть сообщение
i only found this
pawn Код:
stock BanPlayer(playerid, giveplayerid, time, reason[])
{
    new name[24], namegive[24];
    if(playerid == 501) format(name, sizeof(name), "Squidward (Anti-Cheat)");
    else GetPlayerName(playerid, name, sizeof(name));
    GetPlayerName(giveplayerid, namegive, sizeof(namegive));
    new curtime = gettime();
    new expire;
    if(!time)
    {
        expire = 1577836800;
    }
    else
    {
        new Float:banminutes = time * 24 * 60 * 60;
        new bantime = floatround(banminutes);
        expire = curtime + bantime;
    }
    new q[400];
    new ip[16];
    GetPlayerIp(giveplayerid, ip, sizeof(ip));
    //AddBan(ip);
    format(q, sizeof(q), "INSERT INTO bans (name, reason, ban_time, issue_time, expiry_time, admin, ip) VALUES ('%s', '%s', %d, %d, %d, '%s', '%s')", namegive, reason, time, curtime, expire, name, ip);


    new string[128];
    if(time)
    format(STRING, "AdmCmd: %s was banned for %d days by %s: %s", GetPlayerNameEx(giveplayerid), time, GetPlayerNameEx(playerid), reason);
    else
    format(STRING, "AdmCmd: %s was banned permanently by %s: %s", GetPlayerNameEx(giveplayerid), name, reason);
    SendClientMessageToAllEx(COLOR_LIGHTRED, string);
    if(time)
    format(STRING, "You were banned by Admin %s for %d days: %s", GetPlayerNameEx(playerid), time, reason);
    else
    format(STRING, "You were banned permanently by Admin %s: %s", name, reason);
    SendClientMessage(giveplayerid, 0x00FF00FF, string);
    new dialogstring[512];
   
    ShowPlayerDialog(giveplayerid, 4564, DIALOG_STYLE_MSGBOX, "Banned!", dialogstring, "Close", "");
    Kick(giveplayerid);
    return 1;
}
replace this old code with this one

pawn Код:
stock BanPlayer(playerid, giveplayerid, time, reason[])
{
    new name[24], namegive[24];
    if(playerid == 501) format(name, sizeof(name), "Squidward (Anti-Cheat)");
    else GetPlayerName(playerid, name, sizeof(name));
    GetPlayerName(giveplayerid, namegive, sizeof(namegive));
    new curtime = gettime();
    new expire;
    if(!time)
    {
        expire = 1577836800;
    }
    else
    {
        new Float:banminutes = time * 24 * 60 * 60;
        new bantime = floatround(banminutes);
        expire = curtime + bantime;
    }
    new q[400];
    new ip[16];
    GetPlayerIp(giveplayerid, ip, sizeof(ip));
    //AddBan(ip);
    format(q, sizeof(q), "INSERT INTO bans (name, reason, ban_time, issue_time, expiry_time, admin, ip) VALUES ('%s', '%s', %d, %d, %d, '%s', '%s')", namegive, reason, time, curtime, expire, name, ip);


    new string[128];
    if(time)
    format(STRING, "AdmCmd: %s was banned for %d days by %s: %s", GetPlayerNameEx(giveplayerid), time, GetPlayerNameEx(playerid), reason);
    else
    format(STRING, "AdmCmd: %s was banned permanently by %s: %s", GetPlayerNameEx(giveplayerid), name, reason);
    SendClientMessageToAllEx(COLOR_LIGHTRED, string);
    if(time)
    format(STRING, "You were banned by Admin %s for %d days: %s", GetPlayerNameEx(playerid), time, reason);
    else
    format(STRING, "You were banned permanently by Admin %s: %s", name, reason);
    SendClientMessage(giveplayerid, 0x00FF00FF, string);
    new dialogstring[512];
   
    ShowPlayerDialog(giveplayerid, 4564, DIALOG_STYLE_MSGBOX, "Banned!", dialogstring, "Close", "");
    Ban(giveplayerid);
    return 1;
}
Reply
#8

You're kicking the player at the end of the function, not banning him however.
Quote:
Originally Posted by Drago987
Посмотреть сообщение
i only found this
pawn Код:
stock BanPlayer(playerid, giveplayerid, time, reason[])
{
    new name[24], namegive[24];
    if(playerid == 501) format(name, sizeof(name), "Squidward (Anti-Cheat)");
    else GetPlayerName(playerid, name, sizeof(name));
    GetPlayerName(giveplayerid, namegive, sizeof(namegive));
    new curtime = gettime();
    new expire;
    if(!time)
    {
        expire = 1577836800;
    }
    else
    {
        new Float:banminutes = time * 24 * 60 * 60;
        new bantime = floatround(banminutes);
        expire = curtime + bantime;
    }
    new q[400];
    new ip[16];
    GetPlayerIp(giveplayerid, ip, sizeof(ip));
    //AddBan(ip);
    format(q, sizeof(q), "INSERT INTO bans (name, reason, ban_time, issue_time, expiry_time, admin, ip) VALUES ('%s', '%s', %d, %d, %d, '%s', '%s')", namegive, reason, time, curtime, expire, name, ip);


    new string[128];
    if(time)
    format(STRING, "AdmCmd: %s was banned for %d days by %s: %s", GetPlayerNameEx(giveplayerid), time, GetPlayerNameEx(playerid), reason);
    else
    format(STRING, "AdmCmd: %s was banned permanently by %s: %s", GetPlayerNameEx(giveplayerid), name, reason);
    SendClientMessageToAllEx(COLOR_LIGHTRED, string);
    if(time)
    format(STRING, "You were banned by Admin %s for %d days: %s", GetPlayerNameEx(playerid), time, reason);
    else
    format(STRING, "You were banned permanently by Admin %s: %s", name, reason);
    SendClientMessage(giveplayerid, 0x00FF00FF, string);
    new dialogstring[512];
   
    ShowPlayerDialog(giveplayerid, 4564, DIALOG_STYLE_MSGBOX, "Banned!", dialogstring, "Close", "");
    Kick(giveplayerid); // <- should be Ban(giveplayerid);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)