diff --git a/client/main.lua b/client/main.lua index 8dda3be2..4ae3bf3a 100644 --- a/client/main.lua +++ b/client/main.lua @@ -495,7 +495,7 @@ function OpenBodySearchMenu(player) }, function(data, menu) if data.current.value then TriggerServerEvent('esx_policejob:confiscatePlayerItem', GetPlayerServerId(player), data.current.itemType, data.current.value, data.current.amount) - menu.close() + OpenBodySearchMenu(player) end end, function(data, menu) menu.close() diff --git a/server/main.lua b/server/main.lua index 7d2bb3ba..3206b628 100644 --- a/server/main.lua +++ b/server/main.lua @@ -43,19 +43,32 @@ AddEventHandler('esx_policejob:confiscatePlayerItem', function(target, itemType, end elseif itemType == 'item_account' then - targetXPlayer.removeAccountMoney(itemName, amount) - sourceXPlayer.addAccountMoney (itemName, amount) + local targetAccount = targetXPlayer.getAccount(itemName) - sourceXPlayer.showNotification(_U('you_confiscated_account', amount, itemName, targetXPlayer.name)) - targetXPlayer.showNotification(_U('got_confiscated_account', amount, itemName, sourceXPlayer.name)) + -- does the target player have enough money? + if targetAccount.money >= amount then + targetXPlayer.removeAccountMoney(itemName, amount) + sourceXPlayer.addAccountMoney (itemName, amount) + + sourceXPlayer.showNotification(_U('you_confiscated_account', amount, itemName, targetXPlayer.name)) + targetXPlayer.showNotification(_U('got_confiscated_account', amount, itemName, sourceXPlayer.name)) + else + sourceXPlayer.showNotification(_U('quantity_invalid')) + end elseif itemType == 'item_weapon' then if amount == nil then amount = 0 end - targetXPlayer.removeWeapon(itemName, amount) - sourceXPlayer.addWeapon (itemName, amount) - sourceXPlayer.showNotification(_U('you_confiscated_weapon', ESX.GetWeaponLabel(itemName), targetXPlayer.name, amount)) - targetXPlayer.showNotification(_U('got_confiscated_weapon', ESX.GetWeaponLabel(itemName), amount, sourceXPlayer.name)) + -- does the target player have weapon? + if targetXPlayer.hasWeapon(itemName) then + targetXPlayer.removeWeapon(itemName, amount) + sourceXPlayer.addWeapon (itemName, amount) + + sourceXPlayer.showNotification(_U('you_confiscated_weapon', ESX.GetWeaponLabel(itemName), targetXPlayer.name, amount)) + targetXPlayer.showNotification(_U('got_confiscated_weapon', ESX.GetWeaponLabel(itemName), amount, sourceXPlayer.name)) + else + sourceXPlayer.showNotification(_U('quantity_invalid')) + end end end)