diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a42332d..369c61a 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -9,7 +9,7 @@ jobs: with: ref: ${{ github.event.pull_request.head.sha }} - name: Lint - uses: iLLeniumStudios/fivem-lua-lint-action@v1.0.11 + uses: iLLeniumStudios/fivem-lua-lint-action@v2 with: capture: "junit.xml" args: "-t --formatter JUnit" diff --git a/README.md b/README.md index b0e11be..e26ab95 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,10 @@ ### [Official QBCore Documentation](https://qbcore-framework.github.io/qb-docs/) +## Jet Brains Open Source Community Member +* [Click here for more info](https://www.jetbrains.com/community/opensource/#support) + +![imageedit_1_7437031978](https://user-images.githubusercontent.com/57848836/169108129-5bc5e78c-d8ae-464d-bb86-42451685ca1a.png) ## QBCore is officially partnered with Sonoran Software! Sonoran Software offers: diff --git a/client/drawtext.lua b/client/drawtext.lua index ef669b2..2f3280b 100644 --- a/client/drawtext.lua +++ b/client/drawtext.lua @@ -5,7 +5,7 @@ local function hideText() end local function drawText(text, position) - if not type(position) == "string" then position = "left" end + if type(position) ~= "string" then position = "left" end SendNUIMessage({ action = 'DRAW_TEXT', @@ -17,7 +17,7 @@ local function drawText(text, position) end local function changeText(text, position) - if not type(position) == "string" then position = "left" end + if type(position) ~= "string" then position = "left" end SendNUIMessage({ action = 'CHANGE_TEXT', diff --git a/client/events.lua b/client/events.lua index df2adec..6ed07e4 100644 --- a/client/events.lua +++ b/client/events.lua @@ -127,7 +127,7 @@ RegisterNetEvent('QBCore:Command:SpawnVehicle', function(vehName) Wait(0) end - if IsPedInAnyVehicle(ped) then + if IsPedInAnyVehicle(ped) then DeleteVehicle(veh) end @@ -147,7 +147,7 @@ RegisterNetEvent('QBCore:Command:DeleteVehicle', function() else local pcoords = GetEntityCoords(ped) local vehicles = GetGamePool('CVehicle') - for k, v in pairs(vehicles) do + for _, v in pairs(vehicles) do if #(pcoords - GetEntityCoords(v)) <= 5.0 then SetEntityAsMissionEntity(v, true, true) DeleteVehicle(v) diff --git a/client/functions.lua b/client/functions.lua index 75e937b..7e72c50 100644 --- a/client/functions.lua +++ b/client/functions.lua @@ -186,7 +186,7 @@ function QBCore.Functions.GetClosestPed(coords, ignoreList) else coords = GetEntityCoords(ped) end - local ignoreList = ignoreList or {} + ignoreList = ignoreList or {} local peds = QBCore.Functions.GetPeds(ignoreList) local closestDistance = -1 local closestPed = -1 @@ -407,12 +407,12 @@ function QBCore.Functions.GetVehicleProperties(vehicle) local colorPrimary, colorSecondary = GetVehicleColours(vehicle) if GetIsVehiclePrimaryColourCustom(vehicle) then - r, g, b = GetVehicleCustomPrimaryColour(vehicle) + local r, g, b = GetVehicleCustomPrimaryColour(vehicle) colorPrimary = {r, g, b} end if GetIsVehicleSecondaryColourCustom(vehicle) then - r, g, b = GetVehicleCustomSecondaryColour(vehicle) + local r, g, b = GetVehicleCustomSecondaryColour(vehicle) colorSecondary = {r, g, b} end diff --git a/client/loops.lua b/client/loops.lua index 62b0f5d..925e588 100644 --- a/client/loops.lua +++ b/client/loops.lua @@ -12,7 +12,7 @@ end) CreateThread(function() while true do if LocalPlayer.state.isLoggedIn then - if (QBCore.PlayerData.metadata['hunger'] <= 0 or QBCore.PlayerData.metadata['thirst'] <= 0) and not QBCore.PlayerData.metadata['isdead'] then + if (QBCore.PlayerData.metadata['hunger'] <= 0 or QBCore.PlayerData.metadata['thirst'] <= 0) and not QBCore.PlayerData.metadata['isdead'] then local ped = PlayerPedId() local currentHealth = GetEntityHealth(ped) local decreaseTreshold = math.random(5, 10) diff --git a/client/main.lua b/client/main.lua index efa365b..80f9157 100644 --- a/client/main.lua +++ b/client/main.lua @@ -10,4 +10,4 @@ end) -- To use this export in a script instead of manifest method -- Just put this line of code below at the very top of the script --- local QBCore = exports['qb-core']:GetCoreObject() \ No newline at end of file +-- local QBCore = exports['qb-core']:GetCoreObject() diff --git a/locale/fr.lua b/locale/fr.lua index 57dcaa2..f072789 100644 --- a/locale/fr.lua +++ b/locale/fr.lua @@ -29,4 +29,4 @@ local Translations = { Lang = Locale:new({ phrases = Translations, warnOnMissing = true -}) +}) diff --git a/server/commands.lua b/server/commands.lua index 125a1ea..e9aacf0 100644 --- a/server/commands.lua +++ b/server/commands.lua @@ -6,7 +6,7 @@ QBCore.Commands.IgnoreList = { -- Ignore old perm levels while keeping backwards } CreateThread(function() -- Add ace to node for perm checking - for k,v in pairs(QBConfig.Server.Permissions) do + for _, v in pairs(QBConfig.Server.Permissions) do ExecuteCommand(('add_ace qbcore.%s %s allow'):format(v, v)) end end) @@ -224,7 +224,7 @@ QBCore.Commands.Add('ooc', 'OOC Chat Message', {}, false, function(source, args) local Players = QBCore.Functions.GetPlayers() local Player = QBCore.Functions.GetPlayer(source) local playerCoords = GetEntityCoords(GetPlayerPed(source)) - for k, v in pairs(Players) do + for _, v in pairs(Players) do if v == source then TriggerClientEvent('chat:addMessage', v, { color = { 0, 0, 255}, diff --git a/server/debug.lua b/server/debug.lua index 7a8a9cf..9b4b3b2 100644 --- a/server/debug.lua +++ b/server/debug.lua @@ -42,4 +42,4 @@ end function QBCore.ShowSuccess(resource, msg) print('\x1b[32m['..resource..':LOG]\x1b[0m '..msg) -end \ No newline at end of file +end diff --git a/server/events.lua b/server/events.lua index 65d3268..266dfa5 100644 --- a/server/events.lua +++ b/server/events.lua @@ -1,17 +1,17 @@ -- Event Handler -AddEventHandler('chatMessage', function(source, _, message) +AddEventHandler('chatMessage', function(_, _, message) if string.sub(message, 1, 1) == '/' then CancelEvent() return end end) -AddEventHandler('playerDropped', function() +AddEventHandler('playerDropped', function(reason) local src = source if not QBCore.Players[src] then return end local Player = QBCore.Players[src] - TriggerEvent('qb-log:server:CreateLog', 'joinleave', 'Dropped', 'red', '**' .. GetPlayerName(src) .. '** (' .. Player.PlayerData.license .. ') left..') + TriggerEvent('qb-log:server:CreateLog', 'joinleave', 'Dropped', 'red', '**' .. GetPlayerName(src) .. '** (' .. Player.PlayerData.license .. ') left..' ..'\n **Reason:** ' .. reason) Player.Functions.Save() QBCore.Player_Buckets[Player.PlayerData.license] = nil QBCore.Players[src] = nil @@ -57,13 +57,13 @@ local function onPlayerConnecting(name, setKickReason, deferrals) deferrals.update(string.format(Lang:t('info.join_server'), name)) if not license then - deferrals.done(Lang:t('error.no_valid_license')) + deferrals.done(Lang:t('error.no_valid_license')) elseif isBanned then deferrals.done(Reason) elseif isLicenseAlreadyInUse and QBCore.Config.Server.CheckDuplicateLicense then deferrals.done(Lang:t('error.duplicate_license')) elseif isWhitelist and not whitelisted then - deferrals.done(Lang:t('error.not_whitelisted')) + deferrals.done(Lang:t('error.not_whitelisted')) else deferrals.done() if QBCore.Config.Server.UseConnectQueue then @@ -207,52 +207,32 @@ QBCore.Functions.CreateCallback('QBCore:HasItem', function(source, cb, items, am local retval = false local Player = QBCore.Functions.GetPlayer(source) if not Player then return cb(false) end - if type(items) == 'table' then - local count = 0 - local finalcount = 0 - for k, v in pairs(items) do - if type(k) == 'string' then - finalcount = 0 - for i, _ in pairs(items) do finalcount += 1 end - local item = Player.Functions.GetItemByName(k) - if item then - if item.amount >= v then - count += 1 - if count == finalcount then - retval = true - end - end - end - else - finalcount = #items - local item = Player.Functions.GetItemByName(v) - if item then - if amount then - if item.amount >= amount then - count += 1 - if count == finalcount then - retval = true - end - end - else - count += 1 - if count == finalcount then - retval = true - end - end - end + local isTable = type(items) == 'table' + local isArray = isTable and table.type(items) == 'array' or false + local totalItems = #items + local count = 0 + local kvIndex = 2 + if isTable and not isArray then + totalItems = 0 + for _ in pairs(items) do totalItems += 1 end + kvIndex = 1 + end + if isTable then + for k, v in pairs(items) do + local itemKV = {k, v} + local item = Player.Functions.GetItemByName(itemKV[kvIndex]) + if item and ((amount and item.amount >= amount) or (not amount and not isArray and item.amount >= v) or (not amount and isArray)) then + count += 1 end - end - else - local item = Player.Functions.GetItemByName(items) - if not item then return cb(false) end - if amount then - if item.amount >= amount then - retval = true - end - else + end + if count == totalItems then + retval = true + end + else -- Single item as string + local item = Player.Functions.GetItemByName(items) + if item and not amount or (amount and item.amount >= amount) then retval = true end - end + end cb(retval) end) diff --git a/server/functions.lua b/server/functions.lua index 95b302d..1b9b16f 100644 --- a/server/functions.lua +++ b/server/functions.lua @@ -63,7 +63,7 @@ end function QBCore.Functions.GetPlayers() local sources = {} - for k, v in pairs(QBCore.Players) do + for k, _ in pairs(QBCore.Players) do sources[#sources+1] = k end return sources @@ -137,7 +137,7 @@ end function QBCore.Functions.GetPlayersInBucket(bucket --[[ int ]]) local curr_bucket_pool = {} if QBCore.Player_Buckets and next(QBCore.Player_Buckets) then - for k, v in pairs(QBCore.Player_Buckets) do + for _, v in pairs(QBCore.Player_Buckets) do if v.bucket == bucket then curr_bucket_pool[#curr_bucket_pool + 1] = v.id end @@ -152,7 +152,7 @@ end function QBCore.Functions.GetEntitiesInBucket(bucket --[[ int ]]) local curr_bucket_pool = {} if QBCore.Entity_Buckets and next(QBCore.Entity_Buckets) then - for k, v in pairs(QBCore.Entity_Buckets) do + for _, v in pairs(QBCore.Entity_Buckets) do if v.bucket == bucket then curr_bucket_pool[#curr_bucket_pool + 1] = v.id end @@ -236,7 +236,7 @@ function QBCore.Functions.Kick(source, reason, setKickReason, deferrals) if source then DropPlayer(source, reason) end - for i = 0, 4 do + for _ = 0, 4 do while true do if source then if GetPlayerPing(source) >= 0 then @@ -279,7 +279,7 @@ function QBCore.Functions.RemovePermission(source, permission) QBCore.Commands.Refresh(src) end else - for k,v in pairs(QBCore.Config.Server.Permissions) do + for _, v in pairs(QBCore.Config.Server.Permissions) do if IsPlayerAceAllowed(src, v) then ExecuteCommand(('remove_principal identifier.%s qbcore.%s'):format(license, v)) QBCore.Commands.Refresh(src) @@ -299,7 +299,7 @@ end function QBCore.Functions.GetPermission(source) local src = source local perms = {} - for k,v in pairs (QBCore.Config.Server.Permissions) do + for _, v in pairs (QBCore.Config.Server.Permissions) do if IsPlayerAceAllowed(src, v) then perms[v] = true end @@ -328,13 +328,13 @@ end function QBCore.Functions.IsPlayerBanned(source) local plicense = QBCore.Functions.GetIdentifier(source, 'license') - local result = MySQL.Sync.fetchSingle('SELECT * FROM bans WHERE license = ?', { plicense }) + local result = MySQL.single.await('SELECT * FROM bans WHERE license = ?', { plicense }) 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' .. result.reason .. '\nYour ban expires ' .. timeTable.day .. '/' .. timeTable.month .. '/' .. timeTable.year .. ' ' .. timeTable.hour .. ':' .. timeTable.min .. '\n' else - MySQL.Async.execute('DELETE FROM bans WHERE id = ?', { result.id }) + MySQL.query('DELETE FROM bans WHERE id = ?', { result.id }) end return false end diff --git a/server/main.lua b/server/main.lua index 41c0c43..722e84b 100644 --- a/server/main.lua +++ b/server/main.lua @@ -10,4 +10,4 @@ end) -- To use this export in a script instead of manifest method -- Just put this line of code below at the very top of the script --- local QBCore = exports['qb-core']:GetCoreObject() \ No newline at end of file +-- local QBCore = exports['qb-core']:GetCoreObject() diff --git a/server/player.lua b/server/player.lua index 0b873d4..d14ca34 100644 --- a/server/player.lua +++ b/server/player.lua @@ -9,7 +9,7 @@ function QBCore.Player.Login(source, citizenid, newData) if source and source ~= '' then if citizenid then local license = QBCore.Functions.GetIdentifier(source, 'license') - local PlayerData = MySQL.Sync.prepare('SELECT * FROM players where citizenid = ?', { citizenid }) + local PlayerData = MySQL.prepare.await('SELECT * FROM players where citizenid = ?', { citizenid }) if PlayerData and license == PlayerData.license then PlayerData.money = json.decode(PlayerData.money) PlayerData.job = json.decode(PlayerData.job) @@ -238,9 +238,9 @@ function QBCore.Player.CreatePlayer(PlayerData) self.PlayerData.money[moneytype] = self.PlayerData.money[moneytype] + amount self.Functions.UpdatePlayerData() if amount > 100000 then - TriggerEvent('qb-log:server:CreateLog', 'playermoney', 'AddMoney', 'lightgreen', '**' .. GetPlayerName(self.PlayerData.source) .. ' (citizenid: ' .. self.PlayerData.citizenid .. ' | id: ' .. self.PlayerData.source .. ')** $' .. amount .. ' (' .. moneytype .. ') added, new ' .. moneytype .. ' balance: ' .. self.PlayerData.money[moneytype], true) + TriggerEvent('qb-log:server:CreateLog', 'playermoney', 'AddMoney', 'lightgreen', '**' .. GetPlayerName(self.PlayerData.source) .. ' (citizenid: ' .. self.PlayerData.citizenid .. ' | id: ' .. self.PlayerData.source .. ')** $' .. amount .. ' (' .. moneytype .. ') added, new ' .. moneytype .. ' balance: ' .. self.PlayerData.money[moneytype] .. ' reason: ' .. reason, true) else - TriggerEvent('qb-log:server:CreateLog', 'playermoney', 'AddMoney', 'lightgreen', '**' .. GetPlayerName(self.PlayerData.source) .. ' (citizenid: ' .. self.PlayerData.citizenid .. ' | id: ' .. self.PlayerData.source .. ')** $' .. amount .. ' (' .. moneytype .. ') added, new ' .. moneytype .. ' balance: ' .. self.PlayerData.money[moneytype]) + TriggerEvent('qb-log:server:CreateLog', 'playermoney', 'AddMoney', 'lightgreen', '**' .. GetPlayerName(self.PlayerData.source) .. ' (citizenid: ' .. self.PlayerData.citizenid .. ' | id: ' .. self.PlayerData.source .. ')** $' .. amount .. ' (' .. moneytype .. ') added, new ' .. moneytype .. ' balance: ' .. self.PlayerData.money[moneytype] .. ' reason: ' .. reason) end TriggerClientEvent('hud:client:OnMoneyChange', self.PlayerData.source, moneytype, amount, false) return true @@ -262,9 +262,9 @@ function QBCore.Player.CreatePlayer(PlayerData) self.PlayerData.money[moneytype] = self.PlayerData.money[moneytype] - amount self.Functions.UpdatePlayerData() if amount > 100000 then - TriggerEvent('qb-log:server:CreateLog', 'playermoney', 'RemoveMoney', 'red', '**' .. GetPlayerName(self.PlayerData.source) .. ' (citizenid: ' .. self.PlayerData.citizenid .. ' | id: ' .. self.PlayerData.source .. ')** $' .. amount .. ' (' .. moneytype .. ') removed, new ' .. moneytype .. ' balance: ' .. self.PlayerData.money[moneytype], true) + TriggerEvent('qb-log:server:CreateLog', 'playermoney', 'RemoveMoney', 'red', '**' .. GetPlayerName(self.PlayerData.source) .. ' (citizenid: ' .. self.PlayerData.citizenid .. ' | id: ' .. self.PlayerData.source .. ')** $' .. amount .. ' (' .. moneytype .. ') removed, new ' .. moneytype .. ' balance: ' .. self.PlayerData.money[moneytype] .. ' reason: ' .. reason, true) else - TriggerEvent('qb-log:server:CreateLog', 'playermoney', 'RemoveMoney', 'red', '**' .. GetPlayerName(self.PlayerData.source) .. ' (citizenid: ' .. self.PlayerData.citizenid .. ' | id: ' .. self.PlayerData.source .. ')** $' .. amount .. ' (' .. moneytype .. ') removed, new ' .. moneytype .. ' balance: ' .. self.PlayerData.money[moneytype]) + TriggerEvent('qb-log:server:CreateLog', 'playermoney', 'RemoveMoney', 'red', '**' .. GetPlayerName(self.PlayerData.source) .. ' (citizenid: ' .. self.PlayerData.citizenid .. ' | id: ' .. self.PlayerData.source .. ')** $' .. amount .. ' (' .. moneytype .. ') removed, new ' .. moneytype .. ' balance: ' .. self.PlayerData.money[moneytype] .. ' reason: ' .. reason) end TriggerClientEvent('hud:client:OnMoneyChange', self.PlayerData.source, moneytype, amount, true) if moneytype == 'bank' then @@ -281,7 +281,7 @@ function QBCore.Player.CreatePlayer(PlayerData) if not self.PlayerData.money[moneytype] then return false end self.PlayerData.money[moneytype] = amount self.Functions.UpdatePlayerData() - TriggerEvent('qb-log:server:CreateLog', 'playermoney', 'SetMoney', 'green', '**' .. GetPlayerName(self.PlayerData.source) .. ' (citizenid: ' .. self.PlayerData.citizenid .. ' | id: ' .. self.PlayerData.source .. ')** $' .. amount .. ' (' .. moneytype .. ') set, new ' .. moneytype .. ' balance: ' .. self.PlayerData.money[moneytype]) + TriggerEvent('qb-log:server:CreateLog', 'playermoney', 'SetMoney', 'green', '**' .. GetPlayerName(self.PlayerData.source) .. ' (citizenid: ' .. self.PlayerData.citizenid .. ' | id: ' .. self.PlayerData.source .. ')** $' .. amount .. ' (' .. moneytype .. ') set, new ' .. moneytype .. ' balance: ' .. self.PlayerData.money[moneytype] .. ' reason: ' .. reason) return true end @@ -351,16 +351,16 @@ function QBCore.Player.CreatePlayer(PlayerData) local slots = QBCore.Player.GetSlotsByItem(self.PlayerData.items, item) local amountToRemove = amount if slots then - for _, slot in pairs(slots) do - if self.PlayerData.items[slot].amount > amountToRemove then - self.PlayerData.items[slot].amount = self.PlayerData.items[slot].amount - amountToRemove + for _, _slot in pairs(slots) do + if self.PlayerData.items[_slot].amount > amountToRemove then + self.PlayerData.items[_slot].amount = self.PlayerData.items[_slot].amount - amountToRemove self.Functions.UpdatePlayerData() - TriggerEvent('qb-log:server:CreateLog', 'playerinventory', 'RemoveItem', 'red', '**' .. GetPlayerName(self.PlayerData.source) .. ' (citizenid: ' .. self.PlayerData.citizenid .. ' | id: ' .. self.PlayerData.source .. ')** lost item: [slot:' .. slot .. '], itemname: ' .. self.PlayerData.items[slot].name .. ', removed amount: ' .. amount .. ', new total amount: ' .. self.PlayerData.items[slot].amount) + TriggerEvent('qb-log:server:CreateLog', 'playerinventory', 'RemoveItem', 'red', '**' .. GetPlayerName(self.PlayerData.source) .. ' (citizenid: ' .. self.PlayerData.citizenid .. ' | id: ' .. self.PlayerData.source .. ')** lost item: [slot:' .. _slot .. '], itemname: ' .. self.PlayerData.items[_slot].name .. ', removed amount: ' .. amount .. ', new total amount: ' .. self.PlayerData.items[_slot].amount) return true - elseif self.PlayerData.items[slot].amount == amountToRemove then - self.PlayerData.items[slot] = nil + elseif self.PlayerData.items[_slot].amount == amountToRemove then + self.PlayerData.items[_slot] = nil self.Functions.UpdatePlayerData() - TriggerEvent('qb-log:server:CreateLog', 'playerinventory', 'RemoveItem', 'red', '**' .. GetPlayerName(self.PlayerData.source) .. ' (citizenid: ' .. self.PlayerData.citizenid .. ' | id: ' .. self.PlayerData.source .. ')** lost item: [slot:' .. slot .. '], itemname: ' .. item .. ', removed amount: ' .. amount .. ', item removed') + TriggerEvent('qb-log:server:CreateLog', 'playerinventory', 'RemoveItem', 'red', '**' .. GetPlayerName(self.PlayerData.source) .. ' (citizenid: ' .. self.PlayerData.citizenid .. ' | id: ' .. self.PlayerData.source .. ')** lost item: [slot:' .. _slot .. '], itemname: ' .. item .. ', removed amount: ' .. amount .. ', item removed') return true end end @@ -445,7 +445,7 @@ function QBCore.Player.Save(source) local pcoords = GetEntityCoords(ped) local PlayerData = QBCore.Players[source].PlayerData if PlayerData then - MySQL.Async.insert('INSERT INTO players (citizenid, cid, license, name, money, charinfo, job, gang, position, metadata) VALUES (:citizenid, :cid, :license, :name, :money, :charinfo, :job, :gang, :position, :metadata) ON DUPLICATE KEY UPDATE cid = :cid, name = :name, money = :money, charinfo = :charinfo, job = :job, gang = :gang, position = :position, metadata = :metadata', { + MySQL.insert('INSERT INTO players (citizenid, cid, license, name, money, charinfo, job, gang, position, metadata) VALUES (:citizenid, :cid, :license, :name, :money, :charinfo, :job, :gang, :position, :metadata) ON DUPLICATE KEY UPDATE cid = :cid, name = :name, money = :money, charinfo = :charinfo, job = :job, gang = :gang, position = :position, metadata = :metadata', { citizenid = PlayerData.citizenid, cid = tonumber(PlayerData.cid), license = PlayerData.license, @@ -483,7 +483,7 @@ local playertables = { -- Add tables as needed function QBCore.Player.DeleteCharacter(source, citizenid) local license = QBCore.Functions.GetIdentifier(source, 'license') - local result = MySQL.Sync.fetchScalar('SELECT license FROM players where citizenid = ?', { citizenid }) + local result = MySQL.scalar.await('SELECT license FROM players where citizenid = ?', { citizenid }) if license == result then local query = "DELETE FROM %s WHERE citizenid = ?" local tableCount = #playertables @@ -494,8 +494,8 @@ function QBCore.Player.DeleteCharacter(source, citizenid) queries[i] = {query = query:format(v.table), values = { citizenid }} end - MySQL.Async.transaction(queries, function(result) - if result then + MySQL.transaction(queries, function(result2) + if result2 then TriggerEvent('qb-log:server:CreateLog', 'joinleave', 'Character Deleted', 'red', '**' .. GetPlayerName(source) .. '** ' .. license .. ' deleted **' .. citizenid .. '**..') end end) @@ -509,7 +509,7 @@ end function QBCore.Player.LoadInventory(PlayerData) PlayerData.items = {} - local inventory = MySQL.Sync.prepare('SELECT inventory FROM players WHERE citizenid = ?', { PlayerData.citizenid }) + local inventory = MySQL.prepare.await('SELECT inventory FROM players WHERE citizenid = ?', { PlayerData.citizenid }) local missingItems = {} if inventory then inventory = json.decode(inventory) @@ -565,9 +565,9 @@ function QBCore.Player.SaveInventory(source) } end end - MySQL.Async.prepare('UPDATE players SET inventory = ? WHERE citizenid = ?', { json.encode(ItemsJson), PlayerData.citizenid }) + MySQL.prepare('UPDATE players SET inventory = ? WHERE citizenid = ?', { json.encode(ItemsJson), PlayerData.citizenid }) else - MySQL.Async.prepare('UPDATE players SET inventory = ? WHERE citizenid = ?', { '[]', PlayerData.citizenid }) + MySQL.prepare('UPDATE players SET inventory = ? WHERE citizenid = ?', { '[]', PlayerData.citizenid }) end end @@ -608,7 +608,7 @@ function QBCore.Player.CreateCitizenId() local CitizenId = nil while not UniqueFound do CitizenId = tostring(QBCore.Shared.RandomStr(3) .. QBCore.Shared.RandomInt(5)):upper() - local result = MySQL.Sync.prepare('SELECT COUNT(*) as count FROM players WHERE citizenid = ?', { CitizenId }) + local result = MySQL.prepare.await('SELECT COUNT(*) as count FROM players WHERE citizenid = ?', { CitizenId }) if result == 0 then UniqueFound = true end @@ -622,7 +622,7 @@ function QBCore.Functions.CreateAccountNumber() while not UniqueFound do AccountNumber = 'US0' .. math.random(1, 9) .. 'QBCore' .. math.random(1111, 9999) .. math.random(1111, 9999) .. math.random(11, 99) local query = '%' .. AccountNumber .. '%' - local result = MySQL.Sync.prepare('SELECT COUNT(*) as count FROM players WHERE charinfo LIKE ?', { query }) + local result = MySQL.prepare.await('SELECT COUNT(*) as count FROM players WHERE charinfo LIKE ?', { query }) if result == 0 then UniqueFound = true end @@ -636,7 +636,7 @@ function QBCore.Functions.CreatePhoneNumber() while not UniqueFound do PhoneNumber = math.random(100,999) .. math.random(1000000,9999999) local query = '%' .. PhoneNumber .. '%' - local result = MySQL.Sync.prepare('SELECT COUNT(*) as count FROM players WHERE charinfo LIKE ?', { query }) + local result = MySQL.prepare.await('SELECT COUNT(*) as count FROM players WHERE charinfo LIKE ?', { query }) if result == 0 then UniqueFound = true end @@ -650,7 +650,7 @@ function QBCore.Player.CreateFingerId() while not UniqueFound do FingerId = tostring(QBCore.Shared.RandomStr(2) .. QBCore.Shared.RandomInt(3) .. QBCore.Shared.RandomStr(1) .. QBCore.Shared.RandomInt(2) .. QBCore.Shared.RandomStr(3) .. QBCore.Shared.RandomInt(4)) local query = '%' .. FingerId .. '%' - local result = MySQL.Sync.prepare('SELECT COUNT(*) as count FROM `players` WHERE `metadata` LIKE ?', { query }) + local result = MySQL.prepare.await('SELECT COUNT(*) as count FROM `players` WHERE `metadata` LIKE ?', { query }) if result == 0 then UniqueFound = true end @@ -664,7 +664,7 @@ function QBCore.Player.CreateWalletId() while not UniqueFound do WalletId = 'QB-' .. math.random(11111111, 99999999) local query = '%' .. WalletId .. '%' - local result = MySQL.Sync.prepare('SELECT COUNT(*) as count FROM players WHERE metadata LIKE ?', { query }) + local result = MySQL.prepare.await('SELECT COUNT(*) as count FROM players WHERE metadata LIKE ?', { query }) if result == 0 then UniqueFound = true end @@ -678,7 +678,7 @@ function QBCore.Player.CreateSerialNumber() while not UniqueFound do SerialNumber = math.random(11111111, 99999999) local query = '%' .. SerialNumber .. '%' - local result = MySQL.Sync.prepare('SELECT COUNT(*) as count FROM players WHERE metadata LIKE ?', { query }) + local result = MySQL.prepare.await('SELECT COUNT(*) as count FROM players WHERE metadata LIKE ?', { query }) if result == 0 then UniqueFound = true end diff --git a/shared/items.lua b/shared/items.lua index 546a0c2..d58cd32 100644 --- a/shared/items.lua +++ b/shared/items.lua @@ -244,7 +244,7 @@ QBShared.Items = { ['shotgun_ammo'] = {['name'] = 'shotgun_ammo', ['label'] = 'Shotgun ammo', ['weight'] = 500, ['type'] = 'item', ['image'] = 'shotgun_ammo.png', ['unique'] = false, ['useable'] = true, ['shouldClose'] = true, ['combinable'] = nil, ['description'] = 'Ammo for Shotguns'}, ['mg_ammo'] = {['name'] = 'mg_ammo', ['label'] = 'MG ammo', ['weight'] = 1000, ['type'] = 'item', ['image'] = 'mg_ammo.png', ['unique'] = false, ['useable'] = true, ['shouldClose'] = true, ['combinable'] = nil, ['description'] = 'Ammo for Machine Guns'}, ['snp_ammo'] = {['name'] = 'snp_ammo', ['label'] = 'Sniper ammo', ['weight'] = 1000, ['type'] = 'item', ['image'] = 'rifle_ammo.png', ['unique'] = false, ['useable'] = true, ['shouldClose'] = true, ['combinable'] = nil, ['description'] = 'Ammo for Sniper Rifles'}, - ['emp_ammo'] = {['name'] = 'emp_ammo', ['label'] = 'EMP Ammo', ['weight'] = 200, ['type'] = 'item', ['image'] = 'emp_ammo.png', ['unique'] = false, ['useable'] = true, ['shouldClose'] = true, ['combinable'] = nil, ['description'] = 'Ammo for EMP Launcher'}, + ['emp_ammo'] = {['name'] = 'emp_ammo', ['label'] = 'EMP Ammo', ['weight'] = 200, ['type'] = 'item', ['image'] = 'emp_ammo.png', ['unique'] = false, ['useable'] = true, ['shouldClose'] = true, ['combinable'] = nil, ['description'] = 'Ammo for EMP Launcher'}, -- Card ITEMS ['id_card'] = {['name'] = 'id_card', ['label'] = 'ID Card', ['weight'] = 0, ['type'] = 'item', ['image'] = 'id_card.png', ['unique'] = true, ['useable'] = true, ['shouldClose'] = false, ['combinable'] = nil, ['description'] = 'A card containing all your information to identify yourself'}, diff --git a/shared/locale.lua b/shared/locale.lua index eb7e462..6b9510b 100644 --- a/shared/locale.lua +++ b/shared/locale.lua @@ -31,7 +31,6 @@ end --- @param opts table - Constructor opts param --- @return Locale function Locale:new(opts) - local self = {} setmetatable(self, Locale) self.warnOnMissing = opts.warnOnMissing or true @@ -135,4 +134,4 @@ function Locale:delete(phraseTarget, prefix) end end end -end \ No newline at end of file +end diff --git a/shared/main.lua b/shared/main.lua index cace3c0..2319bc9 100644 --- a/shared/main.lua +++ b/shared/main.lua @@ -155,4 +155,4 @@ QBShared.FemaleNoGloves = { [157] = true, [161] = true, [165] = true -} \ No newline at end of file +} diff --git a/shared/vehicles.lua b/shared/vehicles.lua index cb7d8ce..79e9afc 100644 --- a/shared/vehicles.lua +++ b/shared/vehicles.lua @@ -4421,6 +4421,6 @@ QBShared.Vehicles = { }, } -for k,v in pairs(QBShared.Vehicles) do +for _, v in pairs(QBShared.Vehicles) do QBShared.VehicleHashes[v.hash] = v end diff --git a/shared/weapons.lua b/shared/weapons.lua index af0df12..148a40d 100644 --- a/shared/weapons.lua +++ b/shared/weapons.lua @@ -145,4 +145,4 @@ QBShared.Weapons = { -- Animals [`weapon_animal`] = {['name'] = 'weapon_animal', ['label'] = 'Animal', ['ammotype'] = nil, ['damagereason'] = 'Mauled'}, [`weapon_cougar`] = {['name'] = 'weapon_cougar', ['label'] = 'Cougar', ['ammotype'] = nil, ['damagereason'] = 'Mauled'}, -} \ No newline at end of file +}