SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 03/08/2016, 12:09 PM   #1
Fantje
Huge Clucker
 
Join Date: Dec 2014
Posts: 393
Reputation: 9
Default Ban command is bugged

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

Where is the problem?

PHP Code:
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;

__________________
Fantje is offline   Reply With Quote
Old 03/08/2016, 12:15 PM   #2
oMa37
Gangsta
 
Join Date: Feb 2016
Posts: 928
Reputation: 156
Default Re: Ban command is bugged

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 Code:
//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.
oMa37 is offline   Reply With Quote
Old 03/08/2016, 12:17 PM   #3
Fantje
Huge Clucker
 
Join Date: Dec 2014
Posts: 393
Reputation: 9
Default Re: Ban command is bugged

Here:
PHP Code:
// 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.");
        }
    } 
__________________
Fantje is offline   Reply With Quote
Old 03/08/2016, 12:18 PM   #4
oMa37
Gangsta
 
Join Date: Feb 2016
Posts: 928
Reputation: 156
Default Re: Ban command is bugged

Yup, Just put it under OnPlayerConnect. it should work.
oMa37 is offline   Reply With Quote
Old 03/08/2016, 12:19 PM   #5
Fantje
Huge Clucker
 
Join Date: Dec 2014
Posts: 393
Reputation: 9
Default Re: Ban command is bugged

It is under OnPlayerConnect
__________________
Fantje is offline   Reply With Quote
Old 03/08/2016, 12:24 PM   #6
oMa37
Gangsta
 
Join Date: Feb 2016
Posts: 928
Reputation: 156
Default Re: Ban command is bugged

Nothing seems to be wrong, Does it print something in mysql_log.txt ?
oMa37 is offline   Reply With Quote
Old 03/08/2016, 12:24 PM   #7
Sew_Sumi
Banned
 
Join Date: Jun 2008
Location: Azerbaijan
Posts: 6,242
Reputation: 525
Default Re: Ban command is bugged

If this is part of a downloaded gamemode, you should be chasing up support there... Unless you messed around with it and broke it...
Sew_Sumi is offline   Reply With Quote
Old 03/08/2016, 12:34 PM   #8
Fantje
Huge Clucker
 
Join Date: Dec 2014
Posts: 393
Reputation: 9
Default Re: Ban command is bugged

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?
__________________
Fantje is offline   Reply With Quote
Old 03/08/2016, 12:37 PM   #9
Fantje
Huge Clucker
 
Join Date: Dec 2014
Posts: 393
Reputation: 9
Default Re: Ban command is bugged

Here is the problem:

PHP Code:
Dialog_Show(playeriddialogUnusedDIALOG_STYLE_MSGBOX"Notice"DIALOG"Close""");
            
DelayKick(playerid); 
It doesn't kick the player
__________________
Fantje is offline   Reply With Quote
Old 03/08/2016, 01:44 PM   #10
BoBiTza
Little Clucker
 
Join Date: Apr 2010
Location: Cluj-Napoca, Romania
Posts: 43
Reputation: 0
Default Re: Ban command is bugged

Go to function DelayKick and Kick(playerid); in some circumstation
BoBiTza is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Arrest command and Rape command bugged NoahF Scripting Help 8 07/07/2014 04:37 PM
Bugged command. lQs Scripting Help 2 28/05/2013 01:25 PM
Very bugged command hydravink Scripting Help 4 12/01/2013 05:17 PM
[Command Bugged] Each time i use /respawnallcars it says Unknown Command Rand_Omar Scripting Help 11 30/09/2012 12:35 AM
bugged /pm command Dark Crow Scripting Help 2 24/02/2012 08:46 PM


All times are GMT. The time now is 12:34 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.