Skip to content

Commit

Permalink
fix(server/functions): exploitban yield until ids inserted (#520)
Browse files Browse the repository at this point in the history
* fix(server/functions): exploitban yield until ids inserted

* refactor(server/functions): send more descriptive logging message for ban and kick
  • Loading branch information
solareon authored Aug 5, 2024
1 parent 422f918 commit ab5dd32
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions server/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -406,26 +406,25 @@ exports('GetCoreVersion', GetCoreVersion)
---@param origin string reason
local function ExploitBan(playerId, origin)
local name = GetPlayerName(playerId)
CreateThread(function()
local success, errorResult = storage.insertBan({
local success, errorResult = pcall(
storage.insertBan({
name = name,
license = GetPlayerIdentifierByType(playerId --[[@as string]], 'license2') or GetPlayerIdentifierByType(playerId --[[@as string]], 'license'),
discordId = GetPlayerIdentifierByType(playerId --[[@as string]], 'discord'),
ip = GetPlayerIdentifierByType(playerId --[[@as string]], 'ip'),
reason = origin,
expiration = 2147483647,
bannedBy = 'Anti Cheat'
})
assert(success, json.encode(errorResult))
end)
}))
if not success then lib.print.error(errorResult) end
DropPlayer(playerId --[[@as string]], locale('info.exploit_banned', serverConfig.discord))
logger.log({
source = 'qbx_core',
webhook = loggingConfig.webhook['anticheat'],
event = 'Anti-Cheat',
color = 'red',
tags = loggingConfig.role,
message = ('%s has been banned for exploiting %s'):format(name, origin)
message = success and ('%s has been kicked and banned for exploiting %s'):format(name, origin) or ('%s has been kicked for exploiting %s, ban insert failed'):format(name, origin)
})
end

Expand Down

0 comments on commit ab5dd32

Please sign in to comment.