Joriku
Working in the mines, need something?
Here's an updated version from this thread: Action - [TFS 1.3]Lever shop (https://otland.net/threads/tfs-1-3-lever-shop.268777/)
Lua:
local testAction = Action() -- this is our header, the first thing we have to write (except for configuration tables and such)
local c = {
itemid = 23373,
price = 1 * 10000
}
function testAction.onUse(player, item, fromPosition, target, toPosition, isHotkey) -- now we can design the action itself
local tokenCost = player:getItemCount(c.tokenId)
if player:removeMoney(c.price) then
player:addItem(c.itemid, 1)
player:sendCancelMessage("Your purshase was successful.")
fromPosition:sendMagicEffect(CONST_ME_HEARTS)
else
player:sendCancelMessage("You do not have enough money.")
fromPosition:sendMagicEffect(CONST_ME_POFF)
end
return true
end
testAction:aid(701) -- the action id for lever
testAction:register() -- this is our footer, it has to be the last function executed