Check if player already has weapon

This commit is contained in:
ElPumpo
2018-11-11 11:22:41 +01:00
parent b50650db54
commit 093d5535a6
9 changed files with 34 additions and 9 deletions
+7 -2
View File
@@ -58,12 +58,17 @@ AddEventHandler('esx_weashop:buyItem', function(weaponName, zone)
local xPlayer = ESX.GetPlayerFromId(_source)
local price = GetPrice(weaponName, zone)
if xPlayer.hasWeapon(weaponName) then
TriggerClientEvent('esx:showNotification', _source, _U('already_owned'))
return
end
if zone == "BlackWeashop" then
if xPlayer.getAccount('black_money').money >= price then
xPlayer.removeAccountMoney('black_money', price)
xPlayer.addWeapon(weaponName, 42)
TriggerClientEvent('esx:showNotification', _source, _U('buy', ESX.GetWeaponLabel(weaponName)))
TriggerClientEvent('esx:showNotification', _source, _U('buy', ESX.GetWeaponLabel(weaponName), price))
else
TriggerClientEvent('esx:showNotification', _source, _U('not_enough_black'))
end
@@ -73,7 +78,7 @@ AddEventHandler('esx_weashop:buyItem', function(weaponName, zone)
if xPlayer.getMoney() >= price then
xPlayer.removeMoney(price)
xPlayer.addWeapon(weaponName, 42)
TriggerClientEvent('esx:showNotification', _source, _U('buy', ESX.GetWeaponLabel(weaponName)))
TriggerClientEvent('esx:showNotification', _source, _U('buy', ESX.GetWeaponLabel(weaponName), price))
else
TriggerClientEvent('esx:showNotification', _source, _U('not_enough'))
end