• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Action [TFS 1.3]Lever shop

Eduardo170

Well-Known Member
Joined
Jan 7, 2014
Messages
422
Solutions
3
Reaction score
66
Location
Caracas, Venezuela
I did this but I dont know how add transform item(maybe when I looked at another script with that function), but this work fine.
[UniqueId] = item = id, cost = money, count = 1
Code:
local shop = {
    [2051] = {id = 2494, cost = 10000, count = 1},
    [2052] = {id = 2495, cost = 1000, count = 1},
    [2053] = {id = 2496, cost = 1000, count = 1},
    [2054] = {id = 2497, cost = 10000, count = 1},
    [2055] = {id = 2498, cost = 10000, count = 1},
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local ShopItem = shop[item.uid]
    local itemType = ItemType(ShopItem.id)
    if ShopItem then
        if(not player:removeMoney(ShopItem.cost)) then
            player:sendTextMessage(MESSAGE_INFO_DESCR, 'You need '..ShopItem.cost..' to buy '.. itemType:getName() .. '.')
            return false
        end     
        player:addItem(ShopItem.id, ShopItem.count)
        player:removeMoney(ShopItem.cost)
        player:sendTextMessage(MESSAGE_INFO_DESCR, 'You bought a '.. itemType:getName() .. '.')
        player:getPosition():sendMagicEffect(13) 
    end
    return true
end
Update: With transform items
Code:
local lever_id = 1945 -- id of lever before pulled
local pulled_id = 1946 -- id of lever after pulled
local shop = {
    [2051] = {id = 2494, cost = 10000, count = 1},
    [2052] = {id = 2495, cost = 1000, count = 1},
    [2053] = {id = 2496, cost = 1000, count = 1},
    [2054] = {id = 2497, cost = 10000, count = 1},
    [2055] = {id = 2498, cost = 10000, count = 1},
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    
    local ShopItem = shop[item.uid]
    local itemType = ItemType(ShopItem.id)
    if item.itemid ~= pulled_id then
           if ShopItem then
            if(not player:removeMoney(ShopItem.cost)) then
                player:sendTextMessage(MESSAGE_INFO_DESCR, 'You need '..ShopItem.cost..' to buy '.. itemType:getName() .. '.')
                return false
            end     
            item:transform(pulled_id)
            player:addItem(ShopItem.id, ShopItem.count)
            player:removeMoney(ShopItem.cost)
            player:sendTextMessage(MESSAGE_INFO_DESCR, 'You bought a '.. itemType:getName() .. '.')
            player:getPosition():sendMagicEffect(13)   
        end
    else
        item:transform(lever_id)
        return true
    end
end
 
Last edited:
how i can fixed? still getting items even without money :/
Here you have a script that I got requesting this a while ago, works fine.
Lua:
local c = {
    ['item'] = 2565,
    ['cost'] = 200 * 10000,
    [1945] = 1946, -- lever
    [1946] = 1945 -- lever
}

function onUse(player, item, fromPosition, itemEx, toPosition)
  local cid = player:getId()
    if doPlayerRemoveMoney(cid, c.cost) then
            doPlayerAddItem(cid, c.item, 1)
            doPlayerSendTextMessage(cid, 25,"You bought an item for ".. c.cost .." gold")
    else
            doPlayerSendCancel(cid, "You do not have enough money!")
    end
  item:transform(c[item.itemid])
    return true
end
 
Back
Top