The bans thing is more of an example for a bigger thing im trying to do.
Is there a way to determine the time passed for a ban? So like on a set date remove the “set ban” from a table.
The bans thing is more of an example for a bigger thing im trying to do.
Is there a way to determine the time passed for a ban? So like on a set date remove the “set ban” from a table.
Yeah that wouldn’t be too difficult.
First you’ll obviously want to save the time and date any given player was banned.
Next, test on the server everytime a player joins the game to see if they’re currently banned.
If they are currently banned, get the difference between the datetime of the ban, and the current datetime.
If it’s above the threshhold you like, unban them, if it isn’t kick them.
You can save the time you want the ban to last in a datastore. (using UNIX time) then just check when the player joins whatever time rn is higher than the saved one. If so remove the ban.
For more information on UNIX time stamps and getting the difference between dates, refer to this link.
Besides dates, is saving os.time() and then the bantime, comparing the two an option aswell.
I feel like thats similar to unix time
Whatever that suits for you is your option.
Yes, that would also work, however you should keep in mind that os.time()
is deprecated, and the newer DateTime
methods will be in service longer.
you can use tick.
store the tick as the ban takes place then everytime that player joins compare the tick of the ban to the current tick and if the difference equals a specific number then unban them
So using the not deprecated one
-- for saving
local amount = 3*3600 - three hours.
local endtime = DateTime.now().UnixTimestamp + amount
--then check on joined
if DateTime.now().UnixTimestamp >= endtime then
print 'Unbanned'
else
print 'Banned'
end