MySQL ban status does not set to 0? Help!
#1

Hey guys,

I made a new ban system, and decided to make a tempban aswell. The ban works, but after the persons ban finishes. He is supposed to be unban (Meaning the Ban Status should set to 0 automatically)

Here is my checkban stock which checks if the players ban time has ran out.

pawn Код:
stock CheckBan(playerid)
{
    new query[900], bExpiration, bID, IP[16];

    GetPlayerIp(playerid, IP, sizeof(IP));

    format(query,sizeof(query),"SELECT * FROM bans WHERE (Name  = '%s' OR IP = '%s') AND Status = '1'", GetName(playerid), IP );
    mysql_query(query);

    mysql_store_result();
    if(mysql_num_rows() >= 1)
    {
        new bReason[128], bannedBy[MAX_PLAYER_NAME], Name[MAX_PLAYER_NAME], Dialog[900], IP1[16];
        while(mysql_fetch_row_format(query,"|"))
        {
            mysql_fetch_field_row(Name, "Name");
            mysql_fetch_field_row(bReason, "Reason");
            mysql_fetch_field_row(bannedBy, "BannedBy");
            mysql_fetch_field_row(IP1, "IP");
            mysql_fetch_field_row(query, "bID"); bID = strval(query);
            mysql_fetch_field_row(query, "Expiration"); bExpiration = strval(query);

            if(bExpiration > 0)
            {
                if(gettime() >= bExpiration)
                {
                    format(query, sizeof(query), "UPDATE bans SET Status = 0 WHERE bID = %d", bID);
                    mysql_query(query);
                }
                else
                {
                    format(Dialog, sizeof(Dialog), "{FF0000}You are banned from this server! Ban details:\n\n{FF0000}Name:{FFFFFF} %s \n{FF0000}IP:{FFFFFF} %s\n{FF0000}Reason:{FFFFFF} %s \n{FF0000}Banned By:{FFFFFF} %s\n\n{FF0000}You will be unbanned in %d hours!\n\n{FF0000}If you think this ban is unfair, you can apply for an unban appeal at our forums\n{FF0000}Note - We do not unban hackers, or people who lie in their appeal", Name, IP1, bReason, bannedBy, (bExpiration-gettime())/3600);
                    ShowPlayerDialog(playerid, DIALOG_BAN, DIALOG_STYLE_MSGBOX, "{FF0000}Banned!", Dialog, "Close", "");
                }
            }
            else
            {
                format(Dialog, sizeof(Dialog), "{FF0000}You are banned from this server! Ban details:\n\n{FF0000}Name:{FFFFFF} %s \n{FF0000}IP:{FFFFFF} %s\n{FF0000}Reason:{FFFFFF} %s \n{FF0000}Banned By:{FFFFFF} %s\n\n{FF0000}If you think this ban is unfair, you can apply for an unban appeal at our forums\n{FF0000}Note - We do not unban hackers, or people who lie in their appeal", Name, IP1, bReason, bannedBy);
                ShowPlayerDialog(playerid, DIALOG_BAN, DIALOG_STYLE_MSGBOX, "{FF0000}Banned!", Dialog, "Close", "");
            }
        }
        return 1;
    }
    mysql_free_result();
    return 0;
}
See here, after the ban time runs out, it is supposed to set the Ban Status to 0 meaning the player is unbanned, but it is not doing that..

pawn Код:
if(bExpiration > 0)
            {
                if(gettime() >= bExpiration)
                {
                    format(query, sizeof(query), "UPDATE bans SET Status = 0 WHERE bID = %d", bID);
                    mysql_query(query);
                }
                else
                {
                    format(Dialog, sizeof(Dialog), "{FF0000}You are banned from this server! Ban details:\n\n{FF0000}Name:{FFFFFF} %s \n{FF0000}IP:{FFFFFF} %s\n{FF0000}Reason:{FFFFFF} %s \n{FF0000}Banned By:{FFFFFF} %s\n\n{FF0000}You will be unbanned in %d hours!\n\n{FF0000}If you think this ban is unfair, you can apply for an unban appeal at our forums\n{FF0000}Note - We do not unban hackers, or people who lie in their appeal", Name, IP1, bReason, bannedBy, (bExpiration-gettime())/3600);
                    ShowPlayerDialog(playerid, DIALOG_BAN, DIALOG_STYLE_MSGBOX, "{FF0000}Banned!", Dialog, "Close", "");
                }
            }
            else
            {
                format(Dialog, sizeof(Dialog), "{FF0000}You are banned from this server! Ban details:\n\n{FF0000}Name:{FFFFFF} %s \n{FF0000}IP:{FFFFFF} %s\n{FF0000}Reason:{FFFFFF} %s \n{FF0000}Banned By:{FFFFFF} %s\n\n{FF0000}If you think this ban is unfair, you can apply for an unban appeal at our forums\n{FF0000}Note - We do not unban hackers, or people who lie in their appeal", Name, IP1, bReason, bannedBy);
                ShowPlayerDialog(playerid, DIALOG_BAN, DIALOG_STYLE_MSGBOX, "{FF0000}Banned!", Dialog, "Close", "");
            }
