SA-MP Forums Archive
Temp ban - strange bug. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Temp ban - strange bug. (/showthread.php?tid=293778)



Temp ban - strange bug. - Dokins - 29.10.2011

pawn Код:
CMD:tban(playerid, params[])
{
    if(LoggedIn[playerid] == 0) return SendClientMessage(playerid, COLOUR_GREY, "You must be logged in to use this command.");
    if(AdminLevel[playerid] < 1) return SendClientMessage(playerid, COLOUR_GREY, "You are not authorized to use this command.");
   
    new giveplayerid, hours, string[128], reason[128];
    if(sscanf(params, "uds[128]", giveplayerid, hours, reason)) return SendClientMessage(playerid, COLOUR_GREY, "Usage: /tban [player id or name] [hours] [reason]");
    if(hours < 1)return SendClientMessage(playerid, COLOUR_GREY, "Hours must be above 1.");
   
    format(string, sizeof(string), "You have been temporary banned for %d Hour(s).", hours);
    SendClientMessage(giveplayerid, COLOUR_LIGHTRED, string);
   
    format(string, sizeof(string), "Admin %s has Temp-Banned %s for [%d Hour(s)] [Reason: %s]", GetNameEx(playerid), GetNameEx(giveplayerid), hours, reason);
    SendClientMessageToAll(COLOUR_LIGHTRED, string);
    new unbantime = (hours * 60) + gettime();
    MySQL_SetInteger(PlayerSQLID[giveplayerid], "BanTime", unbantime, "Accounts");
    Kick(giveplayerid);
    return 1;
}
I cannot find anything wrong with this code, when I /tban myself for 1 hour, the mysql saves this: 1319921684, don't ask me why, thats why Iam asking you... strange, eh? it all works. and it even checks to see if theyre temp banned when connecting and kicks them, but imagine banning someone for 1 hour to find its over a million...


Re: Temp ban - strange bug. - Kyle_Olsen - 29.10.2011

It saves that because gettime returns a unix timestamp.

http://en.wikipedia.org/wiki/Unix_time


Re: Temp ban - strange bug. - Dokins - 29.10.2011

Yeah but, this confuses me completely, can you elaborate?


Re: Temp ban - strange bug. - selten98 - 29.10.2011

as far as i know. If you retrieve the time in unix timestamp it is. And make sure you save it as an hour later. You compare what you saved with what you have. you should be able to unban. As in the code i can see. Then if you get the if statement: if(BanTime == gettime) { unban stuff happens. } or something like that. If you use print_r(gettime()); you could also see what the gettime does. And how it works a bit.


Re: Temp ban - strange bug. - Norn - 30.10.2011

I'm not really experienced in this but I'm sure if you check this source you'll find out the issue.