From ac7459d05a08ea2c4bb9313bfb7bfe978c513249 Mon Sep 17 00:00:00 2001 From: Tinky <48660658+Tinky124@users.noreply.github.com> Date: Sun, 20 Mar 2022 20:02:23 +0100 Subject: [PATCH] Protection, fixed giving weapons components, tints --- [esx]/es_extended/server/main.lua | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/[esx]/es_extended/server/main.lua b/[esx]/es_extended/server/main.lua index 37584df5..f9ee2366 100644 --- a/[esx]/es_extended/server/main.lua +++ b/[esx]/es_extended/server/main.lua @@ -360,6 +360,11 @@ if not Config.OxInventory then local playerId = source local sourceXPlayer = ESX.GetPlayerFromId(playerId) local targetXPlayer = ESX.GetPlayerFromId(target) + local distance = #(GetEntityCoords(GetPlayerPed(playerId)) - GetEntityCoords(GetPlayerPed(target))) + if not sourceXPlayer then return end + if not targetXPlayer then print("Cheating: " .. GetPlayerName(playerId)) return end + if distance > 4.0 then print("Cheating: " .. GetPlayerName(playerId)) return end + if type == 'item_standard' then local sourceItem = sourceXPlayer.getInventoryItem(itemName) @@ -390,12 +395,20 @@ if not Config.OxInventory then elseif type == 'item_weapon' then if sourceXPlayer.hasWeapon(itemName) then local weaponLabel = ESX.GetWeaponLabel(itemName) - if not targetXPlayer.hasWeapon(itemName) then local _, weapon = sourceXPlayer.getWeapon(itemName) local _, weaponObject = ESX.GetWeapon(itemName) itemCount = weapon.ammo - + local weaponComponents = ESX.Table.Clone(weapon.components) + local weaponTint = weapon.tintIndex + if weaponTint then + targetXPlayer.setWeaponTint(itemName, weaponTint) + end + if weaponComponents then + for k, v in pairs(weaponComponents) do + targetXPlayer.addWeaponComponent(itemName, v) + end + end sourceXPlayer.removeWeapon(itemName) targetXPlayer.addWeapon(itemName, itemCount)