mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-31 10:18:54 +00:00
Fix give weapon
This commit is contained in:
@@ -463,11 +463,11 @@ ESX.Game.GetClosestPlayer = function(coords)
|
||||
local closestPlayer = -1
|
||||
local coords = coords
|
||||
local usePlayerPed = false
|
||||
local playerPed = nil
|
||||
local playerPed = GetPlayerPed(-1)
|
||||
local playerId = PlayerId()
|
||||
|
||||
if coords == nil then
|
||||
usePlayerPed = true
|
||||
playerPed = GetPlayerPed(-1)
|
||||
coords = GetEntityCoords(playerPed)
|
||||
end
|
||||
|
||||
@@ -475,7 +475,7 @@ ESX.Game.GetClosestPlayer = function(coords)
|
||||
|
||||
local target = GetPlayerPed(players[i])
|
||||
|
||||
if not usePlayerPed or (usePlayerPed and target ~= playerPed) then
|
||||
if not usePlayerPed or (usePlayerPed and players[i] ~= playerId) then
|
||||
|
||||
local targetCoords = GetEntityCoords(target)
|
||||
local distance = GetDistanceBetweenCoords(targetCoords.x, targetCoords.y, targetCoords.z, coords.x, coords.y, coords.z, true)
|
||||
@@ -944,7 +944,15 @@ ESX.ShowInventory = function()
|
||||
if data.current.action == 'give' then
|
||||
|
||||
if type == 'item_weapon' then
|
||||
TriggerServerEvent('esx:giveInventoryItem', GetPlayerServerId(closestPlayer), type, item, 1)
|
||||
|
||||
local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer()
|
||||
|
||||
if closestPlayer == -1 or closestDistance > 3.0 then
|
||||
ESX.ShowNotification(_U('players_nearby'))
|
||||
else
|
||||
TriggerServerEvent('esx:giveInventoryItem', GetPlayerServerId(closestPlayer), type, item, 1)
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
ESX.UI.Menu.Open(
|
||||
|
||||
Reference in New Issue
Block a user