Skip to content

Commit

Permalink
fix(server/functions): ban checking when no license2
Browse files Browse the repository at this point in the history
* fix(server/functions): ban checking when no license2

* fix: typo

* Update functions.lua

* fix(server/function): only delete license2 ban if license2 present

* Update functions.lua

---------

Co-authored-by: Solareon <[email protected]>
  • Loading branch information
mafewtm and solareon authored Aug 13, 2024
1 parent e785b5f commit e3a5579
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions server/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -332,29 +332,30 @@ exports('ToggleOptin', ToggleOptin)
---@return boolean
---@return string? playerMessage
function IsPlayerBanned(source)
local plicense = GetPlayerIdentifierByType(source --[[@as string]], 'license2')
local result = storage.fetchBan({
license = plicense
})
local license = GetPlayerIdentifierByType(source --[[@as string]], 'license')
local license2 = GetPlayerIdentifierByType(source --[[@as string]], 'license2')
local result = license2 and storage.fetchBan({ license = license2 })

if not result then
plicense = GetPlayerIdentifierByType(source --[[@as string]], 'license')
result = storage.fetchBan({
license = plicense
})
result = storage.fetchBan({ license = license })
end

if not result then return false end

if os.time() < result.expire then
local timeTable = os.date('*t', tonumber(result.expire))

return true, ('You have been banned from the server:\n%s\nYour ban expires in %s/%s/%s %s:%s\n'):format(result.reason, timeTable.day, timeTable.month, timeTable.year, timeTable.hour, timeTable.min)
else
CreateThread(function()
storage.deleteBan({
license = plicense
})
if license2 then
storage.deleteBan({ license = license2 })
end

storage.deleteBan({ license = license })
end)
end

return false
end

Expand Down

0 comments on commit e3a5579

Please sign in to comment.