Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AddEventHandler('esx_policejob:confiscatePlayerItem', function(target, itemType, itemName, amount)
- local _source = source
- local sourceXPlayer = ESX.GetPlayerFromId(_source)
- local targetXPlayer = ESX.GetPlayerFromId(target)
- if itemType == 'item_standard' then
- local targetItem = targetXPlayer.getInventoryItem(itemName)
- local sourceItem = sourceXPlayer.getInventoryItem(itemName)
- -- does the target player have enough in their inventory?
- if targetItem.count > 0 and targetItem.count <= amount then
- -- can the player carry the said amount of x item?
- if sourceItem.limit ~= -1 and (sourceItem.count + amount) > sourceItem.limit then
- TriggerClientEvent('esx:showNotification', _source, _U('quantity_invalid'))
- else
- targetXPlayer.removeInventoryItem(itemName, amount)
- sourceXPlayer.addInventoryItem (itemName, amount)
- TriggerClientEvent('esx:showNotification', _source, _U('you_confiscated', amount, sourceItem.label, targetXPlayer.name))
- TriggerClientEvent('esx:showNotification', target, _U('got_confiscated', amount, sourceItem.label, sourceXPlayer.name))
- end
- else
- TriggerClientEvent('esx:showNotification', _source, _U('quantity_invalid'))
- end
- elseif itemType == 'item_account' then
- targetXPlayer.removeAccountMoney(itemName, amount)
- sourceXPlayer.addAccountMoney (itemName, amount)
- TriggerClientEvent('esx:showNotification', _source, _U('you_confiscated_account', amount, itemName, targetXPlayer.name))
- TriggerClientEvent('esx:showNotification', target, _U('got_confiscated_account', amount, itemName, sourceXPlayer.name))
- elseif itemType == 'item_weapon' then
- if amount == nil then amount = 0 end
- targetXPlayer.removeWeapon(itemName, amount)
- sourceXPlayer.addWeapon (itemName, amount)
- TriggerClientEvent('esx:showNotification', _source, _U('you_confiscated_weapon', ESX.GetWeaponLabel(itemName), targetXPlayer.name, amount))
- TriggerClientEvent('esx:showNotification', target, _U('got_confiscated_weapon', ESX.GetWeaponLabel(itemName), amount, sourceXPlayer.name))
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement