[Cs:s] Ban Counter
Posted: Fri Feb 12, 2021 4:47 pm
Hi, i have small issue with my ban counter code. I want to show weeks/days/hours/minutes.
This code suppose to count remaining ban, but i can't solve count correctly.
For example if you ban for 4weeks and some times goes, it shows 3.94 Week(s) as remaing timeleft.
But i want it shows weeks and days of remaining time instead 3.94
This code suppose to count remaining ban, but i can't solve count correctly.
For example if you ban for 4weeks and some times goes, it shows 3.94 Week(s) as remaing timeleft.
But i want it shows weeks and days of remaining time instead 3.94
Syntax: Select all
def ban_counter(timeleft):
if timeleft < 0:
return '0 Seconds'
elif timeleft < 60:
stime = '%.2f' % (timeleft)
return '%s Second(s)' % (stime)
elif timeleft < 3600:
minute = timeleft / 60
mins = '%.2f' % (minute)
return '%s Minute(s)' % (mins)
elif timeleft < 86400:
hours = timeleft / 60 / 60
d_hours = '%.2f' % (hours)
return '%s Hour(s)' % (d_hours)
elif timeleft < 604800:
days = timeleft / 60 / 24 / 60
s_day = '%.2f' % (days)
return '%s Day(s)' % (s_day)
elif timeleft < 2419200:
week = timeleft / 60 / 24 / 60 / 7
weeks = '%.2f' % (week)
return '%s Week(s)' % (weeks)
else:
return '%s Second(s)' % (timeleft)