mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 01:08:54 +00:00
Merge pull request #167 from Tinky124/patch-2
fix(es_extended/server/main.lua): fix giving weapon components + tints, feat(es_extended/server/main.lua): add distance check
This commit is contained in:
@@ -20,3 +20,5 @@ Config.EnablePVP = true -- Allow Player to player combat
|
||||
|
||||
Config.Multichar = true -- Enable support for esx_multicharacter
|
||||
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.
|
||||
|
||||
@@ -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 > Config.DistanceGive 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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user