How could I make a timed ban system,
For instance… :InvokeServer(Target,'days',1)
-- Target: Target to ban,
-- 'days': TimeType this could be Days,Months,Minutes OR Perm
-- 1: The amount of TimeType... in this case 1-day.
How could I make a timed ban system,
For instance… :InvokeServer(Target,'days',1)
-- Target: Target to ban,
-- 'days': TimeType this could be Days,Months,Minutes OR Perm
-- 1: The amount of TimeType... in this case 1-day.
You can save the date and time that the player got banned and the duration. When they join the game again, you can do some simple math by adding the duration to the date they got banned and if it’s less than the current date, remove the ban.
I’d save the date that they should be unbanned. So for example: The date they would be unbanned if banned for 3 days would be tick() + 60 * 60 * 24 * 3. Save this in a datastore and get it when they join to determine if they’re banned.
you should use something like DateTime.now() and you should probably use seconds instead of milliseconds.
you can save the datastore as the Time they got banned+ban length
ban length can be in a table which can be converted using DateTime.fromUniversalTime(unpack(this).
or you can use the amount of seconds the ban or the exact time they will be unbanned will be which I highly recommend day of unban DateTime.fromUniversalTime(year,month,day,hour,seconds,milliseconds)