Bug
New Member
- Joined
- Jan 7, 2011
- Messages
- 111
- Reaction score
- 1
Im gettin this error each i perfom the action
error:
Code:
function round(num, idp)
return tonumber(string.format("%." .. (idp or 0) .. "f", num))
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
local pot = potions[item.actionid]
if (pot) then
local itemC = doCreateItemEx(pot.container)
for i = 1, pot.quantity do
doAddContainerItem(itemC, pot.item, 100)
end
local neededCap = 0
neededCap = ItemType(pot.container):getWeight()
neededCap = neededCap + (ItemType(pot.item):getWeight() * (pot.quantity * 100))
neededCap = round(neededCap)
local neededMoney = (pot.quantity * pot.price) * 100
local pos = getThingPos(cid)
local player = Player(cid)
if (player:getMoney() < neededMoney) then
doPlayerSendTextMessage(cid, 19, "[ItemShop] You don't have enough money, you need "..neededMoney/1000 .." K.")
doSendMagicEffect(pos, 2)
return true
end
doSendMagicEffect(fromPosition, pot.effect)
it = doPlayerAddItemEx(cid, itemC)
local word = string.split(ItemType(pot.container):getName(), " ")
local str = "[ItemShop] You purchased a full "..word[2].." of "..ItemType(pot.item):getName().." for "..neededMoney/1000 .." K."
if (it ~= 1) then
doPlayerSendTextMessage(cid, 27, "You don't have enough room or cap on your inventory.")
return true
else
local pos = getThingPos(cid)
doSendDistanceShoot(fromPosition, pos, pot.distanceEffect)
doSendMagicEffect(pos, pot.effect)
doPlayerRemoveMoney(cid, neededMoney)
end
doPlayerSendTextMessage(cid, 27, str)
end
return true
end
Code:
Lua Script Error: [Action Interface]
data/actions/scripts/other/runesShop.lua:onUse
data/actions/scripts/other/runesShop.lua:20: attempt to perform arithmetic on field 'price' (a nil value)
stack traceback:
[C]: in function '__mul'
data/actions/scripts/other/runesShop.lua:20: in function <data/actions/scripts/other/runesShop.lua:6>