fix ban function always returns false

global variables where not writable from inside the export function for some reason
This commit is contained in:
Developer-Bear
2021-08-03 12:43:52 -05:00
parent 9b2c4e3d12
commit 842c7c9301
+11 -11
View File
@@ -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