Changed how pickups work, see desc. Fixed #338, fixed #420

- Pickups now require you to press E once nearby to pick up
- Fixed pickup objects sometimes not showing up #420
- Added animation to picking up and throwing items
- Added message when inventory cannot accept picking up item
This commit is contained in:
ElPumpo
2020-01-03 19:20:26 +01:00
parent 9b33a3e6ca
commit 2f75152457
11 changed files with 98 additions and 59 deletions
+18 -14
View File
@@ -419,24 +419,28 @@ end)
RegisterServerEvent('esx:onPickup')
AddEventHandler('esx:onPickup', function(id)
local playerId = source
local pickup = ESX.Pickups[id]
local xPlayer = ESX.GetPlayerFromId(playerId)
local pickup, xPlayer, success = ESX.Pickups[id], ESX.GetPlayerFromId(source)
if pickup.type == 'item_standard' then
if xPlayer.canCarryItem(pickup.name, pickup.count) then
xPlayer.addInventoryItem(pickup.name, pickup.count)
if pickup then
if pickup.type == 'item_standard' then
if xPlayer.canCarryItem(pickup.name, pickup.count) then
xPlayer.addInventoryItem(pickup.name, pickup.count)
success = true
else
xPlayer.showNotification(_U('threw_cannot_pickup'))
end
elseif pickup.type == 'item_money' then
success = true
xPlayer.addMoney(pickup.count)
elseif pickup.type == 'item_account' then
success = true
xPlayer.addAccountMoney(pickup.name, pickup.count)
end
if success then
ESX.Pickups[id] = nil
TriggerClientEvent('esx:removePickup', -1, id)
end
elseif pickup.type == 'item_money' then
ESX.Pickups[id] = nil
TriggerClientEvent('esx:removePickup', -1, id)
xPlayer.addMoney(pickup.count)
elseif pickup.type == 'item_account' then
ESX.Pickups[id] = nil
TriggerClientEvent('esx:removePickup', -1, id)
xPlayer.addAccountMoney(pickup.name, pickup.count)
end
end)