I don't see anything wrong in the script, but it is not unbanning me. I really hope you can help me through this tough situation.

Thanks
Reply
#2

Help!
Reply
#3

Check your mysql debug logs.

I think:
Quote:

UPDATE bans SET Status = 0 WHERE bID = %d

must be:
Quote:

UPDATE bans SET Status = 0 WHERE bID = '%d'

Reply
#4

Quote:
Originally Posted by Darth1993
Посмотреть сообщение
Check your mysql debug logs.

I think:

must be:
what about the Status = 0 should the 0 be in ' '?
Reply
#5

0 is not a variable, so no.

Or maybe I'm wrong, who knows.
Reply
#6

Can someone help me?
Reply
#7

Check in OnPlayerConnect if the expiration has been ended and if it is, set ban status to 0 for that user.

@Darth1993
- Don't post at all if you don't know how to use MySQL..
Reply
#8

It's already in the stock...
Reply
#9

Im not sure if this works. but give it a try

Code
pawn Код:
stock CheckBan(playerid)
{
    new
        query[900],
        bExpiration,
        bID,
        IP[16],
        bReason[128],
        bannedBy[MAX_PLAYER_NAME],
        Name[MAX_PLAYER_NAME],
        Dialog[900],
        IP1[16]
    ;
    GetPlayerIp(playerid, IP, sizeof(IP));

    format(query,sizeof(query),"SELECT * FROM `bans` WHERE (`Name`  = '%s' OR `IP` = '%s') AND Status = '1' LIMIT 1", GetName(playerid), IP );
    mysql_query(query);

    mysql_store_result();
    if(mysql_num_rows() != 0) //instead of == 1
    {
        while(mysql_fetch_row_format(query,"|"))
        {
            mysql_fetch_field_row(Name, "Name");
            mysql_fetch_field_row(bReason, "Reason");
            mysql_fetch_field_row(bannedBy, "BannedBy");
            mysql_fetch_field_row(IP1, "IP");
            mysql_fetch_field_row(query, "bID"); bID = strval(query);
            mysql_fetch_field_row(query, "Expiration"); bExpiration = strval(query);

            if(bExpiration == 0) //instead of >
            {
                if(gettime() == bExpiration) //instead of >=
                {
                    format(query, sizeof(query), "UPDATE bans SET Status = 0 WHERE bID = %d", bID);
                    mysql_query(query);
                } else {
                    format(Dialog, sizeof(Dialog), "{FF0000}You are banned from this server! Ban details:\n\n{FF0000}Name:{FFFFFF} %s \n{FF0000}IP:{FFFFFF} %s\n{FF0000}Reason:{FFFFFF} %s \n{FF0000}Banned By:{FFFFFF} %s\n\n{FF0000}You will be unbanned in %d hours!\n\n{FF0000}If you think this ban is unfair, you can apply for an unban appeal at our forums\n{FF0000}Note - We do not unban hackers, or people who lie in their appeal", Name, IP1, bReason, bannedBy, (bExpiration-gettime())/3600);
                    ShowPlayerDialog(playerid, DIALOG_BAN, DIALOG_STYLE_MSGBOX, "{FF0000}Banned!", Dialog, "Close", "");
                }
            } else {
                format(Dialog, sizeof(Dialog), "{FF0000}You are banned from this server! Ban details:\n\n{FF0000}Name:{FFFFFF} %s \n{FF0000}IP:{FFFFFF} %s\n{FF0000}Reason:{FFFFFF} %s \n{FF0000}Banned By:{FFFFFF} %s\n\n{FF0000}If you think this ban is unfair, you can apply for an unban appeal at our forums\n{FF0000}Note - We do not unban hackers, or people who lie in their appeal", Name, IP1, bReason, bannedBy);
                ShowPlayerDialog(playerid, DIALOG_BAN, DIALOG_STYLE_MSGBOX, "{FF0000}Banned!", Dialog, "Close", "");
            }
        }
    }
    mysql_free_result();
    return 1; //instead of return 0;
}
Reply
#10

still dont work

Help!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)