Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. AddEventHandler('esx_policejob:confiscatePlayerItem', function(target, itemType, itemName, amount)
  2. local _source = source
  3. local sourceXPlayer = ESX.GetPlayerFromId(_source)
  4. local targetXPlayer = ESX.GetPlayerFromId(target)
  5.  
  6. if itemType == 'item_standard' then
  7. local targetItem = targetXPlayer.getInventoryItem(itemName)
  8. local sourceItem = sourceXPlayer.getInventoryItem(itemName)
  9.  
  10. -- does the target player have enough in their inventory?
  11. if targetItem.count > 0 and targetItem.count <= amount then
  12.  
  13. -- can the player carry the said amount of x item?
  14. if sourceItem.limit ~= -1 and (sourceItem.count + amount) > sourceItem.limit then
  15. TriggerClientEvent('esx:showNotification', _source, _U('quantity_invalid'))
  16. else
  17. targetXPlayer.removeInventoryItem(itemName, amount)
  18. sourceXPlayer.addInventoryItem (itemName, amount)
  19. TriggerClientEvent('esx:showNotification', _source, _U('you_confiscated', amount, sourceItem.label, targetXPlayer.name))
  20. TriggerClientEvent('esx:showNotification', target, _U('got_confiscated', amount, sourceItem.label, sourceXPlayer.name))
  21. end
  22. else
  23. TriggerClientEvent('esx:showNotification', _source, _U('quantity_invalid'))
  24. end
  25.  
  26. elseif itemType == 'item_account' then
  27. targetXPlayer.removeAccountMoney(itemName, amount)
  28. sourceXPlayer.addAccountMoney (itemName, amount)
  29.  
  30. TriggerClientEvent('esx:showNotification', _source, _U('you_confiscated_account', amount, itemName, targetXPlayer.name))
  31. TriggerClientEvent('esx:showNotification', target, _U('got_confiscated_account', amount, itemName, sourceXPlayer.name))
  32.  
  33. elseif itemType == 'item_weapon' then
  34. if amount == nil then amount = 0 end
  35. targetXPlayer.removeWeapon(itemName, amount)
  36. sourceXPlayer.addWeapon (itemName, amount)
  37.  
  38. TriggerClientEvent('esx:showNotification', _source, _U('you_confiscated_weapon', ESX.GetWeaponLabel(itemName), targetXPlayer.name, amount))
  39. TriggerClientEvent('esx:showNotification', target, _U('got_confiscated_weapon', ESX.GetWeaponLabel(itemName), amount, sourceXPlayer.name))
  40. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement