script: [Release] esx_hunting - Hunt animals and sell meat
I tried to change xPlayer.addMoney to xPlayer.addAccountMoney but it doesn’t work and I can’t sell meats and leathers.
RegisterServerEvent('esx-qalle-hunting:sell')
AddEventHandler('esx-qalle-hunting:sell', function()
local xPlayer = ESX.GetPlayerFromId(source)
local MeatPrice = 150
local LeatherPrice = 80
local MeatQuantity = xPlayer.getInventoryItem('meat').count
local LeatherQuantity = xPlayer.getInventoryItem('leather').count
if MeatQuantity > 0 or LeatherQuantity > 0 then
xPlayer.addAccountMoney(MeatQuantity * MeatPrice)
xPlayer.addAccountMoney(LeatherQuantity * LeatherPrice)
xPlayer.removeInventoryItem('meat', MeatQuantity)
xPlayer.removeInventoryItem('leather', LeatherQuantity)
TriggerClientEvent('esx:showNotification', xPlayer.source, 'You sold ' .. LeatherQuantity + MeatQuantity .. ' and earned $' .. LeatherPrice * LeatherQuantity + MeatPrice * MeatQuantity)
else
TriggerClientEvent('esx:showNotification', xPlayer.source, 'You don\'t have any meat or leather')
end
end)