diff --git a/server/functions.lua b/server/functions.lua index 8c667e3..63f6096 100644 --- a/server/functions.lua +++ b/server/functions.lua @@ -245,17 +245,17 @@ end QBCore.Functions.IsPlayerBanned = function (source) local retval = false local message = "" - exports['ghmattimysql']:execute('SELECT * FROM bans WHERE license=@license', {['@license'] = QBCore.Functions.GetIdentifier(source, 'license')}, function(result) - if result[1] ~= nil then - if os.time() < result[1].expire then - retval = true - local timeTable = os.date("*t", tonumber(result[1].expire)) - message = "You have been banned from the server:\n"..result[1].reason.."\nYour ban expires "..timeTable.day.. "/" .. timeTable.month .. "/" .. timeTable.year .. " " .. timeTable.hour.. ":" .. timeTable.min .. "\n" - else - exports['ghmattimysql']:execute('DELETE FROM bans WHERE id=@id', {['@id'] = result[1].id}) - end - end - end) + local result = exports.ghmattimysql:executeSync('SELECT * FROM bans WHERE license=@license', {['@license'] = QBCore.Functions.GetIdentifier(source, 'license')})[1] + + if result ~= nil then + if os.time() < result.expire then + retval = true + local timeTable = os.date("*t", tonumber(result.expire)) + message = "You have been banned from the server:\n"..result.reason.."\nYour ban expires "..timeTable.day.. "/" .. timeTable.month .. "/" .. timeTable.year .. " " .. timeTable.hour.. ":" .. timeTable.min .. "\n" + else + exports['ghmattimysql']:execute('DELETE FROM bans WHERE id=@id', {['@id'] = result.id}) + end + end return retval, message end