soul4soul
Intermediate OT User
here is the script
when i say "!charges mp,10" my storage value is suppose to increase by 10 b/c i bought more potion charges... instead i get this error.
Code:
function onSay(cid, words, param)
--Start configuration --
local items =
{
['hp'] = {cost = 45, storage = 49989},
['shp'] = {cost = 100, storage = 49988},
['ghp'] = {cost = 190, storage = 49987},
['uhp'] = {cost = 310, storage = 49986},
['mp'] = {cost = 50, storage = 49985},
['smp'] = {cost = 80, storage = 49984},
['gmp'] = {cost = 120, storage = 49983},
['gsp'] = {cost = 190, storage = 49982}
}
-- End configuration --
local t = string.explode(param, ",")
local item = t[1]
local amount = tonumber(t[2])
-- Checks if we can use that itemname --
if item then
-- Checks if the player has enough money --
if doPlayerRemoveMoney(cid, item.cost*amount) == 1 then
doPlayerSendTextMessage(cid, 24, 'You have bought '..amount..' '..item..' charges for '..(item.cost*amount)..' golden pieces.')
setPlayerStorageValue(cid, potion.storage, getPlayerStorageValue(cid, potion.storage)+amount)
else
doPlayerSendCancel(cid, 'You dont have enough money to buy that many charges.')
doSendMagicEffect(getPlayerPosition (cid), CONST_ME_POFF)
end
else
-- Sends the player a message wich includes items he can buy --
doPlayerSendTextMessage (cid, 24, 'You can buy the following items:')
-- Getting the all itemnames --
for item1 in pairs (items) do
-- Sends a message with each itemname and price --
doPlayerSendTextMessage (cid, 24, item1)
end
end
end
Code:
<talkaction words="!charges" event="script" value="charges.lua"/>
[13/08/2010 11:07:48] [Error - TalkAction Interface]
[13/08/2010 11:07:48] data/talkactions/scripts/charges.luanSay
[13/08/2010 11:07:48] Description:
[13/08/2010 11:07:48] data/talkactions/scripts/charges.lua:23: attempt to perform arithmetic on field 'cost' (a nil value)
[13/08/2010 11:07:48] stack traceback:
[13/08/2010 11:07:48] data/talkactions/scripts/charges.lua:23: in function <data/talkactions/scripts/charges.lua:1>