• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Buy item with lever (ingame)

Joriku

Working in the mines, need something?
Joined
Jul 16, 2016
Messages
1,175
Solutions
17
Reaction score
481
Location
Sweden
Hello,
Anyone here that knows how to make it possible to buy an item by clicking a lever in tfs 1.2?
Example: "Clicking Lever" -> You do not have enough Money to buy this item.
Example 2: Magic Sword, Costs 200Cc. Clicks the lever and the money is gone from bp and the item is in the backpack
 
Solution
Pull a lever to buy an item (https://otland.net/threads/pull-a-lever-to-buy-an-item.156994/post-1511319)
Modified for 1.2
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

function references in compat.lua
otland/forgottenserver...
Pull a lever to buy an item (https://otland.net/threads/pull-a-lever-to-buy-an-item.156994/post-1511319)
Modified for 1.2
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

function references in compat.lua
otland/forgottenserver (https://github.com/otland/forgottenserver/blob/1.2/data/lib/compat/compat.lua#L369)
otland/forgottenserver (https://github.com/otland/forgottenserver/blob/1.2/data/lib/compat/compat.lua#L379)
otland/forgottenserver (https://github.com/otland/forgottenserver/blob/1.2/data/lib/compat/compat.lua#L399)
otland/forgottenserver (https://github.com/otland/forgottenserver/blob/1.2/data/lib/compat/compat.lua#L405)
 
Solution
Pull a lever to buy an item (https://otland.net/threads/pull-a-lever-to-buy-an-item.156994/post-1511319)
Modified for 1.2
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

function references in compat.lua
otland/forgottenserver (https://github.com/otland/forgottenserver/blob/1.2/data/lib/compat/compat.lua#L369)
otland/forgottenserver (https://github.com/otland/forgottenserver/blob/1.2/data/lib/compat/compat.lua#L379)
otland/forgottenserver (https://github.com/otland/forgottenserver/blob/1.2/data/lib/compat/compat.lua#L399)
otland/forgottenserver (https://github.com/otland/forgottenserver/blob/1.2/data/lib/compat/compat.lua#L405)
How do i change it so i can use another item as payment instead of Crystal coins?
 
Last edited:

Similar threads

Back
Top