gettime bug? -
SomebodyAndMe - 27.05.2012
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"
AW: gettime bug? -
Nero_3D - 27.05.2012
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] ?
Re: gettime bug? -
SomebodyAndMe - 27.05.2012
Yes.
TotalBanTime = (Days * 86400) + (Hours * 3600) + gettime();
Re: gettime bug? -
SomebodyAndMe - 27.05.2012
Anyone else know the problem?
Re: gettime bug? -
SomebodyAndMe - 27.05.2012
Last bump
AW: gettime bug? -
Nero_3D - 27.05.2012
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
Re: gettime bug? -
SomebodyAndMe - 27.05.2012
Yep, printed everything works all fine.
Re: gettime bug? -
iggy1 - 27.05.2012
Failed ignore this.
AW: Re: gettime bug? -
Nero_3D - 27.05.2012
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...
Re: gettime bug? -
AdamCooper - 27.05.2012
"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.