From 95d4d6d287fef286852a25a309ac1f7922bc17f4 Mon Sep 17 00:00:00 2001 From: GhzGarage Date: Sat, 11 Sep 2021 21:26:56 -0500 Subject: [PATCH] =?UTF-8?q?=E2=9A=A0=EF=B8=8F=E2=9A=A0=EF=B8=8F=20ghmatti?= =?UTF-8?q?=20ditch=20=E2=9A=A0=EF=B8=8F=E2=9A=A0=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fxmanifest.lua | 4 ++-- server/events.lua | 6 +++--- server/functions.lua | 12 ++++++------ server/player.lua | 26 +++++++++++++------------- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/fxmanifest.lua b/fxmanifest.lua index 604f7ff..c2ebd8f 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -43,5 +43,5 @@ files { dependencies { 'progressbar', 'connectqueue', - 'ghmattimysql' -} + 'oxmysql' +} \ No newline at end of file diff --git a/server/events.lua b/server/events.lua index ce84531..c91366c 100644 --- a/server/events.lua +++ b/server/events.lua @@ -232,7 +232,7 @@ AddEventHandler('QBCore:ToggleDuty', function() end) Citizen.CreateThread(function() - local result = exports['ghmattimysql']:executeSync('SELECT * FROM permissions') + local result = exports.oxmysql:fetchSync('SELECT * FROM permissions', {}) if result[1] ~= nil then for k, v in pairs(result) do QBCore.Config.Server.PermissionList[v.license] = { @@ -306,9 +306,9 @@ end) RegisterServerEvent('QBCore:Command:CheckOwnedVehicle') AddEventHandler('QBCore:Command:CheckOwnedVehicle', function(VehiclePlate) if VehiclePlate ~= nil then - local result = exports['ghmattimysql']:executeSync('SELECT * FROM player_vehicles WHERE plate=@plate', {['@plate'] = VehiclePlate}) + local result = exports.oxmysql:fetchSync('SELECT * FROM player_vehicles WHERE plate=@plate', {['@plate'] = VehiclePlate}) if result[1] ~= nil then - exports.ghmattimysql:execute('UPDATE player_vehicles SET state=@state WHERE citizenid=@citizenid', {['@state'] = 1, ['@citizenid'] = result[1].citizenid}) + exports.oxmysql:execute('UPDATE player_vehicles SET state=@state WHERE citizenid=@citizenid', {['@state'] = 1, ['@citizenid'] = result[1].citizenid}) TriggerEvent('qb-garages:server:RemoveVehicle', result[1].citizenid, VehiclePlate) end end diff --git a/server/functions.lua b/server/functions.lua index 5b11a6e..605700b 100644 --- a/server/functions.lua +++ b/server/functions.lua @@ -128,7 +128,7 @@ QBCore.Functions.IsWhitelisted = function(source) local identifiers = GetPlayerIdentifiers(source) local rtn = false if (QBCore.Config.Server.whitelist) then - local result = exports['ghmattimysql']:executeSync('SELECT * FROM whitelist WHERE license=@license', {['@license'] = QBCore.Functions.GetIdentifier(source, 'license')}) + local result = exports.oxmysql:fetchSync('SELECT * FROM whitelist WHERE license=@license', {['@license'] = QBCore.Functions.GetIdentifier(source, 'license')}) local data = result[1] if data ~= nil then for _, id in pairs(identifiers) do @@ -150,9 +150,9 @@ QBCore.Functions.AddPermission = function(source, permission) license = QBCore.Functions.GetIdentifier(source, 'license'), permission = permission:lower(), } - exports['ghmattimysql']:execute('DELETE FROM permissions WHERE license=@license', {['@license'] = QBCore.Functions.GetIdentifier(source, 'license')}) + exports.oxmysql:execute('DELETE FROM permissions WHERE license=@license', {['@license'] = QBCore.Functions.GetIdentifier(source, 'license')}) - exports['ghmattimysql']:execute('INSERT INTO permissions (name, license, permission) VALUES (@name, @license, @permission)', { + exports.oxmysql:insert('INSERT INTO permissions (name, license, permission) VALUES (@name, @license, @permission)', { ['@name'] = GetPlayerName(source), ['@license'] = QBCore.Functions.GetIdentifier(source, 'license'), ['@permission'] = permission:lower() @@ -167,7 +167,7 @@ QBCore.Functions.RemovePermission = function(source) local Player = QBCore.Functions.GetPlayer(source) if Player ~= nil then QBCore.Config.Server.PermissionList[QBCore.Functions.GetIdentifier(source, 'license')] = nil - exports['ghmattimysql']:execute('DELETE FROM permissions WHERE license=@license', {['@license'] = QBCore.Functions.GetIdentifier(source, 'license')}) + exports.oxmysql:execute('DELETE FROM permissions WHERE license=@license', {['@license'] = QBCore.Functions.GetIdentifier(source, 'license')}) Player.Functions.UpdatePlayerData() end end @@ -223,14 +223,14 @@ end QBCore.Functions.IsPlayerBanned = function (source) local retval = false local message = "" - local result = exports.ghmattimysql:executeSync('SELECT * FROM bans WHERE license=@license', {['@license'] = QBCore.Functions.GetIdentifier(source, 'license')}) + local result = exports.oxmysql:fetchSync('SELECT * FROM bans WHERE license=@license', {['@license'] = QBCore.Functions.GetIdentifier(source, 'license')}) if result[1] ~= nil then if os.time() < result[1].expire then retval = true local timeTable = os.date("*t", tonumber(result.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}) + exports.oxmysql:execute('DELETE FROM bans WHERE id=@id', {['@id'] = result[1].id}) end end return retval, message diff --git a/server/player.lua b/server/player.lua index 0bd86ec..b37a26f 100644 --- a/server/player.lua +++ b/server/player.lua @@ -4,7 +4,7 @@ QBCore.Player = {} QBCore.Player.Login = function(source, citizenid, newData) if source ~= nil then if citizenid then - local result = exports['ghmattimysql']:executeSync('SELECT * FROM players WHERE citizenid=@citizenid', {['@citizenid'] = citizenid}) + local result = exports.oxmysql:fetchSync('SELECT * FROM players WHERE citizenid=@citizenid', {['@citizenid'] = citizenid}) local PlayerData = result[1] if PlayerData ~= nil then PlayerData.money = json.decode(PlayerData.money) @@ -439,9 +439,9 @@ end QBCore.Player.Save = function(source) local PlayerData = QBCore.Players[source].PlayerData if PlayerData ~= nil then - local result = exports.ghmattimysql:executeSync('SELECT * FROM players WHERE citizenid=@citizenid', {['@citizenid'] = PlayerData.citizenid}) + local result = exports.oxmysql:fetchSync('SELECT * FROM players WHERE citizenid=@citizenid', {['@citizenid'] = PlayerData.citizenid}) if result[1] == nil then - exports.ghmattimysql:execute('INSERT INTO players (citizenid, cid, license, name, money, charinfo, job, gang, position, metadata) VALUES (@citizenid, @cid, @license, @name, @money, @charinfo, @job, @gang, @position, @metadata)', { + exports.oxmysql: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)', { ['@citizenid'] = PlayerData.citizenid, ['@cid'] = tonumber(PlayerData.cid), ['@license'] = PlayerData.license, @@ -454,7 +454,7 @@ QBCore.Player.Save = function(source) ['@metadata'] = json.encode(PlayerData.metadata) }) else - exports.ghmattimysql:execute('UPDATE players SET license=@license, name=@name, money=@money, charinfo=@charinfo, job=@job, gang=@gang, position=@position, metadata=@metadata WHERE citizenid=@citizenid', { + exports.oxmysql:execute('UPDATE players SET license=@license, name=@name, money=@money, charinfo=@charinfo, job=@job, gang=@gang, position=@position, metadata=@metadata WHERE citizenid=@citizenid', { ['@citizenid'] = PlayerData.citizenid, ['@license'] = PlayerData.license, ['@name'] = PlayerData.name, @@ -498,10 +498,10 @@ local playertables = { QBCore.Player.DeleteCharacter = function(source, citizenid) local license = QBCore.Functions.GetIdentifier(source, 'license') - local result = exports.ghmattimysql:scalarSync('SELECT license FROM players where citizenid = ?', {citizenid}) + local result = exports.oxmysql:scalarSync('SELECT license FROM players where citizenid = ?', {citizenid}) if license == result then for k,v in pairs(playertables) do - exports.ghmattimysql:execute('DELETE FROM '..v.table..' WHERE citizenid = ?', {citizenid}) + exports.oxmysql:execute('DELETE FROM '..v.table..' WHERE citizenid = ?', {citizenid}) end TriggerEvent("qb-log:server:CreateLog", "joinleave", "Character Deleted", "red", "**".. GetPlayerName(source) .. "** ("..QBCore.Functions.GetIdentifier(source, 'license')..") deleted **"..citizenid.."**..") else @@ -512,7 +512,7 @@ end QBCore.Player.LoadInventory = function(PlayerData) PlayerData.items = {} - local result = exports['ghmattimysql']:executeSync('SELECT * FROM players WHERE citizenid=@citizenid', {['@citizenid'] = PlayerData.citizenid}) + local result = exports.oxmysql:fetchSync('SELECT * FROM players WHERE citizenid=@citizenid', {['@citizenid'] = PlayerData.citizenid}) if result[1] ~= nil then if result[1].inventory ~= nil then plyInventory = json.decode(result[1].inventory) @@ -562,9 +562,9 @@ QBCore.Player.SaveInventory = function(source) }) end end - exports.ghmattimysql:execute('UPDATE players SET inventory=@inventory WHERE citizenid=@citizenid', {['@inventory'] = json.encode(ItemsJson), ['@citizenid'] = PlayerData.citizenid}) + exports.oxmysql:execute('UPDATE players SET inventory=@inventory WHERE citizenid=@citizenid', {['@inventory'] = json.encode(ItemsJson), ['@citizenid'] = PlayerData.citizenid}) else - exports.ghmattimysql:execute('UPDATE players SET inventory=@inventory WHERE citizenid=@citizenid', {['@inventory'] = '[]', ['@citizenid'] = PlayerData.citizenid}) + exports.oxmysql:execute('UPDATE players SET inventory=@inventory WHERE citizenid=@citizenid', {['@inventory'] = '[]', ['@citizenid'] = PlayerData.citizenid}) end end end @@ -608,7 +608,7 @@ QBCore.Player.CreateCitizenId = function() while not UniqueFound do CitizenId = tostring(QBCore.Shared.RandomStr(3) .. QBCore.Shared.RandomInt(5)):upper() - local result = exports.ghmattimysql:executeSync('SELECT COUNT(*) as count FROM players WHERE citizenid=@citizenid', {['@citizenid'] = CitizenId}) + local result = exports.oxmysql:fetchSync('SELECT COUNT(*) as count FROM players WHERE citizenid=@citizenid', {['@citizenid'] = CitizenId}) if result[1].count == 0 then UniqueFound = true end @@ -622,7 +622,7 @@ QBCore.Player.CreateFingerId = function() 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 = exports.ghmattimysql:executeSync('SELECT COUNT(*) as count FROM `players` WHERE `metadata` LIKE @query', {['@query'] = query}) + local result = exports.oxmysql:fetchSync('SELECT COUNT(*) as count FROM `players` WHERE `metadata` LIKE @query', {['@query'] = query}) if result[1].count == 0 then UniqueFound = true end @@ -636,7 +636,7 @@ QBCore.Player.CreateWalletId = function() while not UniqueFound do WalletId = "QB-"..math.random(11111111, 99999999) local query = '%'..WalletId..'%' - local result = exports.ghmattimysql:executeSync('SELECT COUNT(*) as count FROM players WHERE metadata LIKE @query', {['@query'] = query}) + local result = exports.oxmysql:fetchSync('SELECT COUNT(*) as count FROM players WHERE metadata LIKE @query', {['@query'] = query}) if result[1].count == 0 then UniqueFound = true end @@ -651,7 +651,7 @@ QBCore.Player.CreateSerialNumber = function() while not UniqueFound do SerialNumber = math.random(11111111, 99999999) local query = '%'..SerialNumber..'%' - local result = exports.ghmattimysql:executeSync('SELECT COUNT(*) as count FROM players WHERE metadata LIKE @query', {['@query'] = query}) + local result = exports.oxmysql:fetchSync('SELECT COUNT(*) as count FROM players WHERE metadata LIKE @query', {['@query'] = query}) if result[1].count == 0 then UniqueFound = true end