Ban command is bugged
#1

When I ban someone, he can still join the server and login.

Where is the problem?

PHP код:
CMD:ban(playeridparams[])
{
    
LevelCheck(playerid1);
    new 
targetreason[35], days;
    if(
sscanf(params"is[35]I(0)"targetreasondays)) return Usage(playerid"ban [playerid] [reason] [days(0 for permanent ban)]");
    if(!
IsPlayerConnected(target)) return Error(playerid"The specified player is not connected, use /oban instead.");
    if(
target == playerid) return Error(playerid"You cannot ban yourself.");
    if(
GetLevel(playerid) < GetLevel(target)) return Error(playerid"You cannot use this command on higher level admin.");
    if(
days 0) return Error(playerid"Invalid days, must be greater than 0 for temp ban, or 0 for permanent ban.");
    if(
strlen(reason) < || strlen(reason) > 35) return Error(playerid"Invalid reason length, must be b/w 0-35 characters.");
    new 
bandate[18], date[3], time;
    
getdate(date[0], date[1], date[2]);
    
format(bandatesizeof(bandate), "%02i/%02i/%i"date[2], date[1], date[0]);
    if(
days == 0time 0;
    else 
time = ((days 24 60 60) + gettime());
    new 
handle SQL::Open(SQL::INSERT""BANS_TABLE"");
    
SQL::ToggleAutoIncrement(handletrue);
    
SQL::WriteString(handle"ban_username"GetName(target));
    
SQL::WriteString(handle"ban_ip"GetIP(target));
    
SQL::WriteString(handle"ban_by"GetName(playerid));
    
SQL::WriteString(handle"ban_on"bandate);
    
SQL::WriteString(handle"ban_reason"reason);
    
SQL::WriteInt(handle"ban_expire"time);
    
SQL::Close(handle);
    if(
days == 0)
    {
        new 
string[144];
        
format(stringsizeof(string), "* %s(%i) has been banned by Admin %s(%d) "orange"[Reason: %s]"GetName(target), targetGetName(playerid), playeridreason);
        
SendClientMessage(targetCOLOR_REDstring);
        
#if defined SAVE_LOGS
            
SaveLog("bans.txt"string);
        
#endif
    
}
    else
    {
        new 
string[258];
        
format(stringsizeof(string), "* %s(%i) has been temp banned by Admin %s(%d) "orange"[Reason: %s] [Days: %i]"GetName(target), targetGetName(playerid), playeridreasondays);
        
SendClientMessage(targetCOLOR_REDstring);
        
#if defined SAVE_LOGS
            
SaveLog("bans.txt"string);
        
#endif
        
format(stringsizeof(string), "* Temp banned for %i days "orange"[Unban on %s]"daysConvertTime(time));
        
SendClientMessage(targetCOLOR_REDstring);
    }
     
PlayerPlaySound(target10570.00.00.0);
    
PlayerPlaySound(playerid10570.00.00.0);
    
DelayKick(target);
    return 
1;

Reply
#2

I bet it's the ban system by SecretBoss. right?
Well, You have to check if the player banned OnPlayerConnect.
Either with his username, or IP:
PHP код:
//Check username
if(SQL::RowExistsEx(""BANS_TABLE"""ban_username"GetName(playerid)))

//Check IP
if(SQL::RowExistsEx(""BANS_TABLE"""ban_ip"GetIP(playerid))) 
take a look on the script you took this from and you will find what I mean under OnPlayerConnect.
Reply
#3

Here:
PHP код:
// Ban Checking system
    
new
        
string[6][24],
        
string2[156],
        
expire,
        
DIALOG[676]
    ;

    if(
SQL::RowExistsEx(""BANS_TABLE"""ban_username"GetName(playerid)))
    {
        new 
handle SQL::OpenEx(SQL::READ""BANS_TABLE"""ban_username"GetName(playerid));
        
SQL::ReadString(handle"ban_username"string[1], 24);
        
SQL::ReadString(handle"ban_ip"string[2], 24);
        
SQL::ReadString(handle"ban_by"string[3], 24);
        
SQL::ReadString(handle"ban_on"string[4], 24);
        
SQL::ReadString(handle"ban_reason"string[5], 24);
        
SQL::ReadInt(handle"ban_expire"expire);
        
SQL::Close(handle);

        if(
expire gettime() || expire == 0)
        {

            
strcat(DIALOG""white"Your account is banned from this server,\n\n");

            
format(string2sizeof(string2), ""white"Username: "red"%s\n"string[1]);
            
strcat(DIALOGstring2);

            
format(string2sizeof(string2), ""white"IP: "red"%s\n"string[2]);
            
strcat(DIALOGstring2);

            
format(string2sizeof(string2), ""white"Banned by: "red"%s\n"string[3]);
            
strcat(DIALOGstring2);

            
format(string2sizeof(string2), ""white"Reason: "red"%s\n"string[5]);
            
strcat(DIALOGstring2);

            
format(string2sizeof(string2), ""white"Ban date: "red"%s\n"string[4]);
            
strcat(DIALOGstring2);

            new 
expire2[68];
            if(
expire == 0expire2 "PERMANENT";
            else 
expire2 ConvertTime(expire);
            
format(string2sizeof(string2), ""white"Timeleft: "red"%s\n\n"expire2);
            
strcat(DIALOGstring2);

            
strcat(DIALOG""white"If you think that you got banned wrongfully, please make an appeal on our forums. Visit svt-reloaded.com\n");
            
strcat(DIALOG"Make sure you saved this box by pressing F8.");

            
Dialog_Show(playeriddialogUnusedDIALOG_STYLE_MSGBOX"Notice"DIALOG"Close""");
            
DelayKick(playerid);

            return 
true;
        }
        else
        {
            
SQL::DeleteRowEx(""BANS_TABLE"""ban_username"GetName(playerid));
            
Server(playerid"Your account's ban has expired.");
        }
    }

    else if(
SQL::RowExistsEx(""BANS_TABLE"""ban_ip"GetIP(playerid)))
    {
        new 
handle SQL::OpenEx(SQL::READ""BANS_TABLE"""ban_ip"GetIP(playerid));
        
SQL::ReadString(handle"ban_username"string[1], 24);
        
SQL::ReadString(handle"ban_ip"string[2], 24);
        
SQL::ReadString(handle"ban_by"string[3], 24);
        
SQL::ReadString(handle"ban_on"string[4], 24);
        
SQL::ReadString(handle"ban_reason"string[5], 24);
        
SQL::ReadInt(handle"ban_expire"expire);
        
SQL::Close(handle);

        if(
expire gettime() || expire == 0)
        {

            
strcat(DIALOG""white"Your IP is banned from this server,\n\n");

            
format(string2sizeof(string2), ""white"Username: "red"%s\n"string[1]);
            
strcat(DIALOGstring2);

            
format(string2sizeof(string2), ""white"IP: "red"%s\n"string[2]);
            
strcat(DIALOGstring2);

            
format(string2sizeof(string2), ""white"Banned by: "red"%s\n"string[3]);
            
strcat(DIALOGstring2);

            
format(string2sizeof(string2), ""white"Reason: "red"%s\n"string[5]);
            
strcat(DIALOGstring2);

            
format(string2sizeof(string2), ""white"Ban date: "red"%s\n"string[4]);
            
strcat(DIALOGstring2);

            new 
expire2[68];
            if(
expire == 0expire2 "PERMANENT";
            else 
expire2 ConvertTime(expire);
            
format(string2sizeof(string2), ""white"Timeleft: "red"%s\n\n"expire2);
            
strcat(DIALOGstring2);

            
strcat(DIALOG""white"If you think that you got banned wrongfully, please make an appeal on our forums. Visit svt-reloaded.\n");
            
strcat(DIALOG"Make sure you saved this box by pressing F8.");

            
Dialog_Show(playeriddialogUnusedDIALOG_STYLE_MSGBOX"Notice"DIALOG"Close""");
            
DelayKick(playerid);

            return 
true;
        }
        else
        {
            
SQL::DeleteRowEx(""BANS_TABLE"""ban_username"GetName(playerid));
            
Server(playerid"Your IP's ban has expired.");
        }
    } 
Reply
#4

Yup, Just put it under OnPlayerConnect. it should work.
Reply
#5

It is under OnPlayerConnect
Reply
#6

Nothing seems to be wrong, Does it print something in mysql_log.txt ?
Reply
#7

If this is part of a downloaded gamemode, you should be chasing up support there... Unless you messed around with it and broke it...
Reply
#8

The problem is: The ban updates into the database. But when I join I get the ban screen. When I press ok it will let me spawn but my stats will not load. So maybe make on response kick?
Reply
#9

Here is the problem:

PHP код:
Dialog_Show(playeriddialogUnusedDIALOG_STYLE_MSGBOX"Notice"DIALOG"Close""");
            
DelayKick(playerid); 
It doesn't kick the player
Reply
#10

Go to function DelayKick and Kick(playerid); in some circumstation
Reply


Forum Jump:


Users browsing this thread: