From 2a8e72ee49c282691151a85417857f65c288d362 Mon Sep 17 00:00:00 2001 From: busco82 <95722055+busco82@users.noreply.github.com> Date: Sat, 15 Jun 2024 16:13:44 +0200 Subject: [PATCH 1/3] fix: es_extended\server\main.lua --- .../[esx]/es_extended/server/main.lua | 84 +++++++------------ 1 file changed, 28 insertions(+), 56 deletions(-) diff --git a/server-data/resources/[esx]/es_extended/server/main.lua b/server-data/resources/[esx]/es_extended/server/main.lua index fae13115f..6283fa12e 100644 --- a/server-data/resources/[esx]/es_extended/server/main.lua +++ b/server-data/resources/[esx]/es_extended/server/main.lua @@ -3,8 +3,7 @@ SetGameType("BPT FRAMEWORK") local oneSyncState = GetConvar("onesync", "off") local newPlayer = "INSERT INTO `users` SET `accounts` = ?, `identifier` = ?, `group` = ?" -local loadPlayer = -"SELECT `accounts`, `job`, `job_grade`, `group`, `position`, `inventory`, `skin`, `loadout`, `metadata`" +local loadPlayer = "SELECT `accounts`, `job`, `job_grade`, `group`, `position`, `inventory`, `skin`, `loadout`, `metadata`" if Config.Multichar then newPlayer = newPlayer .. ", `firstname` = ?, `lastname` = ?, `dateofbirth` = ?, `sex` = ?, `height` = ?" @@ -48,14 +47,11 @@ function onPlayerJoined(playerId) local identifier = ESX.GetIdentifier(playerId) if not identifier then - return DropPlayer(playerId, - "there was an error loading your character!\nError code: identifier-missing-ingame\n\nThe cause of this error is not known, your identifier could not be found. Please come back later or report this problem to the server administration team.") + return DropPlayer(playerId, "there was an error loading your character!\nError code: identifier-missing-ingame\n\nThe cause of this error is not known, your identifier could not be found. Please come back later or report this problem to the server administration team.") end if ESX.GetPlayerFromIdentifier(identifier) then - return DropPlayer(playerId, - ("there was an error loading your character!\nError code: identifier-active-ingame\n\nThis error is caused by a player on this server who has the same identifier as you have. Make sure you are not playing on the same Rockstar account.\n\nYour Rockstar identifier: %s") - :format(identifier)) + return DropPlayer(playerId, ("there was an error loading your character!\nError code: identifier-active-ingame\n\nThis error is caused by a player on this server who has the same identifier as you have. Make sure you are not playing on the same Rockstar account.\n\nYour Rockstar identifier: %s"):format(identifier)) end local result = MySQL.scalar.await("SELECT 1 FROM users WHERE identifier = ?", { identifier }) @@ -75,9 +71,7 @@ function createESXPlayer(identifier, playerId, data) defaultGroup = "admin" end - local parameters = Config.Multichar and - { json.encode(accounts), identifier, defaultGroup, data.firstname, data.lastname, data.dateofbirth, data.sex, data - .height } or { json.encode(accounts), identifier, defaultGroup } + local parameters = Config.Multichar and { json.encode(accounts), identifier, defaultGroup, data.firstname, data.lastname, data.dateofbirth, data.sex, data.height } or { json.encode(accounts), identifier, defaultGroup } if Config.StartingInventoryItems then table.insert(parameters, json.encode(Config.StartingInventoryItems)) @@ -95,22 +89,17 @@ if not Config.Multichar then local identifier = ESX.GetIdentifier(playerId) if oneSyncState == "off" or oneSyncState == "legacy" then - return deferrals.done(("[ESX] ESX Requires Onesync Infinity to work. This server currently has Onesync set to: %s") - :format(oneSyncState)) + return deferrals.done(("[ESX] ESX Requires Onesync Infinity to work. This server currently has Onesync set to: %s"):format(oneSyncState)) end if not Core.DatabaseConnected then - return deferrals.done( - "[ESX] OxMySQL Was Unable To Connect to your database. Please make sure it is turned on and correctly configured in your server.cfg") + return deferrals.done("[ESX] OxMySQL Was Unable To Connect to your database. Please make sure it is turned on and correctly configured in your server.cfg") end if identifier then - return ESX.GetPlayerFromIdentifier(identifier) and - deferrals.done(("[ESX] There was an error loading your character!\nError code: identifier-active\n\nThis error is caused by a player on this server who has the same identifier as you have. Make sure you are not playing on the same account.\n\nYour identifier: %s") - :format(identifier)) or deferrals.done() + return ESX.GetPlayerFromIdentifier(identifier) and deferrals.done(("[ESX] There was an error loading your character!\nError code: identifier-active\n\nThis error is caused by a player on this server who has the same identifier as you have. Make sure you are not playing on the same account.\n\nYour identifier: %s"):format(identifier)) or deferrals.done() else - return deferrals.done( - "[ESX] There was an error loading your character!\nError code: identifier-missing\n\nThe cause of this error is not known, your identifier could not be found. Please come back later or report this problem to the server administration team.") + return deferrals.done("[ESX] There was an error loading your character!\nError code: identifier-missing\n\nThe cause of this error is not known, your identifier could not be found. Please come back later or report this problem to the server administration team.") end end) end @@ -132,7 +121,8 @@ function loadESXPlayer(identifier, playerId, isNew) local result = MySQL.prepare.await(loadPlayer, { identifier }) -- Accounts - local accounts = (result.accounts and result.accounts ~= "") and json.decode(result.accounts) or {} + local accounts = result.accounts + accounts = (accounts and accounts ~= "") and json.decode(accounts) or {} for account, data in pairs(Config.Accounts) do data.round = data.round or data.round == nil @@ -151,8 +141,7 @@ function loadESXPlayer(identifier, playerId, isNew) local job, grade = result.job, tostring(result.job_grade) if not ESX.DoesJobExist(job, grade) then - print(("[^3WARNING^7] Ignoring invalid job for ^5%s^7 [job: ^5%s^7, grade: ^5%s^7]"):format(identifier, job, - grade)) + print(("[^3WARNING^7] Ignoring invalid job for ^5%s^7 [job: ^5%s^7, grade: ^5%s^7]"):format(identifier, job, grade)) job, grade = "unemployed", "0" end @@ -234,15 +223,13 @@ function loadESXPlayer(identifier, playerId, isNew) userData.coords = json.decode(result.position) or Config.DefaultSpawns[math.random(#Config.DefaultSpawns)] -- Skin - userData.skin = (result.skin and result.skin ~= "") and json.decode(result.skin) or - { sex = userData.sex == "f" and 1 or 0 } + userData.skin = (result.skin and result.skin ~= "") and json.decode(result.skin) or { sex = userData.sex == "f" and 1 or 0 } -- Metadata userData.metadata = (result.metadata and result.metadata ~= "") and json.decode(result.metadata) or {} -- xPlayer Creation - local xPlayer = CreateExtendedPlayer(playerId, identifier, userData.group, userData.accounts, userData.inventory, - userData.weight, userData.job, userData.loadout, GetPlayerName(playerId), userData.coords, userData.metadata) + local xPlayer = CreateExtendedPlayer(playerId, identifier, userData.group, userData.accounts, userData.inventory, userData.weight, userData.job, userData.loadout, GetPlayerName(playerId), userData.coords, userData.metadata) ESX.Players[playerId] = xPlayer Core.playersByIdentifier[identifier] = xPlayer @@ -382,10 +369,8 @@ if not Config.OxInventory then sourceXPlayer.removeInventoryItem(itemName, itemCount) targetXPlayer.addInventoryItem(itemName, itemCount) - sourceXPlayer.showNotification(TranslateCap("gave_item", itemCount, sourceItem.label, - targetXPlayer.name)) - targetXPlayer.showNotification(TranslateCap("received_item", itemCount, sourceItem.label, - sourceXPlayer.name)) + sourceXPlayer.showNotification(TranslateCap("gave_item", itemCount, sourceItem.label, targetXPlayer.name)) + targetXPlayer.showNotification(TranslateCap("received_item", itemCount, sourceItem.label, sourceXPlayer.name)) else sourceXPlayer.showNotification(TranslateCap("ex_inv_lim", targetXPlayer.name)) end @@ -397,10 +382,8 @@ if not Config.OxInventory then sourceXPlayer.removeAccountMoney(itemName, itemCount, "Gave to " .. targetXPlayer.name) targetXPlayer.addAccountMoney(itemName, itemCount, "Received from " .. sourceXPlayer.name) - sourceXPlayer.showNotification(TranslateCap("gave_account_money", ESX.Math.GroupDigits(itemCount), - Config.Accounts[itemName].label, targetXPlayer.name)) - targetXPlayer.showNotification(TranslateCap("received_account_money", ESX.Math.GroupDigits(itemCount), - Config.Accounts[itemName].label, sourceXPlayer.name)) + sourceXPlayer.showNotification(TranslateCap("gave_account_money", ESX.Math.GroupDigits(itemCount), Config.Accounts[itemName].label, targetXPlayer.name)) + targetXPlayer.showNotification(TranslateCap("received_account_money", ESX.Math.GroupDigits(itemCount), Config.Accounts[itemName].label, sourceXPlayer.name)) else sourceXPlayer.showNotification(TranslateCap("imp_invalid_amount")) end @@ -426,18 +409,15 @@ if not Config.OxInventory then if weaponObject.ammo and itemCount > 0 then local ammoLabel = weaponObject.ammo.label - sourceXPlayer.showNotification(TranslateCap("gave_weapon_withammo", weaponLabel, itemCount, - ammoLabel, targetXPlayer.name)) - targetXPlayer.showNotification(TranslateCap("received_weapon_withammo", weaponLabel, itemCount, - ammoLabel, sourceXPlayer.name)) + sourceXPlayer.showNotification(TranslateCap("gave_weapon_withammo", weaponLabel, itemCount, ammoLabel, targetXPlayer.name)) + targetXPlayer.showNotification(TranslateCap("received_weapon_withammo", weaponLabel, itemCount, ammoLabel, sourceXPlayer.name)) else sourceXPlayer.showNotification(TranslateCap("gave_weapon", weaponLabel, targetXPlayer.name)) targetXPlayer.showNotification(TranslateCap("received_weapon", weaponLabel, sourceXPlayer.name)) end else sourceXPlayer.showNotification(TranslateCap("gave_weapon_hasalready", targetXPlayer.name, weaponLabel)) - targetXPlayer.showNotification(TranslateCap("received_weapon_hasalready", sourceXPlayer.name, - weaponLabel)) + targetXPlayer.showNotification(TranslateCap("received_weapon_hasalready", sourceXPlayer.name, weaponLabel)) end end elseif itemType == "item_ammo" then @@ -454,16 +434,13 @@ if not Config.OxInventory then sourceXPlayer.removeWeaponAmmo(itemName, itemCount) targetXPlayer.addWeaponAmmo(itemName, itemCount) - sourceXPlayer.showNotification(TranslateCap("gave_weapon_ammo", itemCount, ammoLabel, - weapon.label, targetXPlayer.name)) - targetXPlayer.showNotification(TranslateCap("received_weapon_ammo", itemCount, ammoLabel, - weapon.label, sourceXPlayer.name)) + sourceXPlayer.showNotification(TranslateCap("gave_weapon_ammo", itemCount, ammoLabel, weapon.label, targetXPlayer.name)) + targetXPlayer.showNotification(TranslateCap("received_weapon_ammo", itemCount, ammoLabel, weapon.label, sourceXPlayer.name)) end end else sourceXPlayer.showNotification(TranslateCap("gave_weapon_noweapon", targetXPlayer.name)) - targetXPlayer.showNotification(TranslateCap("received_weapon_noweapon", sourceXPlayer.name, - weapon.label)) + targetXPlayer.showNotification(TranslateCap("received_weapon_noweapon", sourceXPlayer.name, weapon.label)) end end end @@ -499,11 +476,9 @@ if not Config.OxInventory then xPlayer.showNotification(TranslateCap("imp_invalid_amount")) else xPlayer.removeAccountMoney(itemName, itemCount, "Threw away") - local pickupLabel = ("%s [%s]"):format(account.label, - TranslateCap("locale_currency", ESX.Math.GroupDigits(itemCount))) + local pickupLabel = ("%s [%s]"):format(account.label, TranslateCap("locale_currency", ESX.Math.GroupDigits(itemCount))) ESX.CreatePickup("item_account", itemName, itemCount, pickupLabel, playerId) - xPlayer.showNotification(TranslateCap("threw_account", ESX.Math.GroupDigits(itemCount), - string.lower(account.label))) + xPlayer.showNotification(TranslateCap("threw_account", ESX.Math.GroupDigits(itemCount), string.lower(account.label))) end end elseif itemType == "item_weapon" then @@ -524,8 +499,7 @@ if not Config.OxInventory then xPlayer.showNotification(TranslateCap("threw_weapon", weapon.label)) end - ESX.CreatePickup("item_weapon", itemName, weapon.ammo, pickupLabel, playerId, components, - weapon.tintIndex) + ESX.CreatePickup("item_weapon", itemName, weapon.ammo, pickupLabel, playerId, components, weapon.tintIndex) end end end) @@ -545,8 +519,7 @@ if not Config.OxInventory then local playerPickupDistance = #(pickup.coords - xPlayer.getCoords(true)) if playerPickupDistance > 5.0 then - return print(("[^3WARNING^7] Player Detected Cheating (Out of range pickup): ^5%s^7"):format(xPlayer - .getIdentifier())) + return print(("[^3WARNING^7] Player Detected Cheating (Out of range pickup): ^5%s^7"):format(xPlayer.getIdentifier())) end if pickup.type == "item_standard" then @@ -632,8 +605,7 @@ end) ESX.RegisterServerCallback("esx:spawnVehicle", function(source, cb, vehData) local ped = GetPlayerPed(source) - ESX.OneSync.SpawnVehicle(vehData.model or `ADDER`, vehData.coords or GetEntityCoords(ped), vehData.coords.w or 0.0, - vehData.props or {}, function(id) + ESX.OneSync.SpawnVehicle(vehData.model or `ADDER`, vehData.coords or GetEntityCoords(ped), vehData.coords.w or 0.0, vehData.props or {}, function(id) if vehData.warp then local vehicle = NetworkGetEntityFromNetworkId(id) local timeout = 0 From 8cb35a247656cffab049ec8716319220f6916189 Mon Sep 17 00:00:00 2001 From: busco82 <95722055+busco82@users.noreply.github.com> Date: Sat, 15 Jun 2024 16:51:07 +0200 Subject: [PATCH 2/3] fix: bpt_menu\server\main.lua --- .../resources/[bpt_addons]/bpt_menu/server/main.lua | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/server-data/resources/[bpt_addons]/bpt_menu/server/main.lua b/server-data/resources/[bpt_addons]/bpt_menu/server/main.lua index 3b2fc51fc..dda6540fd 100644 --- a/server-data/resources/[bpt_addons]/bpt_menu/server/main.lua +++ b/server-data/resources/[bpt_addons]/bpt_menu/server/main.lua @@ -69,7 +69,7 @@ function getMaximumGrade(jobName) end function getAdminCommand(name) - for i = 1, #Config.Admin do + for _ = 1, #Config.Admin do if Config.Admin[i].name == name then return i end @@ -165,11 +165,7 @@ AddEventHandler( if newGrade ~= getMaximumGrade(targetJob.name) then targetXPlayer.setJob(targetJob.name, newGrade) - TriggerClientEvent( - "esx:showNotification", - sourceXPlayer.source, - TranslateCap("promoted"):format(targetXPlayer.name) - ) + TriggerClientEvent("esx:showNotification", sourceXPlayer.source,TranslateCap("promoted"):format(targetXPlayer.name)) TriggerClientEvent("esx:showNotification", target, TranslateCap("you_promoted"):format(sourceXPlayer.name)) else TriggerClientEvent("esx:showNotification", sourceXPlayer.source, TranslateCap("not_permission")) From 2f2a50d2f5f7d4453b7735f390a9ca059c04c80b Mon Sep 17 00:00:00 2001 From: busco82 <95722055+busco82@users.noreply.github.com> Date: Sat, 15 Jun 2024 19:05:35 +0200 Subject: [PATCH 3/3] Update main.lua --- server-data/resources/[esx]/es_extended/server/main.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server-data/resources/[esx]/es_extended/server/main.lua b/server-data/resources/[esx]/es_extended/server/main.lua index 6283fa12e..af68fd51e 100644 --- a/server-data/resources/[esx]/es_extended/server/main.lua +++ b/server-data/resources/[esx]/es_extended/server/main.lua @@ -121,7 +121,7 @@ function loadESXPlayer(identifier, playerId, isNew) local result = MySQL.prepare.await(loadPlayer, { identifier }) -- Accounts - local accounts = result.accounts + local accounts = result ~= nil and result.accounts accounts = (accounts and accounts ~= "") and json.decode(accounts) or {} for account, data in pairs(Config.Accounts) do