I'm working on a game but Im havin a bit of a problem. The problem is for example if i buy 1 ham it charges 55 gold and I get 1 ham but if I want 5 ham I get 5 ham but it only charge 55 gold when it should charge 275 gold.
_state = 0
_count = 0
_index = 0
-- List of items you can buy
items = {}
items[0] = {name = 'ham', id = 456, price = 55}
items[1] = {name = 'fish', id = 201, price = 60}
items[2] = {name = 'mushroom', id = 355, price = 150}
items[3] = {name = 'bread', id = 356, price = 10}
The Function
local function onActionItem(action)
amount = ''
suffix = ''
plural = 'a'
if (_count > 1) then
amount = ' ' .. tostring(_count)
suffix = 's'
plural = ''
end
cost = items[_index].price
selfSay('Do you want to buy ' .. plural .. amount .. ' ' .. items[_index].name .. suffix .. ' for ' .. cost .. ' gold?', 1000)
end