gettime bug?
#1

Hey there, my ban system is with gettime()

But when I log in game( I am banned for testing), it's says I can just log in.

Can someone help me with this problem?

The script when connecting:

pawn Код:
if (PlayerFile_Load(playerid) == 1)
    {
        // Check if the player is still banned
        if (APlayerData[playerid][BanTime] < gettime()) // Player ban-time is passed
        {
            ShowPlayerDialog(playerid, DialogLogin, DIALOG_STYLE_PASSWORD, TXT_DialogLoginTitle, TXT_DialogLoginMsg, TXT_DialogLoginButton1, TXT_DialogButtonCancel);
        }
        else // Player is still banned
        {
            ShowRemainingBanTime(playerid); // Show the remaining ban-time to the player is days, hours, minutes, seconds
        }
    }
    else
        ShowPlayerDialog(playerid, DialogRegister, DIALOG_STYLE_INPUT, TXT_DialogRegisterTitle, TXT_DialogRegisterMsg, TXT_DialogRegisterButton1, TXT_DialogButtonCancel);
ShowRemainingBanTime:
pawn Код:
// This function shows the player how long his ban still is when he tries to login (in days, hours, minutes, seconds)
ShowRemainingBanTime(playerid)
{
    // Setup local variables
    new TotalBanTime, Days, Hours, Minutes, Seconds, Msg[128];

    // Get the total ban-time
    TotalBanTime = APlayerData[playerid][BanTime] - gettime();

    // Calculate days
    if (TotalBanTime >= 86400)
    {
        Days = TotalBanTime / 86400;
        TotalBanTime = TotalBanTime - (Days * 86400);
    }
    // Calculate hours
    if (TotalBanTime >= 3600)
    {
        Hours = TotalBanTime / 3600;
        TotalBanTime = TotalBanTime - (Hours * 3600);
    }
    // Calculate minutes
    if (TotalBanTime >= 60)
    {
        Minutes = TotalBanTime / 60;
        TotalBanTime = TotalBanTime - (Minutes * 60);
    }
    // Calculate seconds
    Seconds = TotalBanTime;

    // Display the remaining ban-time for this player
    SendClientMessage(playerid, 0xFFFFFFFF, TXT_StillBanned);
    format(Msg, 128, TXT_BannedDuration, Days, Hours, Minutes, Seconds);
    SendClientMessage(playerid, 0xFFFFFFFF, Msg);
    Kick(playerid); // Kick the player
    print("ShowRemaining Bantime werkt.+ kick");
}

The funny thing is, is that when I replace, gettime with == 0), It works, but the time isn't correct, "-1736"
Reply
#2

Did you checked what the values are within the if check ?
pawn Код:
printf("%d < %d", APlayerData[playerid][BanTime], gettime());
Also in the ban command you save (gettime() + timeBannedInSec) in APlayerData[playerid][BanTime] ?
Reply
#3

Yes.

TotalBanTime = (Days * 86400) + (Hours * 3600) + gettime();
Reply
#4

Anyone else know the problem?
Reply
#5

Last bump
Reply
#6

did you already checked the values, does the values gets loaded ?
The best think is just to debug it out, also you check the values of everything related
Reply
#7

Yep, printed everything works all fine.
Reply
#8

Failed ignore this.
Reply
#9

Quote:
Originally Posted by SomebodyAndMe
Посмотреть сообщение
Yep, printed everything works all fine.
anything unexpected, was APlayerData[playerid][BanTime] bigger than gettime after you banned yourself ?
If everything works fine, why this topic...
Reply
#10

"The funny thing is, is that when I replace, gettime with == 0), It works, but the time isn't correct, "-1736"

replace gettime with 0 and rewrite ur caculation.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)