Sebastian Ching
New Member
Greetings, i am using this script, it works perfectly in game, but it shows an error in the console that does not affect the operation, this script is to buy items by pressing the lever, can you help me?
Thank you in advance
Thank you in advance
Lua:
-- Written by Ldrozd with Tairen's advice; do not delete it, you arent the creator
function onUse(cid, item, fromPosition, itemEx, toPosition)
local potion = {
[9020] = {id = 2268, bp = 2268, cost = 300, anim = 30},
}
local actuallPotion = potion[item.actionid]
local weight = getItemWeightById(actuallPotion.id, 20) + getItemWeightById(actuallPotion.bp, 1)
if(getPlayerFreeCap(cid) >= weight) then
if getPlayerMoney(cid) >= actuallPotion.cost then
local bp = doCreateItemEx(cid, actuallPotion.bp, 0)
doAddContainerItem(bp, actuallPotion.id, 20)
if(doPlayerAddItemEx(cid, bp) ~= RETURNVALUE_NOERROR) then
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You need more space in your container.")
else
doPlayerRemoveMoney(cid, actuallPotion.cost)
doSendMagicEffect(toPosition, actuallPotion.anim)
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You have bought a "..getItemNameById(actuallPotion.id).."s for "..actuallPotion.cost.." gold coins.")
end
else
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You need "..actuallPotion.cost.." gold coins to buy these potions.")
end
else
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You need at least "..math.ceil(weight).." oz to buy this item.")
end
if item.itemid == 1945 then
doTransformItem(item.uid, item.itemid+1)
elseif item.itemid == 1946 then
doTransformItem(item.uid, item.itemid-1)
else
return true
end
return true
end