Ban time seems to be returning incorrectly.
#1

I'm hosting my own server on my own PC, so the time is currently 04:13.

I /rtban the player for (2 HOURS), log back in and the time says I'll be unbanned at 05:14

pawn Код:
CMD:rtban(playerid, params[])
{
    if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");

    new reason[128], bantime,id,calc,string[256],hours1,player[24],days,query[512];
    if(AdminLevel[playerid] < 1) return SendClientMessage(playerid, COLOUR_GREY, "You are not authorized to use this command.");
    if(sscanf(params, "s[24]D(0)D(0)s[128]", player,hours1,days, reason)) return SendClientMessage(playerid, COLOUR_GREY, "Usage: /rtban [player name] [hours] [days] [reason] - Use an underscore otherwise it will not work.");
    if(days < 0 || days > 7) return SendClientMessage(playerid, COLOUR_GREY, "Days must be between 1 and 10.");
    if(hours1 < 0 || hours1 > 23) return SendClientMessage(playerid, COLOUR_GREY, "Hours must be between 1 and 23.");
    if(hours1 >= 1 && days >= 1) return SendClientMessage(playerid, COLOUR_GREY, "You can only select either Hours OR Days - Not both.");


    format(query, sizeof(query), "SELECT * FROM `accounts` WHERE `PlayerName` = '%s'", player);
    mysql_query(query); // No query line
    mysql_store_result(); // "Error nothing to store"
    printf("ID %d", id);
    new rows = mysql_num_rows();
    if(rows > 0)
    {
        if(days > 0)
        {
            calc =  86400 * days;
            bantime = calc + gettime();
            printf("BAN TIME %d", bantime);
            format(query, sizeof(query), "UPDATE `accounts` SET `BanTime` = %d WHERE `PlayerName` = '%s' LIMIT 1", bantime, player);
            mysql_query(query);
            format(string, sizeof(string), "Admin %s Banned %s until %s - %d Day(s) [Reason: %s]", GetNameEx(playerid), player, date(bantime,4), days, reason);
            SendClientMessageToAll(COLOUR_REALRED, string);
        }
        if(hours1 > 0)
        {
            calc = 3600 * hours1;
            bantime = calc + gettime();
            format(query, sizeof(query), "UPDATE `accounts` SET `BanTime` = %d WHERE `PlayerName` = '%s' LIMIT 1", bantime, player);
            mysql_query(query);
            format(string, sizeof(string), "Admin %s Banned %s for %d Hour(s) [Reason: %s]", GetNameEx(playerid), player, hours1, reason);
            SendClientMessageToAll(COLOUR_REALRED, string);
        }
        format(string, sizeof(string), "You have banned account (REMOTE) %s.", player);
        SendClientMessage(playerid, COLOUR_REALRED, string);
    }
    if(rows == 0)
        {
            SendClientMessage(playerid, COLOUR_GREY, "There are no accounts found with that name.");
        }
    mysql_free_result();
    return 1;
}
Does gettime return incorrectly?

Thanks.
Reply
#2

DELETE, RESOLVED.

FOR THOSE WHO ARE INTERESTED THE ISSUE WAS THIS:

A unix timestamp returns UTC, I am UTC + 1 and this was confusing me, the player will still be banned until the correct time, but it returns it incorrectly to the player because it uses UTC instead of their timezone so...


If I was banned at 4am for two hours, it will say my unban time is 5am <<<< THIS IS UTC
UTC TIME = 3am, so it is correct.
Reply
#3

You should just put the length of the ban, not the time of unban.

Example:
You have 3 days, 13 hours, 43 minutes and 14 seconds remaining.
Reply
#4

What do you mean?
Reply
#5

Set MySQL timezone to the one that server is set to.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)