Hello everyone, My name Is Nehoray
Quick Question:
What is the best way to implement temp ban In Days
Thanks Everyone.
Hello everyone, My name Is Nehoray
Quick Question:
What is the best way to implement temp ban In Days
Thanks Everyone.
When you ban someone, save it to a DataStore with the time they were banned (os.clock) and the length of days (in seconds). Then have a server script constantly check the amount of seconds that have passed until it equals the amount of days in seconds.
Can you give me an example of How I should check the time
local function banUser(user, started, length)
-- stuff stuff and more stuff
DataStore:SetAsync(user.UserId, {start = started, length = length})
-- this saves a data store with a table that includes the ban information
-- in order for them to be kicked, you would have to do that on your own
end
local function getUser(user)
return DataStore:GetAsync(user.UserId) -- get the DataStore information
end
local function removeUser(user)
DataStore:RemoveAsync(user.UserId) -- delete their data store info
end
banUser(player, os.clock(), 86400) -- ban user for 1 day
while wait(360) do -- every 6 minutes, check this
local info = getUser(player) -- get the player's data store information
if (os.clock() - info.start) >= info.length then -- checks if the seconds that have passed is greater than the length of the ban
removeUser(player) -- unban them
end
end
This code is just for an example