31.08.2013, 21:19
Hey guys i'm having a problem with my temp ban system that checks if a player is banned or not. To be exact it more to do with the conversion of the unix timestamp to Day, Hours and Minutes but when it does it i basically use says.
12345 Days, 678 Hours, 4 minutes.
12345 Days, 678 Hours, 4 minutes.
pawn Код:
stock CheckAccountBan(playerid)
{
new bExpiration;
format(Query, sizeof(Query), "SELECT * FROM `server_bans` WHERE (Username = '%s' OR IpAddress = '%s') AND status = 1", GetPName(playerid), GetIP(playerid));
mysql_query(Query);
mysql_store_result();
if(mysql_num_rows() >= 1)
{
new bReason[126], bannedBy[MAX_PLAYER_NAME];
while(mysql_fetch_row_format(Query,"|"))
{
mysql_fetch_field_row(bReason, "Reason");
mysql_fetch_field_row(bannedBy, "BannedBy");
mysql_fetch_field_row(Query, "Expiration"); bExpiration = strval(Query);
if(bExpiration > 0)
{
if(gettime() >= bExpiration)
{
format(Query, sizeof(Query), "UPDATE `server_bans` SET Status = 0 WHERE Username = %s", GetPName(playerid));
mysql_query(Query);
new string[100];
format(string,sizeof(string),"{FFFFFF}You've been unbanned from the server \nAccount Name:{33C9CC}%s{FFFFFF}\nPlease login to continue.",GetPName(playerid));
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Account Login",string,"Login","");
}
else
{
new days,hours,minutes,time;
time = bExpiration-gettime()/3600;
while (time >= 86400)
{
days++;
time-=86400;
}
while(time >= 3600)
{
hours++;
time-=3600;
}
while(time >= 60)
{
minutes++;
time-=60;
}
new string[300];
format(string, sizeof(string), "{FFFFFF}You are banned from this server\n\n{0094BD}Reason: {FFFFFF}%s\n\n{0094BD}Banned By: {FFFFFF}%s\n{0094BD}Unbanned in: {FFFFFF}%d Hours - %d Minutes - %d Seconds", bReason, bannedBy,days, hours, minutes);
ShowPlayerDialog(playerid, DIALOG_BANNED, DIALOG_STYLE_MSGBOX, "Banned", string, "Close", "");
print("Banned player joined the server");
}
} else {
new string[300];
format(string, sizeof(string), "{FFFFFF}You are banned from this server\n\n{0094BD}Reason: {FFFFFF}%s\n\n{0094BD}Banned By: {FFFFFF}%s", bReason, bannedBy);
ShowPlayerDialog(playerid, DIALOG_BANNED, DIALOG_STYLE_MSGBOX, "Banned", string, "Close", "");
}
}
return 1;
}
return 0;
}