i just felt the need to say that this is my very first attempt at writing something.
so i made an attempt to make a shop that uses actionids on levers, but I just cannot get it to work and I cannot see any errors. what am I missing?
so i made an attempt to make a shop that uses actionids on levers, but I just cannot get it to work and I cannot see any errors. what am I missing?
Lua:
local shop = {
[2051] = {id = 12325, cost = 2, count = 1},
[2052] = {id = 8300, cost = 3, count = 1},
[2053] = {id = 12662, cost = 5, count = 1},
}
local levershop = Action()
function levershop.onUse(player, item, fromPosition, target, toPosition, isHotkey)
local config = {
shopitem = shop[item.aid],
itemType = ItemType(ShopItem.id),
token = item.itemid(6527)
}
if item.itemid == 1945 or 1946 then
if(not doPlayerRemoveItem(cid, token, shopitem.cost)) then
player:sendTextMessage(MESSAGE_INFO_DESCR, 'You need '..ShopItem.cost..' to buy '.. itemType:getName() .. '.')
return false
else doPlayerRemoveItem(cid, token, shopitem.cost) then
player:addItem(ShopItem.id, ShopItem.count)
doPlayerRemoveItem(cid, token, ShopItem.cost)
player:sendTextMessage(MESSAGE_INFO_DESCR, 'You bought a '.. itemType:getName() .. '.')
player:getPosition():sendMagicEffect(13)
end
end
end
levershop:aid(shop)
levershop:register()
Last edited: