Fix pickup spawn behind any player

This commit is contained in:
Jérémie N'gadi
2017-08-21 13:38:27 +02:00
parent 0ef34c5491
commit 93daeaaf45
3 changed files with 10 additions and 10 deletions
@@ -270,12 +270,12 @@ AddEventHandler('esx:spawnObject', function(model)
end)
RegisterNetEvent('esx:pickup')
AddEventHandler('esx:pickup', function(id, label)
AddEventHandler('esx:pickup', function(id, label, coords)
local playerPed = GetPlayerPed(-1)
local coords = GetEntityCoords(playerPed)
local forward = GetEntityForwardVector(playerPed)
local x, y, z = table.unpack(coords + forward * -2.0)
local ped = GetPlayerPed(GetPlayerFromServerId(player))
local coords = GetEntityCoords(ped)
local forward = GetEntityForwardVector(ped)
local x, y, z = table.unpack(coords + forward * -2.0)
ESX.Game.SpawnLocalObject('prop_money_bag_01', {
x = x,
@@ -224,7 +224,7 @@ ESX.GetWeaponLabel = function(name)
end
ESX.CreatePickup = function(type, name, count, label)
ESX.CreatePickup = function(type, name, count, label, player)
local pickupId = (ESX.PickupId == 65635 and 0 or ESX.PickupId + 1)
@@ -234,7 +234,7 @@ ESX.CreatePickup = function(type, name, count, label)
count = count
}
TriggerClientEvent('esx:pickup', -1, pickupId, label)
TriggerClientEvent('esx:pickup', -1, pickupId, label, player)
ESX.PickupId = pickupId
@@ -404,7 +404,7 @@ AddEventHandler('esx:removeInventoryItem', function(type, itemName, itemCount)
if total > 0 then
xPlayer.removeInventoryItem(itemName, total)
ESX.CreatePickup('item_standard', itemName, total, foundItem.label)
ESX.CreatePickup('item_standard', itemName, total, foundItem.label, _source)
TriggerClientEvent('esx:showNotification', _source, _U('threw') .. ' ' .. foundItem.label .. ' x' .. total)
end
@@ -439,7 +439,7 @@ AddEventHandler('esx:removeInventoryItem', function(type, itemName, itemCount)
if total > 0 then
xPlayer.removeMoney(total)
ESX.CreatePickup('item_money', 'money', total, 'Cash')
ESX.CreatePickup('item_money', 'money', total, 'Cash', _source)
TriggerClientEvent('esx:showNotification', _source, _U('threw') .. ' [Cash] $' .. total)
end
@@ -474,7 +474,7 @@ AddEventHandler('esx:removeInventoryItem', function(type, itemName, itemCount)
if total > 0 then
xPlayer.removeAccountMoney(itemName, total)
ESX.CreatePickup('item_account', itemName, total, 'Cash')
ESX.CreatePickup('item_account', itemName, total, 'Cash', _source)
TriggerClientEvent('esx:showNotification', _source, _U('threw') .. ' [Cash] $' .. total)
end