From 8edb4c41c5c5d9a34ac5ea90e4d44a8a866529d7 Mon Sep 17 00:00:00 2001 From: faizy Date: Wed, 8 Feb 2023 18:14:00 -0400 Subject: [PATCH 01/34] feat(weapons): LS Drug Wars DLC Weapons --- [core]/es_extended/config.weapons.lua | 16 +++++++++++++++- [core]/es_extended/locales/cs.lua | 6 ++++++ [core]/es_extended/locales/en.lua | 6 ++++++ [core]/es_extended/locales/hu.lua | 6 ++++++ 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/[core]/es_extended/config.weapons.lua b/[core]/es_extended/config.weapons.lua index 8b89e3da..b7c63cd1 100644 --- a/[core]/es_extended/config.weapons.lua +++ b/[core]/es_extended/config.weapons.lua @@ -976,5 +976,19 @@ Config.Weapons = { {name = 'clip_default', label = TranslateCap('component_clip_default'), hash = `COMPONENT_PRECISIONRIFLE_CLIP_01`}, } }, - {name = 'WEAPON_METALDETECTOR', label = TranslateCap('weapon_metaldetector'), components = {}} + {name = 'WEAPON_METALDETECTOR', label = TranslateCap('weapon_metaldetector'), components = {}}, + , + {name = 'WEAPON_PISTOLXM3', label = TranslateCap('weapon_pistolxm3'), ammo = {label = TranslateCap('ammo_rounds'), hash = `AMMO_PISTOL`}, tints = Config.DefaultWeaponTints, + components = { + {name = 'clip_default', label = TranslateCap('component_clip_default'), hash = `COMPONENT_PISTOLXM3_CLIP_01`}, + {name = 'suppressor', label = TranslateCap('component_suppressor'), hash = `COMPONENT_PISTOLXM3_SUPP`} + } + }, + {name = 'WEAPON_ACIDPACKAGE', label = TranslateCap('weapon_acidpackage'), components = {}}, + {name = 'WEAPON_CANDYCANE', label = TranslateCap('weapon_candycane'), components = {}}, + {name = 'WEAPON_RAILGUNXM3', label = TranslateCap('weapon_railgunxm3'), ammo = {label = TranslateCap('ammo_rounds'), hash = `AMMO_RAILGUN`}, tints = Config.DefaultWeaponTints, + components = { + {name = 'clip_default', label = TranslateCap('component_clip_default'), hash = `COMPONENT_RAILGUNXM3_CLIP_01`}, + }, + }, } diff --git a/[core]/es_extended/locales/cs.lua b/[core]/es_extended/locales/cs.lua index 7186ef8b..1472cffc 100644 --- a/[core]/es_extended/locales/cs.lua +++ b/[core]/es_extended/locales/cs.lua @@ -216,6 +216,12 @@ Locales['cs'] = { ['weapon_precisionrifle'] = 'Precision Rifle', ['weapon_tactilerifle'] = 'Service Carbine', + -- Drug Wars DLC + ['weapon_candycane'] = 'Candy Cane', + ['weapon_acidpackage'] = 'Acid Package', + ['weapon_pistolxm3'] = 'WM 29 Pistol', + ['weapon_railgunxm3'] = 'Railgun', + -- Thrown ['weapon_ball'] = 'Míček', ['weapon_bzgas'] = 'Smrtící slzný plyn', diff --git a/[core]/es_extended/locales/en.lua b/[core]/es_extended/locales/en.lua index e480153f..f2d0d75c 100644 --- a/[core]/es_extended/locales/en.lua +++ b/[core]/es_extended/locales/en.lua @@ -222,6 +222,12 @@ Locales['en'] = { ['weapon_precisionrifle'] = 'Precision Rifle', ['weapon_tactilerifle'] = 'Service Carbine', + -- Drug Wars DLC + ['weapon_candycane'] = 'Candy Cane', + ['weapon_acidpackage'] = 'Acid Package', + ['weapon_pistolxm3'] = 'WM 29 Pistol', + ['weapon_railgunxm3'] = 'Railgun', + -- Thrown ['weapon_ball'] = 'Baseball', ['weapon_bzgas'] = 'BZ Gas', diff --git a/[core]/es_extended/locales/hu.lua b/[core]/es_extended/locales/hu.lua index f909601a..d4b1bd6f 100644 --- a/[core]/es_extended/locales/hu.lua +++ b/[core]/es_extended/locales/hu.lua @@ -222,6 +222,12 @@ Locales["hu"] = { ["weapon_precisionrifle"] = "Precision Rifle", ["weapon_tactilerifle"] = "Service Carbine", + -- Drug Wars DLC + ['weapon_candycane'] = 'Candy Cane', + ['weapon_acidpackage'] = 'Acid Package', + ['weapon_pistolxm3'] = 'WM 29 Pistol', + ['weapon_railgunxm3'] = 'Railgun', + -- Thrown ["weapon_ball"] = "Baseball", ["weapon_bzgas"] = "BZ Gas", From 92f5d3c0bcc4a5e02a53ce964dcfe3999855c512 Mon Sep 17 00:00:00 2001 From: Kuuzoo Date: Wed, 19 Apr 2023 17:19:20 +0200 Subject: [PATCH 02/34] Add Support for Drift Tyres Integrate them into the VehicleProperties Functions, and make sure that they return true on the check so there should be no problems with older builds. Thx to mycroft for the idea with the type <3 Co-Authored-By: Mycroft <22378232+Mycroft-Studios@users.noreply.github.com> --- [core]/es_extended/client/functions.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/[core]/es_extended/client/functions.lua b/[core]/es_extended/client/functions.lua index 90191138..b806fe6e 100644 --- a/[core]/es_extended/client/functions.lua +++ b/[core]/es_extended/client/functions.lua @@ -627,6 +627,11 @@ function ESX.Game.GetVehicleProperties(vehicle) end end + local driftTyresEnabled = false + if type(GetDriftTyresEnabled(vehicle) == boolean) and GetDriftTyresEnabled(vehicle) then + driftTyresEnabled = true + end + local doorsBroken, windowsBroken, tyreBurst = {}, {}, {} local numWheels = tostring(GetVehicleNumberOfWheels(vehicle)) @@ -689,6 +694,7 @@ function ESX.Game.GetVehicleProperties(vehicle) neonColor = table.pack(GetVehicleNeonLightsColour(vehicle)), extras = extras, + dirftTyresEnabled = driftTyresEnabled, tyreSmokeColor = table.pack(GetVehicleTyreSmokeColor(vehicle)), modSpoilers = GetVehicleMod(vehicle, 0), @@ -822,6 +828,10 @@ function ESX.Game.SetVehicleProperties(vehicle, props) end end + if props.driftTyresEnabled then + SetDriftTyresEnabled(vehicle, true) + end + if props.neonColor ~= nil then SetVehicleNeonLightsColour(vehicle, props.neonColor[1], props.neonColor[2], props.neonColor[3]) end From d8b1046d3892fd74012259626ea945262098b54f Mon Sep 17 00:00:00 2001 From: Gergo <69343477+Rav3n95@users.noreply.github.com> Date: Wed, 26 Apr 2023 02:48:12 +0200 Subject: [PATCH 03/34] Update [core]/es_extended/client/functions.lua Co-authored-by: Csoki --- [core]/es_extended/client/functions.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/[core]/es_extended/client/functions.lua b/[core]/es_extended/client/functions.lua index b806fe6e..85a393b6 100644 --- a/[core]/es_extended/client/functions.lua +++ b/[core]/es_extended/client/functions.lua @@ -628,7 +628,7 @@ function ESX.Game.GetVehicleProperties(vehicle) end local driftTyresEnabled = false - if type(GetDriftTyresEnabled(vehicle) == boolean) and GetDriftTyresEnabled(vehicle) then + if type(GetDriftTyresEnabled(vehicle) == "boolean") and GetDriftTyresEnabled(vehicle) then driftTyresEnabled = true end From 349bb41e7373acd814e6c6098e6deeba57bfc035 Mon Sep 17 00:00:00 2001 From: FekyDEV <71899549+FekyDEV@users.noreply.github.com> Date: Fri, 12 May 2023 22:55:40 +0200 Subject: [PATCH 04/34] Added option to externally cancel progress bar Personally, I think this feature should have been here a long time ago. I hope that adding this code will help players in the future and if anyone here has a suggestion for a code change feel free to comment. --- [core]/esx_progressbar/Progress.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/[core]/esx_progressbar/Progress.lua b/[core]/esx_progressbar/Progress.lua index 96a638fb..08923692 100644 --- a/[core]/esx_progressbar/Progress.lua +++ b/[core]/esx_progressbar/Progress.lua @@ -1,4 +1,5 @@ local CurrentProgress = nil + local function Progressbar(message,length,Options) if CurrentProgress then return false @@ -34,9 +35,8 @@ local function Progressbar(message,length,Options) end end -ESX.RegisterInput("cancelprog", "[ProgressBar] Cancel Progressbar", "keyboard", "BACK", function() +local function CancelProgressbar() if not CurrentProgress then return end - if not CurrentProgress.onCancel then return end SendNUIMessage({ type = "Close" }) @@ -44,7 +44,12 @@ ESX.RegisterInput("cancelprog", "[ProgressBar] Cancel Progressbar", "keyboard", if CurrentProgress.FreezePlayer then FreezeEntityPosition(PlayerPedId(), false) end CurrentProgress.canceled = true CurrentProgress.length = 0 - CurrentProgress.onCancel() CurrentProgress = nil +end + +ESX.RegisterInput("cancelprog", "[ProgressBar] Cancel Progressbar", "keyboard", "BACK", function() + CancelProgressbar() end) + exports('Progressbar', Progressbar) +exports('CancelProgressbar', CancelProgressbar) From d979ba4ae8a242c83aed9963b3a37447e2d27719 Mon Sep 17 00:00:00 2001 From: Thekuca <63980591+Thekuca@users.noreply.github.com> Date: Fri, 12 May 2023 23:09:38 +0200 Subject: [PATCH 05/34] Update Progress.lua --- [core]/esx_progressbar/Progress.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/[core]/esx_progressbar/Progress.lua b/[core]/esx_progressbar/Progress.lua index 08923692..3336e4a1 100644 --- a/[core]/esx_progressbar/Progress.lua +++ b/[core]/esx_progressbar/Progress.lua @@ -47,9 +47,7 @@ local function CancelProgressbar() CurrentProgress = nil end -ESX.RegisterInput("cancelprog", "[ProgressBar] Cancel Progressbar", "keyboard", "BACK", function() - CancelProgressbar() -end) +ESX.RegisterInput("cancelprog", "[ProgressBar] Cancel Progressbar", "keyboard", "BACK", CancelProgressbar) exports('Progressbar', Progressbar) exports('CancelProgressbar', CancelProgressbar) From 696277d5bbb2dfb9656b18a049bf3a431c3abfb1 Mon Sep 17 00:00:00 2001 From: thesysadmindev Date: Mon, 15 May 2023 10:41:02 +1000 Subject: [PATCH 06/34] Added Paycheck Logging Added a config variable to config.lua to enable/disable paycheck logging to Discord, added config option to config.logs.lua for Discord webhook and added function into paycheck.lua to send data to webhook containing paycheck information. --- [core]/es_extended/config.logs.lua | 3 ++- [core]/es_extended/config.lua | 1 + [core]/es_extended/server/paycheck.lua | 29 ++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/[core]/es_extended/config.logs.lua b/[core]/es_extended/config.logs.lua index b58a8fed..34f91641 100644 --- a/[core]/es_extended/config.logs.lua +++ b/[core]/es_extended/config.logs.lua @@ -4,7 +4,8 @@ Config.DiscordLogs = { test = '', Chat = '', UserActions = '', - Resources = '' + Resources = '', + Paycheck = '' }, Colors = { -- https://www.spycolor.com/ diff --git a/[core]/es_extended/config.lua b/[core]/es_extended/config.lua index cb13fb33..62b38a21 100644 --- a/[core]/es_extended/config.lua +++ b/[core]/es_extended/config.lua @@ -21,6 +21,7 @@ Config.StartingAccountMoney = {bank = 50000} Config.DefaultSpawn = {x = -269.4, y = -955.3, z = 31.2, heading = 205.8} Config.EnablePaycheck = true -- enable paycheck +Config.LogPaycheck = false -- Logs paychecks to a nominated Discord channel via webhook (default is false) Config.EnableSocietyPayouts = false -- pay from the society account that the player is employed at? Requirement: esx_society Config.MaxWeight = 24 -- the max inventory weight without backpack Config.PaycheckInterval = 7 * 60000 -- how often to recieve pay checks in milliseconds diff --git a/[core]/es_extended/server/paycheck.lua b/[core]/es_extended/server/paycheck.lua index 1f234a57..ba5b776b 100644 --- a/[core]/es_extended/server/paycheck.lua +++ b/[core]/es_extended/server/paycheck.lua @@ -4,6 +4,7 @@ function StartPayCheck() Wait(Config.PaycheckInterval) for player, xPlayer in pairs(ESX.Players) do + local jobLabel = xPlayer.job.label local job = xPlayer.job.grade_name local salary = xPlayer.job.grade_salary @@ -12,6 +13,13 @@ function StartPayCheck() xPlayer.addAccountMoney('bank', salary, "Welfare Check") TriggerClientEvent('esx:showAdvancedNotification', player, TranslateCap('bank'), TranslateCap('received_paycheck'), TranslateCap('received_help', salary), 'CHAR_BANK_MAZE', 9) + if Config.LogPaycheck then + ESX.DiscordLogFields("Paycheck", "Paycheck - Unemployment Benefits", "green", { + {name = "Player", value = xPlayer.name, inline = true}, + {name = "ID", value = xPlayer.source, inline = true}, + {name = "Amount", value = salary, inline = true} + }) + end elseif Config.EnableSocietyPayouts then -- possibly a society TriggerEvent('esx_society:getSociety', xPlayer.job.name, function(society) if society ~= nil then -- verified society @@ -19,6 +27,13 @@ function StartPayCheck() if account.money >= salary then -- does the society money to pay its employees? xPlayer.addAccountMoney('bank', salary, "Paycheck") account.removeMoney(salary) + if Config.LogPaycheck then + ESX.DiscordLogFields("Paycheck", "Paycheck - "..jobLabel, "green", { + {name = "Player", value = xPlayer.name, inline = true}, + {name = "ID", value = xPlayer.source, inline = true}, + {name = "Amount", value = salary, inline = true} + }) + end TriggerClientEvent('esx:showAdvancedNotification', player, TranslateCap('bank'), TranslateCap('received_paycheck'), TranslateCap('received_salary', salary), 'CHAR_BANK_MAZE', 9) @@ -28,12 +43,26 @@ function StartPayCheck() end) else -- not a society xPlayer.addAccountMoney('bank', salary, "Paycheck") + if Config.LogPaycheck then + ESX.DiscordLogFields("Paycheck", "Paycheck - "..jobLabel, "green", { + {name = "Player", value = xPlayer.name, inline = true}, + {name = "ID", value = xPlayer.source, inline = true}, + {name = "Amount", value = salary, inline = true} + }) + end TriggerClientEvent('esx:showAdvancedNotification', player, TranslateCap('bank'), TranslateCap('received_paycheck'), TranslateCap('received_salary', salary), 'CHAR_BANK_MAZE', 9) end end) else -- generic job xPlayer.addAccountMoney('bank', salary, "Paycheck") + if Config.LogPaycheck then + ESX.DiscordLogFields("Paycheck", "Paycheck - Generic", "green", { + {name = "Player", value = xPlayer.name, inline = true}, + {name = "ID", value = xPlayer.source, inline = true}, + {name = "Amount", value = salary, inline = true} + }) + end TriggerClientEvent('esx:showAdvancedNotification', player, TranslateCap('bank'), TranslateCap('received_paycheck'), TranslateCap('received_salary', salary), 'CHAR_BANK_MAZE', 9) end From 40c22f5685209e42407f0017fddefa8af57a646b Mon Sep 17 00:00:00 2001 From: thesysadmindev Date: Tue, 16 May 2023 10:16:35 +1000 Subject: [PATCH 07/34] Added logging to Discord for sensitive commands 1. Added config variable to config.lua to enable/disable admin logging. 2. Added ESX.DiscordLogFields function to a number of sensitive admin commands (such as /setaccountmoney and /giveweapon). --- [core]/es_extended/config.lua | 2 + [core]/es_extended/server/commands.lua | 174 +++++++++++++++++++++++-- 2 files changed, 164 insertions(+), 12 deletions(-) diff --git a/[core]/es_extended/config.lua b/[core]/es_extended/config.lua index 62b38a21..70e2280d 100644 --- a/[core]/es_extended/config.lua +++ b/[core]/es_extended/config.lua @@ -34,6 +34,8 @@ Config.Multichar = GetResourceState("esx_multicharacter") ~= "mis Config.Identity = true -- Select a characters identity data before they have loaded in (this happens by default with multichar) Config.DistanceGive = 4.0 -- Max distance when giving items, weapons etc. +Config.AdminLogging = false -- Logs the usage of certain commands by those with group.admin ace permissions (default is false) + Config.DisableHealthRegeneration = false -- Player will no longer regenerate health Config.DisableVehicleRewards = false -- Disables Player Recieving weapons from vehicles Config.DisableNPCDrops = false -- stops NPCs from dropping weapons on death diff --git a/[core]/es_extended/server/commands.lua b/[core]/es_extended/server/commands.lua index 5573b56b..cae042f7 100644 --- a/[core]/es_extended/server/commands.lua +++ b/[core]/es_extended/server/commands.lua @@ -1,5 +1,14 @@ ESX.RegisterCommand('setcoords', 'admin', function(xPlayer, args, showError) xPlayer.setCoords({x = args.x, y = args.y, z = args.z}) + if Config.AdminLogging then + ESX.DiscordLogFields("UserActions", "Set Coordinates /setcoords Triggered!", "pink", { + {name = "Player", value = xPlayer.name, inline = true}, + {name = "ID", value = xPlayer.source, inline = true}, + {name = "X Coord", value = args.x, inline = true}, + {name = "Y Coord", value = args.y, inline = true}, + {name = "Z Coord", value = args.z, inline = true}, + }) + end end, false, {help = TranslateCap('command_setcoords'), validate = true, arguments = { {name = 'x', help = TranslateCap('command_setcoords_x'), type = 'number'}, {name = 'y', help = TranslateCap('command_setcoords_y'), type = 'number'}, @@ -9,16 +18,18 @@ end, false, {help = TranslateCap('command_setcoords'), validate = true, argument ESX.RegisterCommand('setjob', 'admin', function(xPlayer, args, showError) if ESX.DoesJobExist(args.job, args.grade) then args.playerId.setJob(args.job, args.grade) + if Config.AdminLogging then + ESX.DiscordLogFields("UserActions", "Set Job /setjob Triggered!", "pink", { + {name = "Player", value = xPlayer.name, inline = true}, + {name = "ID", value = xPlayer.source, inline = true}, + {name = "Target", value = args.playerId.name, inline = true}, + {name = "Job", value = args.playerId, inline = true}, + {name = "Grade", value = args.playerId, inline = true}, + }) + end else showError(TranslateCap('command_setjob_invalid')) end - - ESX.DiscordLogFields("UserActions", "/setjob Triggered", "pink", { - {name = "Executor", value = xPlayer and xPlayer.name or 'Console', inline = true}, - {name = "Target", value = args.playerId.name, inline = true}, - {name = "Job", value = args.job, inline = true}, - {name = "Grade", value = args.grade, inline = true} - }) end, true, {help = TranslateCap('command_setjob'), validate = true, arguments = { {name = 'playerId', help = TranslateCap('commandgeneric_playerid'), type = 'player'}, {name = 'job', help = TranslateCap('command_setjob_job'), type = 'string'}, @@ -54,11 +65,13 @@ ESX.RegisterCommand('car', 'admin', function(xPlayer, args, showError) DeleteEntity(playerVehicle) end - ESX.DiscordLogFields("UserActions", "/car Triggered", "pink", { - {name = "Player", value = xPlayer.name, inline = true}, - {name = "ID", value = xPlayer.source, inline = true}, - {name = "Vehicle", value = args.car, inline = true} - }) + if Config.AdminLogging then + ESX.DiscordLogFields("UserActions", "Spawn Car /car Triggered!", "pink", { + {name = "Player", value = xPlayer.name, inline = true}, + {name = "ID", value = xPlayer.source, inline = true}, + {name = "Vehicle", value = args.car, inline = true} + }) + end ESX.OneSync.SpawnVehicle(args.car, playerCoords, playerHeading, upgrades, function(networkId) if networkId then @@ -92,6 +105,12 @@ ESX.RegisterCommand({'cardel', 'dv'}, 'admin', function(xPlayer, args, showError DeleteEntity(Vehicle) end end + if Config.AdminLogging then + ESX.DiscordLogFields("UserActions", "Delete Vehicle /dv Triggered!", "pink", { + {name = "Player", value = xPlayer.name, inline = true}, + {name = "ID", value = xPlayer.source, inline = true}, + }) + end end, false, {help = TranslateCap('command_cardel'), validate = false, arguments = { {name = 'radius',validate = false, help = TranslateCap('command_cardel_radius'), type = 'number'} }}) @@ -99,6 +118,15 @@ end, false, {help = TranslateCap('command_cardel'), validate = false, arguments ESX.RegisterCommand('setaccountmoney', 'admin', function(xPlayer, args, showError) if args.playerId.getAccount(args.account) then args.playerId.setAccountMoney(args.account, args.amount, "Government Grant") + if Config.AdminLogging then + ESX.DiscordLogFields("UserActions", "Set Account Money /setaccountmoney Triggered!", "pink", { + {name = "Player", value = xPlayer.name, inline = true}, + {name = "ID", value = xPlayer.source, inline = true}, + {name = "Target", value = args.playerId.name, inline = true}, + {name = "Account", value = args.account, inline = true}, + {name = "Amount", value = args.amount, inline = true}, + }) + end else showError(TranslateCap('command_giveaccountmoney_invalid')) end @@ -111,6 +139,15 @@ end, true, {help = TranslateCap('command_setaccountmoney'), validate = true, arg ESX.RegisterCommand('giveaccountmoney', 'admin', function(xPlayer, args, showError) if args.playerId.getAccount(args.account) then args.playerId.addAccountMoney(args.account, args.amount, "Government Grant") + if Config.AdminLogging then + ESX.DiscordLogFields("UserActions", "Give Account Money /giveaccountmoney Triggered!", "pink", { + {name = "Player", value = xPlayer.name, inline = true}, + {name = "ID", value = xPlayer.source, inline = true}, + {name = "Target", value = args.playerId.name, inline = true}, + {name = "Account", value = args.account, inline = true}, + {name = "Amount", value = args.amount, inline = true}, + }) + end else showError(TranslateCap('command_giveaccountmoney_invalid')) end @@ -123,6 +160,15 @@ end, true, {help = TranslateCap('command_giveaccountmoney'), validate = true, ar if not Config.OxInventory then ESX.RegisterCommand('giveitem', 'admin', function(xPlayer, args, showError) args.playerId.addInventoryItem(args.item, args.count) + if Config.AdminLogging then + ESX.DiscordLogFields("UserActions", "Give Item /giveitem Triggered!", "pink", { + {name = "Player", value = xPlayer.name, inline = true}, + {name = "ID", value = xPlayer.source, inline = true}, + {name = "Target", value = args.playerId.name, inline = true}, + {name = "Item", value = args.item, inline = true}, + {name = "Quantity", value = args.count, inline = true}, + }) + end end, true, {help = TranslateCap('command_giveitem'), validate = true, arguments = { {name = 'playerId', help = TranslateCap('commandgeneric_playerid'), type = 'player'}, {name = 'item', help = TranslateCap('command_giveitem_item'), type = 'item'}, @@ -134,6 +180,15 @@ if not Config.OxInventory then showError(TranslateCap('command_giveweapon_hasalready')) else args.playerId.addWeapon(args.weapon, args.ammo) + if Config.AdminLogging then + ESX.DiscordLogFields("UserActions", "Give Weapon /giveweapon Triggered!", "pink", { + {name = "Player", value = xPlayer.name, inline = true}, + {name = "ID", value = xPlayer.source, inline = true}, + {name = "Target", value = args.playerId.name, inline = true}, + {name = "Weapon", value = args.weapon, inline = true}, + {name = "Ammo", value = args.ammo, inline = true}, + }) + end end end, true, {help = TranslateCap('command_giveweapon'), validate = true, arguments = { {name = 'playerId', help = TranslateCap('commandgeneric_playerid'), type = 'player'}, @@ -144,6 +199,15 @@ if not Config.OxInventory then ESX.RegisterCommand('giveammo', 'admin', function(xPlayer, args, showError) if args.playerId.hasWeapon(args.weapon) then args.playerId.addWeaponAmmo(args.weapon, args.ammo) + if Config.AdminLogging then + ESX.DiscordLogFields("UserActions", "Give Ammunition /giveammo Triggered!", "pink", { + {name = "Player", value = xPlayer.name, inline = true}, + {name = "ID", value = xPlayer.source, inline = true}, + {name = "Target", value = args.playerId.name, inline = true}, + {name = "Weapon", value = args.weapon, inline = true}, + {name = "Ammo", value = args.ammo, inline = true}, + }) + end else showError(TranslateCap("command_giveammo_noweapon_found")) end @@ -162,6 +226,15 @@ if not Config.OxInventory then showError(TranslateCap('command_giveweaponcomponent_hasalready')) else args.playerId.addWeaponComponent(args.weaponName, args.componentName) + if Config.AdminLogging then + ESX.DiscordLogFields("UserActions", "Give Weapon Component /giveweaponcomponent Triggered!", "pink", { + {name = "Player", value = xPlayer.name, inline = true}, + {name = "ID", value = xPlayer.source, inline = true}, + {name = "Target", value = args.playerId.name, inline = true}, + {name = "Weapon", value = args.weaponName, inline = true}, + {name = "Component", value = args.componentName, inline = true}, + }) + end end else showError(TranslateCap('command_giveweaponcomponent_invalid')) @@ -182,6 +255,12 @@ end, false, {help = TranslateCap('command_clear')}) ESX.RegisterCommand({'clearall', 'clsall'}, 'admin', function(xPlayer, args, showError) TriggerClientEvent('chat:clear', -1) + if Config.AdminLogging then + ESX.DiscordLogFields("UserActions", "Clear Chat /clearall Triggered!", "pink", { + {name = "Player", value = xPlayer.name, inline = true}, + {name = "ID", value = xPlayer.source, inline = true}, + }) + end end, true, {help = TranslateCap('command_clearall')}) ESX.RegisterCommand("refreshjobs", 'admin', function(xPlayer, args, showError) @@ -196,6 +275,13 @@ if not Config.OxInventory then end end TriggerEvent('esx:playerInventoryCleared',args.playerId) + if Config.AdminLogging then + ESX.DiscordLogFields("UserActions", "Clear Inventory /clearinventory Triggered!", "pink", { + {name = "Player", value = xPlayer.name, inline = true}, + {name = "ID", value = xPlayer.source, inline = true}, + {name = "Target", value = args.playerId.name, inline = true}, + }) + end end, true, {help = TranslateCap('command_clearinventory'), validate = true, arguments = { {name = 'playerId', help = TranslateCap('commandgeneric_playerid'), type = 'player'} }}) @@ -205,6 +291,13 @@ if not Config.OxInventory then args.playerId.removeWeapon(args.playerId.loadout[i].name) end TriggerEvent('esx:playerLoadoutCleared',args.playerId) + if Config.AdminLogging then + ESX.DiscordLogFields("UserActions", "/clearloadout Triggered!", "pink", { + {name = "Player", value = xPlayer.name, inline = true}, + {name = "ID", value = xPlayer.source, inline = true}, + {name = "Target", value = args.playerId.name, inline = true}, + }) + end end, true, {help = TranslateCap('command_clearloadout'), validate = true, arguments = { {name = 'playerId', help = TranslateCap('commandgeneric_playerid'), type = 'player'} }}) @@ -214,6 +307,14 @@ ESX.RegisterCommand('setgroup', 'admin', function(xPlayer, args, showError) if not args.playerId then args.playerId = xPlayer.source end if args.group == "superadmin" then args.group = "admin" print("[^3WARNING^7] ^5Superadmin^7 detected, setting group to ^5admin^7") end args.playerId.setGroup(args.group) + if Config.AdminLogging then + ESX.DiscordLogFields("UserActions", "/setgroup Triggered!", "pink", { + {name = "Player", value = xPlayer.name, inline = true}, + {name = "ID", value = xPlayer.source, inline = true}, + {name = "Target", value = args.playerId.name, inline = true}, + {name = "Group", value = args.group, inline = true}, + }) + end end, true, {help = TranslateCap('command_setgroup'), validate = true, arguments = { {name = 'playerId', help = TranslateCap('commandgeneric_playerid'), type = 'player'}, {name = 'group', help = TranslateCap('command_setgroup_group'), type = 'string'}, @@ -254,11 +355,25 @@ end, true) ESX.RegisterCommand('tpm', "admin", function(xPlayer, args, showError) xPlayer.triggerEvent("esx:tpm") + if Config.AdminLogging then + ESX.DiscordLogFields("UserActions", "Admin Teleport /tpm Triggered!", "pink", { + {name = "Player", value = xPlayer.name, inline = true}, + {name = "ID", value = xPlayer.source, inline = true}, + }) + end end, true) ESX.RegisterCommand('goto', "admin", function(xPlayer, args, showError) local targetCoords = args.playerId.getCoords() xPlayer.setCoords(targetCoords) + if Config.AdminLogging then + ESX.DiscordLogFields("UserActions", "Admin Teleport /goto Triggered!", "pink", { + {name = "Player", value = xPlayer.name, inline = true}, + {name = "ID", value = xPlayer.source, inline = true}, + {name = "Target", value = args.playerId.name, inline = true}, + {name = "Target Coords", value = targetCoords, inline = true}, + }) + end end, true, {help = TranslateCap('command_goto'), validate = true, arguments = { {name = 'playerId', help = TranslateCap('commandgeneric_playerid'), type = 'player'} }}) @@ -266,30 +381,65 @@ end, true, {help = TranslateCap('command_goto'), validate = true, arguments = { ESX.RegisterCommand('bring', "admin", function(xPlayer, args, showError) local playerCoords = xPlayer.getCoords() args.playerId.setCoords(playerCoords) + if Config.AdminLogging then + ESX.DiscordLogFields("UserActions", "Admin Teleport /bring Triggered!", "pink", { + {name = "Player", value = xPlayer.name, inline = true}, + {name = "ID", value = xPlayer.source, inline = true}, + {name = "Target", value = args.playerId.name, inline = true}, + {name = "Target Coords", value = targetCoords, inline = true}, + }) + end end, true, {help = TranslateCap('command_bring'), validate = true, arguments = { {name = 'playerId', help = TranslateCap('commandgeneric_playerid'), type = 'player'} }}) ESX.RegisterCommand('kill', "admin", function(xPlayer, args, showError) args.playerId.triggerEvent("esx:killPlayer") + if Config.AdminLogging then + ESX.DiscordLogFields("UserActions", "Kill Command /kill Triggered!", "pink", { + {name = "Player", value = xPlayer.name, inline = true}, + {name = "ID", value = xPlayer.source, inline = true}, + {name = "Target", value = args.playerId.name, inline = true}, + }) + end end, true, {help = TranslateCap('command_kill'), validate = true, arguments = { {name = 'playerId', help = TranslateCap('commandgeneric_playerid'), type = 'player'} }}) ESX.RegisterCommand('freeze', "admin", function(xPlayer, args, showError) args.playerId.triggerEvent('esx:freezePlayer', "freeze") + if Config.AdminLogging then + ESX.DiscordLogFields("UserActions", "Admin Freeze /freeze Triggered!", "pink", { + {name = "Player", value = xPlayer.name, inline = true}, + {name = "ID", value = xPlayer.source, inline = true}, + {name = "Target", value = args.playerId.name, inline = true}, + }) + end end, true, {help = TranslateCap('command_freeze'), validate = true, arguments = { {name = 'playerId', help = TranslateCap('commandgeneric_playerid'), type = 'player'} }}) ESX.RegisterCommand('unfreeze', "admin", function(xPlayer, args, showError) args.playerId.triggerEvent('esx:freezePlayer', "unfreeze") + if Config.AdminLogging then + ESX.DiscordLogFields("UserActions", "Admin UnFreeze /unfreeze Triggered!", "pink", { + {name = "Player", value = xPlayer.name, inline = true}, + {name = "ID", value = xPlayer.source, inline = true}, + {name = "Target", value = args.playerId.name, inline = true}, + }) + end end, true, {help = TranslateCap('command_unfreeze'), validate = true, arguments = { {name = 'playerId', help = TranslateCap('commandgeneric_playerid'), type = 'player'} }}) ESX.RegisterCommand("noclip", 'admin', function(xPlayer, args, showError) xPlayer.triggerEvent('esx:noclip') + if Config.AdminLogging then + ESX.DiscordLogFields("UserActions", "Admin NoClip /noclip Triggered!", "pink", { + {name = "Player", value = xPlayer.name, inline = true}, + {name = "ID", value = xPlayer.source, inline = true}, + }) + end end, false) ESX.RegisterCommand('players', "admin", function(xPlayer, args, showError) From bfd0d9ef5ea25dde6e5469f82ac212f6e93edb54 Mon Sep 17 00:00:00 2001 From: Thekuca <63980591+Thekuca@users.noreply.github.com> Date: Fri, 19 May 2023 14:47:22 +0200 Subject: [PATCH 08/34] refactor(Admin Check): refactor admin checking --- [core]/es_extended/config.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/[core]/es_extended/config.lua b/[core]/es_extended/config.lua index 70e2280d..701028bf 100644 --- a/[core]/es_extended/config.lua +++ b/[core]/es_extended/config.lua @@ -18,6 +18,11 @@ Config.Accounts = { Config.StartingAccountMoney = {bank = 50000} +Config.AdminGroups = { + ['owner'] = true, + ['admin'] = true +} + Config.DefaultSpawn = {x = -269.4, y = -955.3, z = 31.2, heading = 205.8} Config.EnablePaycheck = true -- enable paycheck From 939958542384eedd404e3c9e784f235d41ebc985 Mon Sep 17 00:00:00 2001 From: Thekuca <63980591+Thekuca@users.noreply.github.com> Date: Fri, 19 May 2023 14:48:31 +0200 Subject: [PATCH 09/34] refactor(Admin Check): refactor admin checking --- [core]/es_extended/server/functions.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/[core]/es_extended/server/functions.lua b/[core]/es_extended/server/functions.lua index 76f9e2c4..31b0c1a9 100644 --- a/[core]/es_extended/server/functions.lua +++ b/[core]/es_extended/server/functions.lua @@ -454,7 +454,7 @@ function Core.IsPlayerAdmin(playerId) local xPlayer = ESX.Players[playerId] if xPlayer then - if xPlayer.group == 'admin' then + if Config.AdminGroups[xPlayer.group] then return true end end From 03a79177027cea96e98b4d681d927f3f693b6e6e Mon Sep 17 00:00:00 2001 From: Thekuca <63980591+Thekuca@users.noreply.github.com> Date: Fri, 19 May 2023 15:00:42 +0200 Subject: [PATCH 10/34] refactor(client/functions): refactor code --- [core]/es_extended/client/functions.lua | 32 ++++++++++--------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/[core]/es_extended/client/functions.lua b/[core]/es_extended/client/functions.lua index 5a381fa9..d42fbd44 100644 --- a/[core]/es_extended/client/functions.lua +++ b/[core]/es_extended/client/functions.lua @@ -401,8 +401,8 @@ function ESX.Game.DeleteObject(object) DeleteObject(object) end -function ESX.Game.SpawnVehicle(vehicle, coords, heading, cb, networked) - local model = type(vehicle) == 'number' and vehicle or joaat(vehicle) +function ESX.Game.SpawnVehicle(model, coords, heading, cb, networked) + local model = type(model) == 'number' and model or joaat(model) local vector = type(coords) == "vector3" and coords or vec(coords.x, coords.y, coords.z) networked = networked == nil and true or networked @@ -1087,17 +1087,11 @@ function ESX.ShowInventory() local weaponHash = joaat(v.name) if HasPedGotWeapon(playerPed, weaponHash, false) then - local ammo, label = GetAmmoInPedWeapon(playerPed, weaponHash) - - if v.ammo then - label = ('%s - %s %s'):format(v.label, ammo, v.ammo.label) - else - label = v.label - end + local ammo = GetAmmoInPedWeapon(playerPed, weaponHash) elements[#elements+1] = { icon = 'fas fa-gun', - title = label, + title = v.ammo and ('%s - %s %s'):format(v.label, ammo, v.ammo.label) or v.label, count = 1, type = 'item_weapon', value = v.name, @@ -1118,10 +1112,10 @@ function ESX.ShowInventory() ESX.CloseContext() - ESX.OpenContext("right", elements, function(menu,element) + ESX.OpenContext("right", elements, function(_, element) local player, distance = ESX.Game.GetClosestPlayer() - elements2 = {} + local elements2 = {} if element.usable then elements2[#elements2+1] = { @@ -1169,7 +1163,7 @@ function ESX.ShowInventory() action = 'return' } - ESX.OpenContext("right", elements2, function(menu2,element2) + ESX.OpenContext("right", elements2, function(_, element2) local item, type = element2.value, element2.type if element2.action == "give" then @@ -1177,7 +1171,7 @@ function ESX.ShowInventory() if #playersNearby > 0 then local players = {} - elements3 = { + local elements3 = { {unselectable = true, icon = "fas fa-users", title = "Nearby Players"} } @@ -1194,7 +1188,7 @@ function ESX.ShowInventory() } end - ESX.OpenContext("right", elements3, function(menu3,element3) + ESX.OpenContext("right", elements3, function(_, element3) local selectedPlayer, selectedPlayerId = GetPlayerFromServerId(element3.playerId), element3.playerId playersNearby = ESX.Game.GetPlayersInArea(GetEntityCoords(playerPed), 3.0) playersNearby = ESX.Table.Set(playersNearby) @@ -1213,7 +1207,7 @@ function ESX.ShowInventory() {icon = "fas fa-check-double", title = "Confirm", val = "confirm"} } - ESX.OpenContext("right", elementsG, function(menuG,elementG) + ESX.OpenContext("right", elementsG, function(menuG, _) local quantity = tonumber(menuG.eles[2].inputValue) if quantity and quantity > 0 and element.count >= quantity then @@ -1252,7 +1246,7 @@ function ESX.ShowInventory() {icon = "fas fa-check-double", title = "Confirm", val = "confirm"} } - ESX.OpenContext("right", elementsR, function(menuR,elementR) + ESX.OpenContext("right", elementsR, function(menuR, _) local quantity = tonumber(menuR.eles[2].inputValue) if quantity and quantity > 0 and element.count >= quantity then @@ -1287,7 +1281,7 @@ function ESX.ShowInventory() {icon = "fas fa-check-double", title = "Confirm", val = "confirm"} } - ESX.OpenContext("right", elementsGA, function(menuGA,elementGA) + ESX.OpenContext("right", elementsGA, function(menuGA, _) local quantity = tonumber(menuGA.eles[2].inputValue) if quantity and quantity > 0 then @@ -1352,4 +1346,4 @@ function ESX.GetVehicleType(model) } return types[vehicleType] or "automobile" -end \ No newline at end of file +end From 353d9df9f77953795ec2f0319892287eca32fd1e Mon Sep 17 00:00:00 2001 From: Thekuca <63980591+Thekuca@users.noreply.github.com> Date: Fri, 19 May 2023 15:06:32 +0200 Subject: [PATCH 11/34] refactor(client/main): refactor code --- [core]/es_extended/client/main.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/[core]/es_extended/client/main.lua b/[core]/es_extended/client/main.lua index 436c2056..1ddc15be 100644 --- a/[core]/es_extended/client/main.lua +++ b/[core]/es_extended/client/main.lua @@ -76,7 +76,7 @@ AddEventHandler('esx:playerLoaded', function(xPlayer, isNew, skin) end if Config.DisableVehicleSeatShuff then - AddEventHandler('esx:enteredVehicle', function(vehicle, plate, seat) + AddEventHandler('esx:enteredVehicle', function(vehicle, _, seat) if seat == 0 then SetPedIntoVehicle(ESX.PlayerData.ped, vehicle, 0) SetPedConfigFlag(ESX.PlayerData.ped, 184, true) @@ -241,7 +241,7 @@ AddEventHandler('esx:restoreLoadout', function() end) -- Credit: https://github.com/LukeWasTakenn, https://github.com/LukeWasTakenn/luke_garages/blob/master/client/client.lua#L331-L352 -AddStateBagChangeHandler('VehicleProperties', nil, function(bagName, key, value) +AddStateBagChangeHandler('VehicleProperties', nil, function(bagName, _, value) if not value then return end @@ -254,12 +254,12 @@ AddStateBagChangeHandler('VehicleProperties', nil, function(bagName, key, value) return end end - + local vehicle = NetToVeh(tonumber(netId)) - local timer = GetGameTimer() + local timer2 = GetGameTimer() while NetworkGetEntityOwner(vehicle) ~= PlayerId() do Wait(0) - if GetGameTimer() - timer > 10000 then + if GetGameTimer() - timer2 > 10000 then return end end @@ -707,4 +707,4 @@ end RegisterNetEvent('esx:updatePlayerData', function(key, val) ESX.SetPlayerData(key, val) -end) \ No newline at end of file +end) From ff3ee5843e7746e8f86fa75fbfa03dab919b7e27 Mon Sep 17 00:00:00 2001 From: Thekuca <63980591+Thekuca@users.noreply.github.com> Date: Fri, 19 May 2023 15:12:45 +0200 Subject: [PATCH 12/34] fix(client/functions): shadowing upvalue --- [core]/es_extended/client/functions.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/[core]/es_extended/client/functions.lua b/[core]/es_extended/client/functions.lua index d42fbd44..4319769d 100644 --- a/[core]/es_extended/client/functions.lua +++ b/[core]/es_extended/client/functions.lua @@ -401,8 +401,8 @@ function ESX.Game.DeleteObject(object) DeleteObject(object) end -function ESX.Game.SpawnVehicle(model, coords, heading, cb, networked) - local model = type(model) == 'number' and model or joaat(model) +function ESX.Game.SpawnVehicle(vehicleModel, coords, heading, cb, networked) + local model = type(vehicleModel) == 'number' and vehicleModel or joaat(vehicleModel) local vector = type(coords) == "vector3" and coords or vec(coords.x, coords.y, coords.z) networked = networked == nil and true or networked From bb526ea0bc16ff17528bbbce05244f969be9da9b Mon Sep 17 00:00:00 2001 From: Thekuca <63980591+Thekuca@users.noreply.github.com> Date: Fri, 19 May 2023 15:19:00 +0200 Subject: [PATCH 13/34] refactor(common/modules/table): small refactor --- [core]/es_extended/common/modules/table.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/[core]/es_extended/common/modules/table.lua b/[core]/es_extended/common/modules/table.lua index 0d5c0002..c582d59b 100644 --- a/[core]/es_extended/common/modules/table.lua +++ b/[core]/es_extended/common/modules/table.lua @@ -119,12 +119,11 @@ function ESX.Table.Concat(t1, t2) end function ESX.Table.Join(t, sep) - local sep = sep or ',' local str = '' for i = 1, #t, 1 do if i > 1 then - str = str .. sep + str = str .. (sep or ',') end str = str .. t[i] From 648147f99e6a8c23ec6d08668ebcd2966ca675ab Mon Sep 17 00:00:00 2001 From: Thekuca <63980591+Thekuca@users.noreply.github.com> Date: Fri, 19 May 2023 15:24:07 +0200 Subject: [PATCH 14/34] refactor(overrides/oxinventory): unused args --- .../server/classes/overrides/oxinventory.lua | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/[core]/es_extended/server/classes/overrides/oxinventory.lua b/[core]/es_extended/server/classes/overrides/oxinventory.lua index 0bc5fe67..4b4aa349 100644 --- a/[core]/es_extended/server/classes/overrides/oxinventory.lua +++ b/[core]/es_extended/server/classes/overrides/oxinventory.lua @@ -36,7 +36,7 @@ Core.PlayerFunctionOverrides.OxInventory = { end end, - getLoadout = function(self) + getLoadout = function(_) return function() return {} end @@ -144,49 +144,49 @@ Core.PlayerFunctionOverrides.OxInventory = { end end, - addWeapon = function(self) + addWeapon = function(_) return function() end end, - addWeaponComponent = function(self) + addWeaponComponent = function(_) return function() end end, - addWeaponAmmo = function(self) + addWeaponAmmo = function(_) return function() end end, - updateWeaponAmmo = function(self) + updateWeaponAmmo = function(_) return function() end end, - setWeaponTint = function(self) + setWeaponTint = function(_) return function() end end, - getWeaponTint = function(self) + getWeaponTint = function(_) return function() end end, - removeWeapon = function(self) + removeWeapon = function(_) return function() end end, - removeWeaponComponent = function(self) + removeWeaponComponent = function(_) return function() end end, - removeWeaponAmmo = function(self) + removeWeaponAmmo = function(_) return function() end end, - hasWeaponComponent = function(self) + hasWeaponComponent = function(_) return function() return false end end, - hasWeapon = function(self) + hasWeapon = function(_) return function() return false end @@ -198,7 +198,7 @@ Core.PlayerFunctionOverrides.OxInventory = { end end, - getWeapon = function(self) + getWeapon = function(_) return function() end end, From fec1a9d8aaa8381c616806f11c6d45a80f9ed52e Mon Sep 17 00:00:00 2001 From: Thekuca <63980591+Thekuca@users.noreply.github.com> Date: Fri, 19 May 2023 15:53:16 +0200 Subject: [PATCH 15/34] refactor(server/commands): refactor code --- [core]/es_extended/server/commands.lua | 176 ++++++++++++------------- 1 file changed, 86 insertions(+), 90 deletions(-) diff --git a/[core]/es_extended/server/commands.lua b/[core]/es_extended/server/commands.lua index cae042f7..4cedd62f 100644 --- a/[core]/es_extended/server/commands.lua +++ b/[core]/es_extended/server/commands.lua @@ -1,4 +1,4 @@ -ESX.RegisterCommand('setcoords', 'admin', function(xPlayer, args, showError) +ESX.RegisterCommand('setcoords', 'admin', function(xPlayer, args, _) xPlayer.setCoords({x = args.x, y = args.y, z = args.z}) if Config.AdminLogging then ESX.DiscordLogFields("UserActions", "Set Coordinates /setcoords Triggered!", "pink", { @@ -16,19 +16,19 @@ end, false, {help = TranslateCap('command_setcoords'), validate = true, argument }}) ESX.RegisterCommand('setjob', 'admin', function(xPlayer, args, showError) - if ESX.DoesJobExist(args.job, args.grade) then - args.playerId.setJob(args.job, args.grade) - if Config.AdminLogging then - ESX.DiscordLogFields("UserActions", "Set Job /setjob Triggered!", "pink", { - {name = "Player", value = xPlayer.name, inline = true}, - {name = "ID", value = xPlayer.source, inline = true}, - {name = "Target", value = args.playerId.name, inline = true}, - {name = "Job", value = args.playerId, inline = true}, - {name = "Grade", value = args.playerId, inline = true}, - }) - end - else - showError(TranslateCap('command_setjob_invalid')) + if not ESX.DoesJobExist(args.job, args.grade) then + return showError(TranslateCap('command_setjob_invalid')) + end + + args.playerId.setJob(args.job, args.grade) + if Config.AdminLogging then + ESX.DiscordLogFields("UserActions", "Set Job /setjob Triggered!", "pink", { + {name = "Player", value = xPlayer.name, inline = true}, + {name = "ID", value = xPlayer.source, inline = true}, + {name = "Target", value = args.playerId.name, inline = true}, + {name = "Job", value = args.playerId, inline = true}, + {name = "Grade", value = args.playerId, inline = true}, + }) end end, true, {help = TranslateCap('command_setjob'), validate = true, arguments = { {name = 'playerId', help = TranslateCap('commandgeneric_playerid'), type = 'player'}, @@ -49,7 +49,7 @@ local upgrades = Config.SpawnVehMaxUpgrades and ESX.RegisterCommand('car', 'admin', function(xPlayer, args, showError) if not xPlayer then - return print('[^1ERROR^7] The xPlayer value is nil') + return showError('[^1ERROR^7] The xPlayer value is nil') end local playerPed = GetPlayerPed(xPlayer.source) @@ -85,7 +85,7 @@ ESX.RegisterCommand('car', 'admin', function(xPlayer, args, showError) end end if GetVehiclePedIsIn(playerPed, false) ~= vehicle then - print('[^1ERROR^7] The player could not be seated in the vehicle') + showError('[^1ERROR^7] The player could not be seated in the vehicle') end end end) @@ -93,13 +93,13 @@ end, false, {help = TranslateCap('command_car'), validate = false, arguments = { {name = 'car',validate = false, help = TranslateCap('command_car_car'), type = 'string'} }}) -ESX.RegisterCommand({'cardel', 'dv'}, 'admin', function(xPlayer, args, showError) +ESX.RegisterCommand({'cardel', 'dv'}, 'admin', function(xPlayer, args, _) local PedVehicle = GetVehiclePedIsIn(GetPlayerPed(xPlayer.source), false) if DoesEntityExist(PedVehicle) then DeleteEntity(PedVehicle) end local Vehicles = ESX.OneSync.GetVehiclesInArea(GetEntityCoords(GetPlayerPed(xPlayer.source)), tonumber(args.radius) or 5.0) - for i = 1, #Vehicles do + for i = 1, #Vehicles do local Vehicle = NetworkGetEntityFromNetworkId(Vehicles[i]) if DoesEntityExist(Vehicle) then DeleteEntity(Vehicle) @@ -116,19 +116,18 @@ end, false, {help = TranslateCap('command_cardel'), validate = false, arguments }}) ESX.RegisterCommand('setaccountmoney', 'admin', function(xPlayer, args, showError) - if args.playerId.getAccount(args.account) then - args.playerId.setAccountMoney(args.account, args.amount, "Government Grant") - if Config.AdminLogging then - ESX.DiscordLogFields("UserActions", "Set Account Money /setaccountmoney Triggered!", "pink", { - {name = "Player", value = xPlayer.name, inline = true}, - {name = "ID", value = xPlayer.source, inline = true}, - {name = "Target", value = args.playerId.name, inline = true}, - {name = "Account", value = args.account, inline = true}, - {name = "Amount", value = args.amount, inline = true}, - }) - end - else - showError(TranslateCap('command_giveaccountmoney_invalid')) + if not args.playerId.getAccount(args.account) then + return showError(TranslateCap('command_giveaccountmoney_invalid')) + end + args.playerId.setAccountMoney(args.account, args.amount, "Government Grant") + if Config.AdminLogging then + ESX.DiscordLogFields("UserActions", "Set Account Money /setaccountmoney Triggered!", "pink", { + {name = "Player", value = xPlayer.name, inline = true}, + {name = "ID", value = xPlayer.source, inline = true}, + {name = "Target", value = args.playerId.name, inline = true}, + {name = "Account", value = args.account, inline = true}, + {name = "Amount", value = args.amount, inline = true}, + }) end end, true, {help = TranslateCap('command_setaccountmoney'), validate = true, arguments = { {name = 'playerId', help = TranslateCap('commandgeneric_playerid'), type = 'player'}, @@ -137,19 +136,18 @@ end, true, {help = TranslateCap('command_setaccountmoney'), validate = true, arg }}) ESX.RegisterCommand('giveaccountmoney', 'admin', function(xPlayer, args, showError) - if args.playerId.getAccount(args.account) then - args.playerId.addAccountMoney(args.account, args.amount, "Government Grant") - if Config.AdminLogging then - ESX.DiscordLogFields("UserActions", "Give Account Money /giveaccountmoney Triggered!", "pink", { - {name = "Player", value = xPlayer.name, inline = true}, - {name = "ID", value = xPlayer.source, inline = true}, - {name = "Target", value = args.playerId.name, inline = true}, - {name = "Account", value = args.account, inline = true}, - {name = "Amount", value = args.amount, inline = true}, - }) - end - else - showError(TranslateCap('command_giveaccountmoney_invalid')) + if not args.playerId.getAccount(args.account) then + return showError(TranslateCap('command_giveaccountmoney_invalid')) + end + args.playerId.addAccountMoney(args.account, args.amount, "Government Grant") + if Config.AdminLogging then + ESX.DiscordLogFields("UserActions", "Give Account Money /giveaccountmoney Triggered!", "pink", { + {name = "Player", value = xPlayer.name, inline = true}, + {name = "ID", value = xPlayer.source, inline = true}, + {name = "Target", value = args.playerId.name, inline = true}, + {name = "Account", value = args.account, inline = true}, + {name = "Amount", value = args.amount, inline = true}, + }) end end, true, {help = TranslateCap('command_giveaccountmoney'), validate = true, arguments = { {name = 'playerId', help = TranslateCap('commandgeneric_playerid'), type = 'player'}, @@ -158,7 +156,7 @@ end, true, {help = TranslateCap('command_giveaccountmoney'), validate = true, ar }}) if not Config.OxInventory then - ESX.RegisterCommand('giveitem', 'admin', function(xPlayer, args, showError) + ESX.RegisterCommand('giveitem', 'admin', function(xPlayer, args, _) args.playerId.addInventoryItem(args.item, args.count) if Config.AdminLogging then ESX.DiscordLogFields("UserActions", "Give Item /giveitem Triggered!", "pink", { @@ -177,18 +175,17 @@ if not Config.OxInventory then ESX.RegisterCommand('giveweapon', 'admin', function(xPlayer, args, showError) if args.playerId.hasWeapon(args.weapon) then - showError(TranslateCap('command_giveweapon_hasalready')) - else - args.playerId.addWeapon(args.weapon, args.ammo) - if Config.AdminLogging then - ESX.DiscordLogFields("UserActions", "Give Weapon /giveweapon Triggered!", "pink", { - {name = "Player", value = xPlayer.name, inline = true}, - {name = "ID", value = xPlayer.source, inline = true}, - {name = "Target", value = args.playerId.name, inline = true}, - {name = "Weapon", value = args.weapon, inline = true}, - {name = "Ammo", value = args.ammo, inline = true}, - }) - end + return showError(TranslateCap('command_giveweapon_hasalready')) + end + args.playerId.addWeapon(args.weapon, args.ammo) + if Config.AdminLogging then + ESX.DiscordLogFields("UserActions", "Give Weapon /giveweapon Triggered!", "pink", { + {name = "Player", value = xPlayer.name, inline = true}, + {name = "ID", value = xPlayer.source, inline = true}, + {name = "Target", value = args.playerId.name, inline = true}, + {name = "Weapon", value = args.weapon, inline = true}, + {name = "Ammo", value = args.ammo, inline = true}, + }) end end, true, {help = TranslateCap('command_giveweapon'), validate = true, arguments = { {name = 'playerId', help = TranslateCap('commandgeneric_playerid'), type = 'player'}, @@ -197,19 +194,18 @@ if not Config.OxInventory then }}) ESX.RegisterCommand('giveammo', 'admin', function(xPlayer, args, showError) - if args.playerId.hasWeapon(args.weapon) then - args.playerId.addWeaponAmmo(args.weapon, args.ammo) - if Config.AdminLogging then - ESX.DiscordLogFields("UserActions", "Give Ammunition /giveammo Triggered!", "pink", { - {name = "Player", value = xPlayer.name, inline = true}, - {name = "ID", value = xPlayer.source, inline = true}, - {name = "Target", value = args.playerId.name, inline = true}, - {name = "Weapon", value = args.weapon, inline = true}, - {name = "Ammo", value = args.ammo, inline = true}, - }) - end - else - showError(TranslateCap("command_giveammo_noweapon_found")) + if not args.playerId.hasWeapon(args.weapon) then + return showError(TranslateCap("command_giveammo_noweapon_found")) + end + args.playerId.addWeaponAmmo(args.weapon, args.ammo) + if Config.AdminLogging then + ESX.DiscordLogFields("UserActions", "Give Ammunition /giveammo Triggered!", "pink", { + {name = "Player", value = xPlayer.name, inline = true}, + {name = "ID", value = xPlayer.source, inline = true}, + {name = "Target", value = args.playerId.name, inline = true}, + {name = "Weapon", value = args.weapon, inline = true}, + {name = "Ammo", value = args.ammo, inline = true}, + }) end end, true, {help = TranslateCap('command_giveweapon'), validate = false, arguments = { {name = 'playerId', help = TranslateCap('commandgeneric_playerid'), type = 'player'}, @@ -249,11 +245,11 @@ if not Config.OxInventory then }}) end -ESX.RegisterCommand({'clear', 'cls'}, 'user', function(xPlayer, args, showError) +ESX.RegisterCommand({'clear', 'cls'}, 'user', function(xPlayer, _, _) xPlayer.triggerEvent('chat:clear') end, false, {help = TranslateCap('command_clear')}) -ESX.RegisterCommand({'clearall', 'clsall'}, 'admin', function(xPlayer, args, showError) +ESX.RegisterCommand({'clearall', 'clsall'}, 'admin', function(xPlayer, _, _) TriggerClientEvent('chat:clear', -1) if Config.AdminLogging then ESX.DiscordLogFields("UserActions", "Clear Chat /clearall Triggered!", "pink", { @@ -263,12 +259,12 @@ ESX.RegisterCommand({'clearall', 'clsall'}, 'admin', function(xPlayer, args, sho end end, true, {help = TranslateCap('command_clearall')}) -ESX.RegisterCommand("refreshjobs", 'admin', function(xPlayer, args, showError) +ESX.RegisterCommand("refreshjobs", 'admin', function(xPlayer, _, _) ESX.RefreshJobs() end, true, {help = TranslateCap('command_clearall')}) if not Config.OxInventory then - ESX.RegisterCommand('clearinventory', 'admin', function(xPlayer, args, showError) + ESX.RegisterCommand('clearinventory', 'admin', function(xPlayer, args, _) for k, v in ipairs(args.playerId.inventory) do if v.count > 0 then args.playerId.setInventoryItem(v.name, 0) @@ -286,7 +282,7 @@ if not Config.OxInventory then {name = 'playerId', help = TranslateCap('commandgeneric_playerid'), type = 'player'} }}) - ESX.RegisterCommand('clearloadout', 'admin', function(xPlayer, args, showError) + ESX.RegisterCommand('clearloadout', 'admin', function(xPlayer, args, _) for i=#args.playerId.loadout, 1, -1 do args.playerId.removeWeapon(args.playerId.loadout[i].name) end @@ -303,7 +299,7 @@ if not Config.OxInventory then }}) end -ESX.RegisterCommand('setgroup', 'admin', function(xPlayer, args, showError) +ESX.RegisterCommand('setgroup', 'admin', function(xPlayer, args, _) if not args.playerId then args.playerId = xPlayer.source end if args.group == "superadmin" then args.group = "admin" print("[^3WARNING^7] ^5Superadmin^7 detected, setting group to ^5admin^7") end args.playerId.setGroup(args.group) @@ -320,32 +316,32 @@ end, true, {help = TranslateCap('command_setgroup'), validate = true, arguments {name = 'group', help = TranslateCap('command_setgroup_group'), type = 'string'}, }}) -ESX.RegisterCommand('save', 'admin', function(xPlayer, args, showError) +ESX.RegisterCommand('save', 'admin', function(xPlayer, args, _) Core.SavePlayer(args.playerId) print("[^2Info^0] Saved Player - ^5".. args.playerId.source .. "^0") end, true, {help = TranslateCap('command_save'), validate = true, arguments = { {name = 'playerId', help = TranslateCap('commandgeneric_playerid'), type = 'player'} }}) -ESX.RegisterCommand('saveall', 'admin', function(xPlayer, args, showError) +ESX.RegisterCommand('saveall', 'admin', function(xPlayer, args, _) Core.SavePlayers() end, true, {help = TranslateCap('command_saveall')}) -ESX.RegisterCommand('group', {"user", "admin"}, function(xPlayer, args, showError) +ESX.RegisterCommand('group', {"user", "admin"}, function(xPlayer, _, _) print(xPlayer.getName()..", You are currently: ^5".. xPlayer.getGroup() .. "^0") end, true) -ESX.RegisterCommand('job', {"user", "admin"}, function(xPlayer, args, showError) +ESX.RegisterCommand('job', {"user", "admin"}, function(xPlayer, _, _) print(xPlayer.getName()..", You are currently: ^5".. xPlayer.getJob().name.. "^0 - ^5".. xPlayer.getJob().grade_label .. "^0") end, true) -ESX.RegisterCommand('info', {"user", "admin"}, function(xPlayer, args, showError) +ESX.RegisterCommand('info', {"user", "admin"}, function(xPlayer, _, _) local job = xPlayer.getJob().name local jobgrade = xPlayer.getJob().grade_name print("^2ID : ^5"..xPlayer.source.." ^0| ^2Name:^5"..xPlayer.getName().." ^0 | ^2Group:^5"..xPlayer.getGroup().."^0 | ^2Job:^5".. job.."^0") end, true) -ESX.RegisterCommand('coords', "admin", function(xPlayer, args, showError) +ESX.RegisterCommand('coords', "admin", function(xPlayer, _, _) local ped = GetPlayerPed(xPlayer.source) local coords = GetEntityCoords(ped, false) local heading = GetEntityHeading(ped) @@ -353,7 +349,7 @@ ESX.RegisterCommand('coords', "admin", function(xPlayer, args, showError) print("Coords - Vector4: ^5".. vector4(coords.x, coords.y, coords.z, heading) .. "^0") end, true) -ESX.RegisterCommand('tpm', "admin", function(xPlayer, args, showError) +ESX.RegisterCommand('tpm', "admin", function(xPlayer, _ _) xPlayer.triggerEvent("esx:tpm") if Config.AdminLogging then ESX.DiscordLogFields("UserActions", "Admin Teleport /tpm Triggered!", "pink", { @@ -363,7 +359,7 @@ ESX.RegisterCommand('tpm', "admin", function(xPlayer, args, showError) end end, true) -ESX.RegisterCommand('goto', "admin", function(xPlayer, args, showError) +ESX.RegisterCommand('goto', "admin", function(xPlayer, args, _) local targetCoords = args.playerId.getCoords() xPlayer.setCoords(targetCoords) if Config.AdminLogging then @@ -378,7 +374,7 @@ end, true, {help = TranslateCap('command_goto'), validate = true, arguments = { {name = 'playerId', help = TranslateCap('commandgeneric_playerid'), type = 'player'} }}) -ESX.RegisterCommand('bring', "admin", function(xPlayer, args, showError) +ESX.RegisterCommand('bring', "admin", function(xPlayer, args, _) local playerCoords = xPlayer.getCoords() args.playerId.setCoords(playerCoords) if Config.AdminLogging then @@ -393,7 +389,7 @@ end, true, {help = TranslateCap('command_bring'), validate = true, arguments = { {name = 'playerId', help = TranslateCap('commandgeneric_playerid'), type = 'player'} }}) -ESX.RegisterCommand('kill', "admin", function(xPlayer, args, showError) +ESX.RegisterCommand('kill', "admin", function(xPlayer, args, _) args.playerId.triggerEvent("esx:killPlayer") if Config.AdminLogging then ESX.DiscordLogFields("UserActions", "Kill Command /kill Triggered!", "pink", { @@ -406,7 +402,7 @@ end, true, {help = TranslateCap('command_kill'), validate = true, arguments = { {name = 'playerId', help = TranslateCap('commandgeneric_playerid'), type = 'player'} }}) -ESX.RegisterCommand('freeze', "admin", function(xPlayer, args, showError) +ESX.RegisterCommand('freeze', "admin", function(xPlayer, args, _) args.playerId.triggerEvent('esx:freezePlayer', "freeze") if Config.AdminLogging then ESX.DiscordLogFields("UserActions", "Admin Freeze /freeze Triggered!", "pink", { @@ -419,7 +415,7 @@ end, true, {help = TranslateCap('command_freeze'), validate = true, arguments = {name = 'playerId', help = TranslateCap('commandgeneric_playerid'), type = 'player'} }}) -ESX.RegisterCommand('unfreeze', "admin", function(xPlayer, args, showError) +ESX.RegisterCommand('unfreeze', "admin", function(xPlayer, args, _) args.playerId.triggerEvent('esx:freezePlayer', "unfreeze") if Config.AdminLogging then ESX.DiscordLogFields("UserActions", "Admin UnFreeze /unfreeze Triggered!", "pink", { @@ -432,7 +428,7 @@ end, true, {help = TranslateCap('command_unfreeze'), validate = true, arguments {name = 'playerId', help = TranslateCap('commandgeneric_playerid'), type = 'player'} }}) -ESX.RegisterCommand("noclip", 'admin', function(xPlayer, args, showError) +ESX.RegisterCommand("noclip", 'admin', function(xPlayer, _, _) xPlayer.triggerEvent('esx:noclip') if Config.AdminLogging then ESX.DiscordLogFields("UserActions", "Admin NoClip /noclip Triggered!", "pink", { @@ -442,7 +438,7 @@ ESX.RegisterCommand("noclip", 'admin', function(xPlayer, args, showError) end end, false) -ESX.RegisterCommand('players', "admin", function(xPlayer, args, showError) +ESX.RegisterCommand('players', "admin", function(xPlayer, _, _) local xPlayers = ESX.GetExtendedPlayers() -- Returns all xPlayers print("^5"..#xPlayers.." ^2online player(s)^0") for i = 1, #(xPlayers) do From 6b54644ce41503d9da1316f85e3b00bb3c6224e6 Mon Sep 17 00:00:00 2001 From: Thekuca <63980591+Thekuca@users.noreply.github.com> Date: Fri, 19 May 2023 15:55:35 +0200 Subject: [PATCH 16/34] fix(server/commands): typo --- [core]/es_extended/server/commands.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/[core]/es_extended/server/commands.lua b/[core]/es_extended/server/commands.lua index 4cedd62f..156f688f 100644 --- a/[core]/es_extended/server/commands.lua +++ b/[core]/es_extended/server/commands.lua @@ -349,7 +349,7 @@ ESX.RegisterCommand('coords', "admin", function(xPlayer, _, _) print("Coords - Vector4: ^5".. vector4(coords.x, coords.y, coords.z, heading) .. "^0") end, true) -ESX.RegisterCommand('tpm', "admin", function(xPlayer, _ _) +ESX.RegisterCommand('tpm', "admin", function(xPlayer, _, _) xPlayer.triggerEvent("esx:tpm") if Config.AdminLogging then ESX.DiscordLogFields("UserActions", "Admin Teleport /tpm Triggered!", "pink", { From b1f879fd2a0b98fc89c30405b37b8c70bc1b900a Mon Sep 17 00:00:00 2001 From: TheFantomas <117121911+TheFantomas@users.noreply.github.com> Date: Sun, 21 May 2023 10:53:56 +0200 Subject: [PATCH 17/34] Remove .editorconfig --- [core]/es_extended/.editorconfig | 9 --------- [core]/esx_menu_dialog/.editorconfig | 9 --------- [core]/esx_menu_list/.editorconfig | 9 --------- [core]/esx_skin/.editorconfig | 9 --------- 4 files changed, 36 deletions(-) delete mode 100644 [core]/es_extended/.editorconfig delete mode 100644 [core]/esx_menu_dialog/.editorconfig delete mode 100644 [core]/esx_menu_list/.editorconfig delete mode 100644 [core]/esx_skin/.editorconfig diff --git a/[core]/es_extended/.editorconfig b/[core]/es_extended/.editorconfig deleted file mode 100644 index 9b425256..00000000 --- a/[core]/es_extended/.editorconfig +++ /dev/null @@ -1,9 +0,0 @@ -root = true - -[*] -indent_size = 4 -indent_style = tab -end_of_line = crlf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true \ No newline at end of file diff --git a/[core]/esx_menu_dialog/.editorconfig b/[core]/esx_menu_dialog/.editorconfig deleted file mode 100644 index 9b425256..00000000 --- a/[core]/esx_menu_dialog/.editorconfig +++ /dev/null @@ -1,9 +0,0 @@ -root = true - -[*] -indent_size = 4 -indent_style = tab -end_of_line = crlf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true \ No newline at end of file diff --git a/[core]/esx_menu_list/.editorconfig b/[core]/esx_menu_list/.editorconfig deleted file mode 100644 index 9b425256..00000000 --- a/[core]/esx_menu_list/.editorconfig +++ /dev/null @@ -1,9 +0,0 @@ -root = true - -[*] -indent_size = 4 -indent_style = tab -end_of_line = crlf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true \ No newline at end of file diff --git a/[core]/esx_skin/.editorconfig b/[core]/esx_skin/.editorconfig deleted file mode 100644 index 9b425256..00000000 --- a/[core]/esx_skin/.editorconfig +++ /dev/null @@ -1,9 +0,0 @@ -root = true - -[*] -indent_size = 4 -indent_style = tab -end_of_line = crlf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true \ No newline at end of file From 6be5fd547830f50e8704809b76a83bd7c8f58b9c Mon Sep 17 00:00:00 2001 From: Cyzxin Date: Mon, 22 May 2023 09:47:07 +0100 Subject: [PATCH 18/34] Fixed Translation For RefreshJob Command Added /refreshitems To Update The ESX.Items Table --- [core]/es_extended/locales/en.lua | 2 ++ [core]/es_extended/server/commands.lua | 6 +++++- [core]/es_extended/server/functions.lua | 8 ++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/[core]/es_extended/locales/en.lua b/[core]/es_extended/locales/en.lua index e480153f..8355c378 100644 --- a/[core]/es_extended/locales/en.lua +++ b/[core]/es_extended/locales/en.lua @@ -108,6 +108,8 @@ Locales['en'] = { ['command_giveammo_noweapon_found'] = '%s does not have that weapon', ['command_giveammo_weapon'] = 'Weapon name', ['command_giveammo_ammo'] = 'Ammo Quantity', + ['command_refreshjobs'] = 'Refresh The ESX Jobs Table', + ['command_refreshitems'] = 'Refresh The ESX Items Table', ['tpm_nowaypoint'] = 'No Waypoint Set.', ['tpm_success'] = 'Successfully Teleported', diff --git a/[core]/es_extended/server/commands.lua b/[core]/es_extended/server/commands.lua index b89ae36a..ad1cf9e8 100644 --- a/[core]/es_extended/server/commands.lua +++ b/[core]/es_extended/server/commands.lua @@ -184,7 +184,11 @@ end, true, {help = TranslateCap('command_clearall')}) ESX.RegisterCommand("refreshjobs", 'admin', function(xPlayer, args, showError) ESX.RefreshJobs() -end, true, {help = TranslateCap('command_clearall')}) +end, true, {help = TranslateCap('command_refreshjobs')}) + +ESX.RegisterCommand("refreshitems", 'admin', function(xPlayer, args, showError) + ESX.RefreshItems() +end, true, {help = TranslateCap('command_refreshitems')}) if not Config.OxInventory then ESX.RegisterCommand('clearinventory', 'admin', function(xPlayer, args, showError) diff --git a/[core]/es_extended/server/functions.lua b/[core]/es_extended/server/functions.lua index 202e1b5e..2ed4b802 100644 --- a/[core]/es_extended/server/functions.lua +++ b/[core]/es_extended/server/functions.lua @@ -348,6 +348,14 @@ function ESX.RefreshJobs() end end +function ESX.RefreshItems() + if Config.OxInventory then return end + local items = MySQL.query.await('SELECT * FROM items') + for k, v in ipairs(items) do + ESX.Items[v.name] = {label = v.label, weight = v.weight, rare = v.rare, canRemove = v.can_remove} + end +end + function ESX.RegisterUsableItem(item, cb) Core.UsableItemsCallbacks[item] = cb end From de416d59a983eaca58ad2b11b520e2077807546a Mon Sep 17 00:00:00 2001 From: Thekuca <63980591+Thekuca@users.noreply.github.com> Date: Mon, 22 May 2023 23:47:50 +0200 Subject: [PATCH 19/34] fix(Weapons): typo --- [core]/es_extended/config.weapons.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/[core]/es_extended/config.weapons.lua b/[core]/es_extended/config.weapons.lua index b7c63cd1..aef2af7d 100644 --- a/[core]/es_extended/config.weapons.lua +++ b/[core]/es_extended/config.weapons.lua @@ -977,7 +977,6 @@ Config.Weapons = { } }, {name = 'WEAPON_METALDETECTOR', label = TranslateCap('weapon_metaldetector'), components = {}}, - , {name = 'WEAPON_PISTOLXM3', label = TranslateCap('weapon_pistolxm3'), ammo = {label = TranslateCap('ammo_rounds'), hash = `AMMO_PISTOL`}, tints = Config.DefaultWeaponTints, components = { {name = 'clip_default', label = TranslateCap('component_clip_default'), hash = `COMPONENT_PISTOLXM3_CLIP_01`}, From f442b53276a2c5daa1bca8fe6baa46675183970b Mon Sep 17 00:00:00 2001 From: Thekuca Date: Mon, 22 May 2023 23:58:00 +0200 Subject: [PATCH 20/34] feat(Locales): add new locales for dlc weapons --- [core]/es_extended/locales/hu.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/[core]/es_extended/locales/hu.lua b/[core]/es_extended/locales/hu.lua index d4b1bd6f..da859972 100644 --- a/[core]/es_extended/locales/hu.lua +++ b/[core]/es_extended/locales/hu.lua @@ -223,10 +223,10 @@ Locales["hu"] = { ["weapon_tactilerifle"] = "Service Carbine", -- Drug Wars DLC - ['weapon_candycane'] = 'Candy Cane', - ['weapon_acidpackage'] = 'Acid Package', - ['weapon_pistolxm3'] = 'WM 29 Pistol', - ['weapon_railgunxm3'] = 'Railgun', + ['weapon_candycane'] = 'Candy Cane', -- not translated + ['weapon_acidpackage'] = 'Acid Package', -- not translated + ['weapon_pistolxm3'] = 'WM 29 Pistol', -- not translated + ['weapon_railgunxm3'] = 'Railgun', -- not translated -- Thrown ["weapon_ball"] = "Baseball", From 5245de9e089ba06af3e74d08fff0b73c4ea06c96 Mon Sep 17 00:00:00 2001 From: Thekuca Date: Mon, 22 May 2023 23:59:34 +0200 Subject: [PATCH 21/34] feat(Locales): add new translations for dlc weapons --- [core]/es_extended/locales/cs.lua | 6 ++++++ [core]/es_extended/locales/da.lua | 6 ++++++ [core]/es_extended/locales/de.lua | 6 ++++++ [core]/es_extended/locales/en.lua | 6 ++++++ [core]/es_extended/locales/es.lua | 6 ++++++ [core]/es_extended/locales/fi.lua | 6 ++++++ [core]/es_extended/locales/fr.lua | 6 ++++++ [core]/es_extended/locales/it.lua | 6 ++++++ [core]/es_extended/locales/nl.lua | 6 ++++++ [core]/es_extended/locales/pl.lua | 6 ++++++ [core]/es_extended/locales/sl.lua | 6 ++++++ [core]/es_extended/locales/sr.lua | 6 ++++++ [core]/es_extended/locales/zh-cn.lua | 6 ++++++ 13 files changed, 78 insertions(+) diff --git a/[core]/es_extended/locales/cs.lua b/[core]/es_extended/locales/cs.lua index 417ee851..67744f15 100644 --- a/[core]/es_extended/locales/cs.lua +++ b/[core]/es_extended/locales/cs.lua @@ -216,6 +216,12 @@ Locales['cs'] = { ['weapon_precisionrifle'] = 'Precision Rifle', ['weapon_tactilerifle'] = 'Service Carbine', + -- Drug Wars DLC + ['weapon_candycane'] = 'Candy Cane', -- not translated + ['weapon_acidpackage'] = 'Acid Package', -- not translated + ['weapon_pistolxm3'] = 'WM 29 Pistol', -- not translated + ['weapon_railgunxm3'] = 'Railgun', -- not translated + -- Thrown ['weapon_ball'] = 'Míček', ['weapon_bzgas'] = 'Smrtící slzný plyn', diff --git a/[core]/es_extended/locales/da.lua b/[core]/es_extended/locales/da.lua index a5e5548f..c5a7a771 100644 --- a/[core]/es_extended/locales/da.lua +++ b/[core]/es_extended/locales/da.lua @@ -222,6 +222,12 @@ Locales['da'] = { ['weapon_precisionrifle'] = 'Precision Rifle', ['weapon_tactilerifle'] = 'Service Carbine', + -- Drug Wars DLC + ['weapon_candycane'] = 'Candy Cane', -- not translated + ['weapon_acidpackage'] = 'Acid Package', -- not translated + ['weapon_pistolxm3'] = 'WM 29 Pistol', -- not translated + ['weapon_railgunxm3'] = 'Railgun', -- not translated + -- Thrown ['weapon_ball'] = 'Baseball', ['weapon_bzgas'] = 'BZ Gas', diff --git a/[core]/es_extended/locales/de.lua b/[core]/es_extended/locales/de.lua index 6ea003dd..635d9a75 100644 --- a/[core]/es_extended/locales/de.lua +++ b/[core]/es_extended/locales/de.lua @@ -222,6 +222,12 @@ Locales['de'] = { ['weapon_precisionrifle'] = 'Präzisionsgewehr', ['weapon_tactilerifle'] = 'Service Karabiner', + -- Drug Wars DLC + ['weapon_candycane'] = 'Candy Cane', -- not translated + ['weapon_acidpackage'] = 'Acid Package', -- not translated + ['weapon_pistolxm3'] = 'WM 29 Pistol', -- not translated + ['weapon_railgunxm3'] = 'Railgun', -- not translated + -- Thrown ['weapon_ball'] = 'Baseball', ['weapon_bzgas'] = 'BZ Gas', diff --git a/[core]/es_extended/locales/en.lua b/[core]/es_extended/locales/en.lua index ec590def..9e5ee8aa 100644 --- a/[core]/es_extended/locales/en.lua +++ b/[core]/es_extended/locales/en.lua @@ -222,6 +222,12 @@ Locales['en'] = { ['weapon_precisionrifle'] = 'Precision Rifle', ['weapon_tactilerifle'] = 'Service Carbine', + -- Drug Wars DLC + ['weapon_candycane'] = 'Candy Cane', -- not translated + ['weapon_acidpackage'] = 'Acid Package', -- not translated + ['weapon_pistolxm3'] = 'WM 29 Pistol', -- not translated + ['weapon_railgunxm3'] = 'Railgun', -- not translated + -- Thrown ['weapon_ball'] = 'Baseball', ['weapon_bzgas'] = 'BZ Gas', diff --git a/[core]/es_extended/locales/es.lua b/[core]/es_extended/locales/es.lua index dc9c57bb..efd3d1c6 100644 --- a/[core]/es_extended/locales/es.lua +++ b/[core]/es_extended/locales/es.lua @@ -115,6 +115,12 @@ Locales['es'] = { -- Weapons + -- Drug Wars DLC + ['weapon_candycane'] = 'Candy Cane', -- not translated + ['weapon_acidpackage'] = 'Acid Package', -- not translated + ['weapon_pistolxm3'] = 'WM 29 Pistol', -- not translated + ['weapon_railgunxm3'] = 'Railgun', -- not translated + -- Melee ['weapon_dagger'] = 'Daga', ['weapon_bat'] = 'Bate', diff --git a/[core]/es_extended/locales/fi.lua b/[core]/es_extended/locales/fi.lua index 9e169caf..1a8e8e09 100644 --- a/[core]/es_extended/locales/fi.lua +++ b/[core]/es_extended/locales/fi.lua @@ -108,6 +108,12 @@ Locales['fi'] = { ['locale_digit_grouping_symbol'] = '', ['locale_currency'] = '$%s', + -- Drug Wars DLC + ['weapon_candycane'] = 'Candy Cane', -- not translated + ['weapon_acidpackage'] = 'Acid Package', -- not translated + ['weapon_pistolxm3'] = 'WM 29 Pistol', -- not translated + ['weapon_railgunxm3'] = 'Railgun', -- not translated + -- Weapons ['weapon_knife'] = 'Veitsi', ['weapon_nightstick'] = 'Pamppu', diff --git a/[core]/es_extended/locales/fr.lua b/[core]/es_extended/locales/fr.lua index f21a4ed5..74e105a8 100644 --- a/[core]/es_extended/locales/fr.lua +++ b/[core]/es_extended/locales/fr.lua @@ -196,6 +196,12 @@ Locales['fr'] = { ['component_grip'] = 'poignée', ['component_luxary_finish'] = 'finition de luxe', + -- Drug Wars DLC + ['weapon_candycane'] = 'Candy Cane', -- not translated + ['weapon_acidpackage'] = 'Acid Package', -- not translated + ['weapon_pistolxm3'] = 'WM 29 Pistol', -- not translated + ['weapon_railgunxm3'] = 'Railgun', -- not translated + -- Weapon Ammo ['ammo_rounds'] = 'cartouche(s)', ['ammo_shells'] = 'obus', diff --git a/[core]/es_extended/locales/it.lua b/[core]/es_extended/locales/it.lua index 621b350f..daff7efd 100644 --- a/[core]/es_extended/locales/it.lua +++ b/[core]/es_extended/locales/it.lua @@ -222,6 +222,12 @@ Locales['it'] = { ['weapon_precisionrifle'] = 'Fucile di precisione', ['weapon_tactilerifle'] = 'Carabina di servizio', + -- Drug Wars DLC + ['weapon_candycane'] = 'Candy Cane', -- not translated + ['weapon_acidpackage'] = 'Acid Package', -- not translated + ['weapon_pistolxm3'] = 'WM 29 Pistol', -- not translated + ['weapon_railgunxm3'] = 'Railgun', -- not translated + -- Thrown ['weapon_ball'] = 'Palla', ['weapon_bzgas'] = 'BZ Gas', diff --git a/[core]/es_extended/locales/nl.lua b/[core]/es_extended/locales/nl.lua index 86e8ed34..85998877 100644 --- a/[core]/es_extended/locales/nl.lua +++ b/[core]/es_extended/locales/nl.lua @@ -221,6 +221,12 @@ Locales['nl'] = { ['weapon_metaldetector'] = 'Metaal Detector', ['weapon_precisionrifle'] = 'Precisiegeweer', ['weapon_tactilerifle'] = 'Service Carbine', + + -- Drug Wars DLC + ['weapon_candycane'] = 'Candy Cane', -- not translated + ['weapon_acidpackage'] = 'Acid Package', -- not translated + ['weapon_pistolxm3'] = 'WM 29 Pistol', -- not translated + ['weapon_railgunxm3'] = 'Railgun', -- not translated -- Thrown ['weapon_ball'] = 'Honkbal', diff --git a/[core]/es_extended/locales/pl.lua b/[core]/es_extended/locales/pl.lua index c3acb5bd..96e543c5 100644 --- a/[core]/es_extended/locales/pl.lua +++ b/[core]/es_extended/locales/pl.lua @@ -195,6 +195,12 @@ Locales['pl'] = { ['component_grip'] = 'uchwyt', ['component_luxary_finish'] = 'luksusowe wykończenie broni', + -- Drug Wars DLC + ['weapon_candycane'] = 'Candy Cane', -- not translated + ['weapon_acidpackage'] = 'Acid Package', -- not translated + ['weapon_pistolxm3'] = 'WM 29 Pistol', -- not translated + ['weapon_railgunxm3'] = 'Railgun', -- not translated + -- Weapon Ammo ['ammo_rounds'] = 'nabój/oi', ['ammo_shells'] = 'pocisk(ów)', diff --git a/[core]/es_extended/locales/sl.lua b/[core]/es_extended/locales/sl.lua index 0a0b234c..880ef536 100644 --- a/[core]/es_extended/locales/sl.lua +++ b/[core]/es_extended/locales/sl.lua @@ -221,6 +221,12 @@ Locales['sl'] = { ['weapon_metaldetector'] = 'Metal Detector', ['weapon_precisionrifle'] = 'Precision Rifle', ['weapon_tactilerifle'] = 'Service Carbine', + + -- Drug Wars DLC + ['weapon_candycane'] = 'Candy Cane', -- not translated + ['weapon_acidpackage'] = 'Acid Package', -- not translated + ['weapon_pistolxm3'] = 'WM 29 Pistol', -- not translated + ['weapon_railgunxm3'] = 'Railgun', -- not translated -- Thrown ['weapon_ball'] = 'Baseball', diff --git a/[core]/es_extended/locales/sr.lua b/[core]/es_extended/locales/sr.lua index 69a589b1..e3fe777c 100644 --- a/[core]/es_extended/locales/sr.lua +++ b/[core]/es_extended/locales/sr.lua @@ -222,6 +222,12 @@ Locales['sr'] = { ['weapon_precisionrifle'] = 'Precision Rifle', ['weapon_tactilerifle'] = 'Service Carbine', + -- Drug Wars DLC + ['weapon_candycane'] = 'Candy Cane', -- not translated + ['weapon_acidpackage'] = 'Acid Package', -- not translated + ['weapon_pistolxm3'] = 'WM 29 Pistol', -- not translated + ['weapon_railgunxm3'] = 'Railgun', -- not translated + -- Thrown ['weapon_ball'] = 'Baseball', ['weapon_bzgas'] = 'BZ Gas', diff --git a/[core]/es_extended/locales/zh-cn.lua b/[core]/es_extended/locales/zh-cn.lua index 7671a230..c9951bc7 100644 --- a/[core]/es_extended/locales/zh-cn.lua +++ b/[core]/es_extended/locales/zh-cn.lua @@ -222,6 +222,12 @@ Locales['zh-cn'] = { ['weapon_precisionrifle'] = '精确步枪', ['weapon_tactilerifle'] = '制式卡宾步枪', + -- Drug Wars DLC + ['weapon_candycane'] = 'Candy Cane', -- not translated + ['weapon_acidpackage'] = 'Acid Package', -- not translated + ['weapon_pistolxm3'] = 'WM 29 Pistol', -- not translated + ['weapon_railgunxm3'] = 'Railgun', -- not translated + -- Thrown ['weapon_ball'] = '棒球', ['weapon_bzgas'] = '毒气弹', From fab8f3aa741ceb740eb0371808502e49032069be Mon Sep 17 00:00:00 2001 From: Thekuca <63980591+Thekuca@users.noreply.github.com> Date: Tue, 23 May 2023 11:28:09 +0200 Subject: [PATCH 22/34] Update functions.lua --- [core]/es_extended/server/functions.lua | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/[core]/es_extended/server/functions.lua b/[core]/es_extended/server/functions.lua index 094f3162..0591e8db 100644 --- a/[core]/es_extended/server/functions.lua +++ b/[core]/es_extended/server/functions.lua @@ -357,11 +357,23 @@ function ESX.RefreshJobs() end function ESX.RefreshItems() - if Config.OxInventory then return end - local items = MySQL.query.await('SELECT * FROM items') - for k, v in ipairs(items) do - ESX.Items[v.name] = {label = v.label, weight = v.weight, rare = v.rare, canRemove = v.can_remove} - end + if not Config.OxInventory then + ESX.Items = {} + local items = MySQL.query.await('SELECT * FROM items') + for k, v in ipairs(items) do + ESX.Items[v.name] = {label = v.label, weight = v.weight, rare = v.rare, canRemove = v.can_remove} + end + else + TriggerEvent('__cfx_export_ox_inventory_Items', function(ref) + if ref then + ESX.Items = ref() + end + end) + + AddEventHandler('ox_inventory:itemList', function(items) + ESX.Items = items + end) + end end function ESX.RegisterUsableItem(item, cb) From 9ee4bcddf1b2fb5f644cfdcf65409b99665ec1e7 Mon Sep 17 00:00:00 2001 From: Thekuca <63980591+Thekuca@users.noreply.github.com> Date: Tue, 23 May 2023 11:29:50 +0200 Subject: [PATCH 23/34] Update common.lua --- [core]/es_extended/server/common.lua | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/[core]/es_extended/server/common.lua b/[core]/es_extended/server/common.lua index 7e3d3ebb..63b9fb9e 100644 --- a/[core]/es_extended/server/common.lua +++ b/[core]/es_extended/server/common.lua @@ -40,25 +40,11 @@ end MySQL.ready(function() Core.DatabaseConnected = true - if not Config.OxInventory then - local items = MySQL.query.await('SELECT * FROM items') - for k, v in ipairs(items) do - ESX.Items[v.name] = {label = v.label, weight = v.weight, rare = v.rare, canRemove = v.can_remove} - end - else - TriggerEvent('__cfx_export_ox_inventory_Items', function(ref) - if ref then - ESX.Items = ref() - end - end) - AddEventHandler('ox_inventory:itemList', function(items) - ESX.Items = items - end) + ESX.RefreshItems() - while not next(ESX.Items) do - Wait(0) - end + while not next(ESX.Items) do + Wait(0) end ESX.RefreshJobs() From de0d33b2f6f674245ac1e4af53b527a713e5dcf2 Mon Sep 17 00:00:00 2001 From: Cyzxin Date: Thu, 25 May 2023 08:57:50 +0100 Subject: [PATCH 24/34] feat(es_extended): /removeaccountmoney --- [core]/es_extended/locales/en.lua | 4 ++++ [core]/es_extended/server/commands.lua | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/[core]/es_extended/locales/en.lua b/[core]/es_extended/locales/en.lua index eeb2f135..749eb13a 100644 --- a/[core]/es_extended/locales/en.lua +++ b/[core]/es_extended/locales/en.lua @@ -69,6 +69,10 @@ Locales['en'] = { ['command_giveaccountmoney_account'] = 'Account to add to', ['command_giveaccountmoney_amount'] = 'Amount to add', ['command_giveaccountmoney_invalid'] = 'Account Name Invalid', + ['command_removeaccountmoney'] = 'Remove Money from a specified Account', + ['command_removeaccountmoney_account'] = 'Account to remove from', + ['command_removeaccountmoney_amount'] = 'Amount to remove', + ['command_removeaccountmoney_invalid'] = 'Account Name Invalid', ['command_giveitem'] = 'Give Player an item', ['command_giveitem_item'] = 'Item name', ['command_giveitem_count'] = 'Quantity', diff --git a/[core]/es_extended/server/commands.lua b/[core]/es_extended/server/commands.lua index a9f5054b..8418f151 100644 --- a/[core]/es_extended/server/commands.lua +++ b/[core]/es_extended/server/commands.lua @@ -155,6 +155,26 @@ end, true, {help = TranslateCap('command_giveaccountmoney'), validate = true, ar {name = 'amount', help = TranslateCap('command_giveaccountmoney_amount'), type = 'number'} }}) +ESX.RegisterCommand('removeaccountmoney', 'admin', function(xPlayer, args, showError) + if not args.playerId.getAccount(args.account) then + return showError(TranslateCap('command_removeaccountmoney_invalid')) + end + args.playerId.removeaccountmoney(args.account, args.amount, "Government Tax") + if Config.AdminLogging then + ESX.DiscordLogFields("UserActions", "Remove Account Money /removeaccountmoney Triggered!", "pink", { + {name = "Player", value = xPlayer.name, inline = true}, + {name = "ID", value = xPlayer.source, inline = true}, + {name = "Target", value = args.playerId.name, inline = true}, + {name = "Account", value = args.account, inline = true}, + {name = "Amount", value = args.amount, inline = true}, + }) + end +end, true, {help = TranslateCap('command_removeaccountmoney'), validate = true, arguments = { + {name = 'playerId', help = TranslateCap('commandgeneric_playerid'), type = 'player'}, + {name = 'account', help = TranslateCap('command_removeaccountmoney_account'), type = 'string'}, + {name = 'amount', help = TranslateCap('command_removeaccountmoney_amount'), type = 'number'} +}}) + if not Config.OxInventory then ESX.RegisterCommand('giveitem', 'admin', function(xPlayer, args, _) args.playerId.addInventoryItem(args.item, args.count) From c2772dbd560f7bb000cff68d85f0cd71a2ef1d69 Mon Sep 17 00:00:00 2001 From: thesysadmindev Date: Thu, 25 May 2023 20:17:39 +1000 Subject: [PATCH 25/34] feat(es_extended) Added in randomisation of default spawn coordinates Replaced Config.DefaultSpawn in [core]\es_extended\config.lua:L21 with a table of default spawn coordinates, and updated [core]\es_extended\server\main.lua:L254 to use new coordinates table. --- [core]/es_extended/config.lua | 8 +++++++- [core]/es_extended/server/main.lua | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/[core]/es_extended/config.lua b/[core]/es_extended/config.lua index 70e2280d..9262e27b 100644 --- a/[core]/es_extended/config.lua +++ b/[core]/es_extended/config.lua @@ -18,7 +18,13 @@ Config.Accounts = { Config.StartingAccountMoney = {bank = 50000} -Config.DefaultSpawn = {x = -269.4, y = -955.3, z = 31.2, heading = 205.8} +Config.Spawns = { -- Default spawn locations are currently set to locations on San Andreas Avenue near the intersection of Strawberry Avenue at Legion Square + {x = 222.2027, y = -864.0162, z = 30.2922, heading = 1.0}, + {x = 224.9865, y = -865.0871, z = 30.2922, heading = 1.0}, + {x = 227.8436, y = -866.0400, z = 30.2922, heading = 1.0}, + {x = 230.6051, y = -867.1450, z = 30.2922, heading = 1.0}, + {x = 233.5459, y = -868.2626, z = 30.2922, heading = 1.0} +} Config.EnablePaycheck = true -- enable paycheck Config.LogPaycheck = false -- Logs paychecks to a nominated Discord channel via webhook (default is false) diff --git a/[core]/es_extended/server/main.lua b/[core]/es_extended/server/main.lua index 889e9c94..2c85305b 100644 --- a/[core]/es_extended/server/main.lua +++ b/[core]/es_extended/server/main.lua @@ -251,7 +251,7 @@ function loadESXPlayer(identifier, playerId, isNew) end -- Position - userData.coords = json.decode(result.position) or Config.DefaultSpawn + userData.coords = json.decode(result.position) or Config.Spawns[math.random(#Config.Spawns)] -- Skin if result.skin and result.skin ~= '' then From e406a2b6c31ac643b6edc0ab837838760ebf9331 Mon Sep 17 00:00:00 2001 From: Thekuca <63980591+Thekuca@users.noreply.github.com> Date: Thu, 25 May 2023 13:02:06 +0200 Subject: [PATCH 26/34] Update commands.lua --- [core]/es_extended/server/commands.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/[core]/es_extended/server/commands.lua b/[core]/es_extended/server/commands.lua index 8418f151..142a7af1 100644 --- a/[core]/es_extended/server/commands.lua +++ b/[core]/es_extended/server/commands.lua @@ -159,7 +159,7 @@ ESX.RegisterCommand('removeaccountmoney', 'admin', function(xPlayer, args, showE if not args.playerId.getAccount(args.account) then return showError(TranslateCap('command_removeaccountmoney_invalid')) end - args.playerId.removeaccountmoney(args.account, args.amount, "Government Tax") + args.playerId.removeAccountMoney(args.account, args.amount, "Government Tax") if Config.AdminLogging then ESX.DiscordLogFields("UserActions", "Remove Account Money /removeaccountmoney Triggered!", "pink", { {name = "Player", value = xPlayer.name, inline = true}, From b740fa187a536c1e10f18185819b3db9d2870acc Mon Sep 17 00:00:00 2001 From: TheFantomas <117121911+TheFantomas@users.noreply.github.com> Date: Thu, 25 May 2023 15:12:22 +0200 Subject: [PATCH 27/34] Hmm --- [core]/es_extended/config.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/[core]/es_extended/config.lua b/[core]/es_extended/config.lua index 0608fbbf..9eac7f6d 100644 --- a/[core]/es_extended/config.lua +++ b/[core]/es_extended/config.lua @@ -19,12 +19,12 @@ Config.Accounts = { Config.StartingAccountMoney = {bank = 50000} -Config.Spawns = { -- Default spawn locations are currently set to locations on San Andreas Avenue near the intersection of Strawberry Avenue at Legion Square +Config.Spawns = { -- If you want to have more spawn positions and select them randomly uncomment commented code or add more locations {x = 222.2027, y = -864.0162, z = 30.2922, heading = 1.0}, - {x = 224.9865, y = -865.0871, z = 30.2922, heading = 1.0}, - {x = 227.8436, y = -866.0400, z = 30.2922, heading = 1.0}, - {x = 230.6051, y = -867.1450, z = 30.2922, heading = 1.0}, - {x = 233.5459, y = -868.2626, z = 30.2922, heading = 1.0} + --{x = 224.9865, y = -865.0871, z = 30.2922, heading = 1.0}, + --{x = 227.8436, y = -866.0400, z = 30.2922, heading = 1.0}, + --{x = 230.6051, y = -867.1450, z = 30.2922, heading = 1.0}, + --{x = 233.5459, y = -868.2626, z = 30.2922, heading = 1.0} } Config.AdminGroups = { From 3b06d8cf59d7a3dc17debb939888b178a1739da5 Mon Sep 17 00:00:00 2001 From: TheFantomas <117121911+TheFantomas@users.noreply.github.com> Date: Thu, 25 May 2023 15:12:59 +0200 Subject: [PATCH 28/34] DefaultSpawns --- [core]/es_extended/config.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/[core]/es_extended/config.lua b/[core]/es_extended/config.lua index 9eac7f6d..a4245685 100644 --- a/[core]/es_extended/config.lua +++ b/[core]/es_extended/config.lua @@ -19,7 +19,7 @@ Config.Accounts = { Config.StartingAccountMoney = {bank = 50000} -Config.Spawns = { -- If you want to have more spawn positions and select them randomly uncomment commented code or add more locations +Config.DefaultSpawns = { -- If you want to have more spawn positions and select them randomly uncomment commented code or add more locations {x = 222.2027, y = -864.0162, z = 30.2922, heading = 1.0}, --{x = 224.9865, y = -865.0871, z = 30.2922, heading = 1.0}, --{x = 227.8436, y = -866.0400, z = 30.2922, heading = 1.0}, From 86270a3b1c59b2bef61e67f411ccaa378a340a59 Mon Sep 17 00:00:00 2001 From: TheFantomas <117121911+TheFantomas@users.noreply.github.com> Date: Thu, 25 May 2023 15:13:21 +0200 Subject: [PATCH 29/34] Forgot --- [core]/es_extended/server/main.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/[core]/es_extended/server/main.lua b/[core]/es_extended/server/main.lua index 2c85305b..87958fed 100644 --- a/[core]/es_extended/server/main.lua +++ b/[core]/es_extended/server/main.lua @@ -251,7 +251,7 @@ function loadESXPlayer(identifier, playerId, isNew) end -- Position - userData.coords = json.decode(result.position) or Config.Spawns[math.random(#Config.Spawns)] + userData.coords = json.decode(result.position) or Config.DefaultSpawns[math.random(#Config.DefaultSpawns)] -- Skin if result.skin and result.skin ~= '' then From 5842f3086583de4eb7bdf835a20aa526eb01481a Mon Sep 17 00:00:00 2001 From: TheFantomas <117121911+TheFantomas@users.noreply.github.com> Date: Sun, 28 May 2023 13:29:18 +0200 Subject: [PATCH 30/34] revert "a969785d3697a384132202a07d4b357afb668048" --- [core]/es_extended/server/commands.lua | 6 +----- [core]/es_extended/server/common.lua | 20 +++++++++++++++++--- [core]/es_extended/server/functions.lua | 20 -------------------- 3 files changed, 18 insertions(+), 28 deletions(-) diff --git a/[core]/es_extended/server/commands.lua b/[core]/es_extended/server/commands.lua index 142a7af1..c20edf68 100644 --- a/[core]/es_extended/server/commands.lua +++ b/[core]/es_extended/server/commands.lua @@ -281,11 +281,7 @@ end, true, {help = TranslateCap('command_clearall')}) ESX.RegisterCommand("refreshjobs", 'admin', function(xPlayer, _, _) ESX.RefreshJobs() -end, true, {help = TranslateCap('command_refreshjobs')}) - -ESX.RegisterCommand("refreshitems", 'admin', function(xPlayer, args, showError) - ESX.RefreshItems() -end, true, {help = TranslateCap('command_refreshitems')}) +end, true, {help = TranslateCap('command_clearall')}) if not Config.OxInventory then ESX.RegisterCommand('clearinventory', 'admin', function(xPlayer, args, _) diff --git a/[core]/es_extended/server/common.lua b/[core]/es_extended/server/common.lua index 63b9fb9e..7e3d3ebb 100644 --- a/[core]/es_extended/server/common.lua +++ b/[core]/es_extended/server/common.lua @@ -40,11 +40,25 @@ end MySQL.ready(function() Core.DatabaseConnected = true + if not Config.OxInventory then + local items = MySQL.query.await('SELECT * FROM items') + for k, v in ipairs(items) do + ESX.Items[v.name] = {label = v.label, weight = v.weight, rare = v.rare, canRemove = v.can_remove} + end + else + TriggerEvent('__cfx_export_ox_inventory_Items', function(ref) + if ref then + ESX.Items = ref() + end + end) - ESX.RefreshItems() + AddEventHandler('ox_inventory:itemList', function(items) + ESX.Items = items + end) - while not next(ESX.Items) do - Wait(0) + while not next(ESX.Items) do + Wait(0) + end end ESX.RefreshJobs() diff --git a/[core]/es_extended/server/functions.lua b/[core]/es_extended/server/functions.lua index 0591e8db..31b0c1a9 100644 --- a/[core]/es_extended/server/functions.lua +++ b/[core]/es_extended/server/functions.lua @@ -356,26 +356,6 @@ function ESX.RefreshJobs() end end -function ESX.RefreshItems() - if not Config.OxInventory then - ESX.Items = {} - local items = MySQL.query.await('SELECT * FROM items') - for k, v in ipairs(items) do - ESX.Items[v.name] = {label = v.label, weight = v.weight, rare = v.rare, canRemove = v.can_remove} - end - else - TriggerEvent('__cfx_export_ox_inventory_Items', function(ref) - if ref then - ESX.Items = ref() - end - end) - - AddEventHandler('ox_inventory:itemList', function(items) - ESX.Items = items - end) - end -end - function ESX.RegisterUsableItem(item, cb) Core.UsableItemsCallbacks[item] = cb end From 8cd2f750124208f93c9c07d5d68a568d784058aa Mon Sep 17 00:00:00 2001 From: TheFantomas <117121911+TheFantomas@users.noreply.github.com> Date: Sun, 28 May 2023 13:30:27 +0200 Subject: [PATCH 31/34] revert "a969785d3697a384132202a07d4b357afb668048" --- [core]/es_extended/locales/en.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/[core]/es_extended/locales/en.lua b/[core]/es_extended/locales/en.lua index 749eb13a..50de5d0e 100644 --- a/[core]/es_extended/locales/en.lua +++ b/[core]/es_extended/locales/en.lua @@ -112,8 +112,6 @@ Locales['en'] = { ['command_giveammo_noweapon_found'] = '%s does not have that weapon', ['command_giveammo_weapon'] = 'Weapon name', ['command_giveammo_ammo'] = 'Ammo Quantity', - ['command_refreshjobs'] = 'Refresh The ESX Jobs Table', - ['command_refreshitems'] = 'Refresh The ESX Items Table', ['tpm_nowaypoint'] = 'No Waypoint Set.', ['tpm_success'] = 'Successfully Teleported', @@ -368,4 +366,4 @@ Locales['en'] = { ['tint_lspd'] = 'blue skin', ['tint_orange'] = 'orange skin', ['tint_platinum'] = 'platinum skin', -} \ No newline at end of file +} From d8b4de8f05d1d3e17916f134619bfe858f6d09ee Mon Sep 17 00:00:00 2001 From: Thekuca <63980591+Thekuca@users.noreply.github.com> Date: Sun, 4 Jun 2023 00:17:26 +0200 Subject: [PATCH 32/34] revert(server/callback): revert old code --- .../es_extended/server/modules/callback.lua | 53 ++++--------------- 1 file changed, 10 insertions(+), 43 deletions(-) diff --git a/[core]/es_extended/server/modules/callback.lua b/[core]/es_extended/server/modules/callback.lua index b615be21..f517531e 100644 --- a/[core]/es_extended/server/modules/callback.lua +++ b/[core]/es_extended/server/modules/callback.lua @@ -21,54 +21,21 @@ RegisterNetEvent('esx:triggerServerCallback', function(eventName, requestId, inv end, ...) end) -ESX.TriggerClientCallback = setmetatable({ - ---@param player number? - ---@param eventName string - ---@param ... any - Await = function(player, eventName, ...) - player = tonumber(player) +---@param player number playerId +---@param eventName string +---@param callback function +---@param ... any +ESX.TriggerClientCallback = function(player, eventName, callback, ...) + clientRequests[RequestId] = callback - assert(player, 'Argument 1 `player` is not a number!') - assert(type(eventName) == 'string', 'Argument 2 `eventName` is not a string!') + TriggerClientEvent('esx:triggerClientCallback', player, eventName, RequestId, GetInvokingResource() or "unknown", ...) - local p = promise.new() - - clientRequests[RequestId] = p - - TriggerClientEvent('esx:triggerClientCallback', player, eventName, RequestId, GetInvokingResource() or "unknown", ...) - - RequestId = RequestId + 1 - - return Citizen.Await(p) - end -}, { - ---@param player number? playerId - ---@param eventName string - ---@param callback function - ---@param ... any - __call = function(_, player, eventName, callback, ...) - player = tonumber(player) - - assert(player, 'Argument 1 `player` is not a number!') - assert(type(eventName) == 'string', 'Argument 2 `eventName` is not a string!') - assert(type(callback) == 'function', 'Argument 3 `callback` is not a function!') - - clientRequests[RequestId] = callback - - TriggerClientEvent('esx:triggerClientCallback', player, eventName, RequestId, GetInvokingResource() or "unknown", ...) - - RequestId = RequestId + 1 - end -}) + RequestId = RequestId + 1 +end RegisterNetEvent('esx:clientCallback', function(requestId, invoker, ...) if not clientRequests[requestId] then - return print(('[^1ERROR^7] Client Callback with requestId ^5%s^7 Was Called by ^5%s^7 but does not exist.'):format(requestId, invoker)) - end - - if type(clientRequests[requestId]) == 'table' then - clientRequests[requestId]:resolve(...) - return + return print(('[^1ERROR^7] Client Callback with requestId ^5%s^7 Was Called by ^5%s^7 but does not exist.'):format(requestId, invoker)) end clientRequests[requestId](...) From b32ac5aed2790d30a43322d9952aee52687ae958 Mon Sep 17 00:00:00 2001 From: Thekuca <63980591+Thekuca@users.noreply.github.com> Date: Sun, 4 Jun 2023 00:20:33 +0200 Subject: [PATCH 33/34] revert(client/callbacks): revert old code --- .../es_extended/client/modules/callback.lua | 43 ++++--------------- 1 file changed, 9 insertions(+), 34 deletions(-) diff --git a/[core]/es_extended/client/modules/callback.lua b/[core]/es_extended/client/modules/callback.lua index 3d9ac88a..dfeae8fa 100644 --- a/[core]/es_extended/client/modules/callback.lua +++ b/[core]/es_extended/client/modules/callback.lua @@ -3,47 +3,22 @@ local serverRequests = {} local clientCallbacks = {} -ESX.TriggerServerCallback = setmetatable({ - ---@param eventName string - ---@param ... any - Await = function(eventName, ...) - assert(type(eventName) == 'string', 'Argument 1 `eventName` is not a string!') - local p = promise.new() +---@param eventName string +---@param callback function +---@param ... any +ESX.TriggerServerCallback = function(eventName, callback, ...) + serverRequests[RequestId] = callback + + TriggerServerEvent('esx:triggerServerCallback', eventName, RequestId, GetInvokingResource() or "unknown", ...) - serverRequests[RequestId] = p - - TriggerServerEvent('esx:triggerServerCallback', eventName, RequestId, GetInvokingResource() or "unknown", ...) - - RequestId = RequestId + 1 - - return Citizen.Await(p) - end -}, { - ---@param eventName string - ---@param callback function - ---@param ... any - __call = function(_, eventName, callback, ...) - assert(type(eventName) == 'string', 'Argument 1 `eventName` is not a string!') - assert(type(callback) == 'function', 'Argument 2 `callback` is not a function!') - - serverRequests[RequestId] = callback - - TriggerServerEvent('esx:triggerServerCallback', eventName, RequestId, GetInvokingResource() or "unknown", ...) - - RequestId = RequestId + 1 - end -}) + RequestId = RequestId + 1 +end RegisterNetEvent('esx:serverCallback', function(requestId, invoker, ...) if not serverRequests[requestId] then return print(('[^1ERROR^7] Server Callback with requestId ^5%s^7 Was Called by ^5%s^7 but does not exist.'):format(requestId, invoker)) end - if type(serverRequests[requestId]) == 'table' then - serverRequests[requestId]:resolve(...) - return - end - serverRequests[requestId](...) serverRequests[requestId] = nil end) From cdfe4ddf438052a2c9455b0381dfbae9e2093f69 Mon Sep 17 00:00:00 2001 From: Thekuca <63980591+Thekuca@users.noreply.github.com> Date: Sun, 4 Jun 2023 00:32:37 +0200 Subject: [PATCH 34/34] revert(client/main): revert to old callbacks --- [core]/es_extended/client/main.lua | 155 +++++++++++++++-------------- 1 file changed, 78 insertions(+), 77 deletions(-) diff --git a/[core]/es_extended/client/main.lua b/[core]/es_extended/client/main.lua index 1ddc15be..3fe61e8e 100644 --- a/[core]/es_extended/client/main.lua +++ b/[core]/es_extended/client/main.lua @@ -522,82 +522,82 @@ AddEventHandler("esx:tpm", function() local GetBlipInfoIdCoord = GetBlipInfoIdCoord local GetVehiclePedIsIn = GetVehiclePedIsIn - local admin = ESX.TriggerServerCallback.Await("esx:isUserAdmin") - if not admin then - return - end - - local blipMarker = GetFirstBlipInfoId(8) - if not DoesBlipExist(blipMarker) then - ESX.ShowNotification(TranslateCap('tpm_nowaypoint'), true, false, 140) - return 'marker' - end - - -- Fade screen to hide how clients get teleported. - DoScreenFadeOut(650) - while not IsScreenFadedOut() do - Wait(0) - end - - local ped, coords = ESX.PlayerData.ped, GetBlipInfoIdCoord(blipMarker) - local vehicle = GetVehiclePedIsIn(ped, false) - local oldCoords = GetEntityCoords(ped) - - -- Unpack coords instead of having to unpack them while iterating. - -- 825.0 seems to be the max a player can reach while 0.0 being the lowest. - local x, y, groundZ, Z_START = coords['x'], coords['y'], 850.0, 950.0 - local found = false - FreezeEntityPosition(vehicle > 0 and vehicle or ped, true) - - for i = Z_START, 0, -25.0 do - local z = i - if (i % 2) ~= 0 then - z = Z_START - i + ESX.TriggerServerCallback("esx:isUserAdmin", function(admin) + if not admin then + return + end + local blipMarker = GetFirstBlipInfoId(8) + if not DoesBlipExist(blipMarker) then + ESX.ShowNotification(TranslateCap('tpm_nowaypoint'), true, false, 140) + return 'marker' end - NewLoadSceneStart(x, y, z, x, y, z, 50.0, 0) - local curTime = GetGameTimer() - while IsNetworkLoadingScene() do - if GetGameTimer() - curTime > 1000 then - break - end + -- Fade screen to hide how clients get teleported. + DoScreenFadeOut(650) + while not IsScreenFadedOut() do Wait(0) end - NewLoadSceneStop() - SetPedCoordsKeepVehicle(ped, x, y, z) - while not HasCollisionLoadedAroundEntity(ped) do - RequestCollisionAtCoord(x, y, z) - if GetGameTimer() - curTime > 1000 then + local ped, coords = ESX.PlayerData.ped, GetBlipInfoIdCoord(blipMarker) + local vehicle = GetVehiclePedIsIn(ped, false) + local oldCoords = GetEntityCoords(ped) + + -- Unpack coords instead of having to unpack them while iterating. + -- 825.0 seems to be the max a player can reach while 0.0 being the lowest. + local x, y, groundZ, Z_START = coords['x'], coords['y'], 850.0, 950.0 + local found = false + FreezeEntityPosition(vehicle > 0 and vehicle or ped, true) + + for i = Z_START, 0, -25.0 do + local z = i + if (i % 2) ~= 0 then + z = Z_START - i + end + + NewLoadSceneStart(x, y, z, x, y, z, 50.0, 0) + local curTime = GetGameTimer() + while IsNetworkLoadingScene() do + if GetGameTimer() - curTime > 1000 then + break + end + Wait(0) + end + NewLoadSceneStop() + SetPedCoordsKeepVehicle(ped, x, y, z) + + while not HasCollisionLoadedAroundEntity(ped) do + RequestCollisionAtCoord(x, y, z) + if GetGameTimer() - curTime > 1000 then + break + end + Wait(0) + end + + -- Get ground coord. As mentioned in the natives, this only works if the client is in render distance. + found, groundZ = GetGroundZFor_3dCoord(x, y, z, false) + if found then + Wait(0) + SetPedCoordsKeepVehicle(ped, x, y, groundZ) break end Wait(0) end - -- Get ground coord. As mentioned in the natives, this only works if the client is in render distance. - found, groundZ = GetGroundZFor_3dCoord(x, y, z, false) - if found then - Wait(0) - SetPedCoordsKeepVehicle(ped, x, y, groundZ) - break + -- Remove black screen once the loop has ended. + DoScreenFadeIn(650) + FreezeEntityPosition(vehicle > 0 and vehicle or ped, false) + + if not found then + -- If we can't find the coords, set the coords to the old ones. + -- We don't unpack them before since they aren't in a loop and only called once. + SetPedCoordsKeepVehicle(ped, oldCoords['x'], oldCoords['y'], oldCoords['z'] - 1.0) + ESX.ShowNotification(TranslateCap('tpm_success'), true, false, 140) end - Wait(0) - end - -- Remove black screen once the loop has ended. - DoScreenFadeIn(650) - FreezeEntityPosition(vehicle > 0 and vehicle or ped, false) - - if not found then - -- If we can't find the coords, set the coords to the old ones. - -- We don't unpack them before since they aren't in a loop and only called once. - SetPedCoordsKeepVehicle(ped, oldCoords['x'], oldCoords['y'], oldCoords['z'] - 1.0) + -- If Z coord was found, set coords in found coords. + SetPedCoordsKeepVehicle(ped, x, y, groundZ) ESX.ShowNotification(TranslateCap('tpm_success'), true, false, 140) - end - - -- If Z coord was found, set coords in found coords. - SetPedCoordsKeepVehicle(ped, x, y, groundZ) - ESX.ShowNotification(TranslateCap('tpm_success'), true, false, 140) + end) end) local noclip = false @@ -646,23 +646,24 @@ local function noclipThread() end RegisterNetEvent("esx:noclip") -AddEventHandler("esx:noclip", function() - local admin = ESX.TriggerServerCallback.Await("esx:isUserAdmin") - if not admin then - return - end +AddEventHandler("esx:noclip", function(input) + ESX.TriggerServerCallback("esx:isUserAdmin", function(admin) + if not admin then + return + end - if not noclip then - noclip_pos = GetEntityCoords(ESX.PlayerData.ped, false) - heading = GetEntityHeading(ESX.PlayerData.ped) - end + if not noclip then + noclip_pos = GetEntityCoords(ESX.PlayerData.ped, false) + heading = GetEntityHeading(ESX.PlayerData.ped) + end - noclip = not noclip - if noclip then - CreateThread(noclipThread) - end + noclip = not noclip + if noclip then + CreateThread(noclipThread) + end - ESX.ShowNotification(TranslateCap('noclip_message', noclip and "enabled" or "disabled"), true, false, 140) + ESX.ShowNotification(TranslateCap('noclip_message', noclip and "enabled" or "disabled"), true, false, 140) + end) end) RegisterNetEvent("esx:killPlayer")