• 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!

request lever script

matthew4321

Mapper
Joined
Jan 19, 2011
Messages
91
Reaction score
4
hello otlanders im in need of a lever script that buys x item for x money tfs 1.2 thanks in advance
 
lever.png


message.png


In the example below:
2400 = SoV
2431 = SCA
2421 = Thunder Hammer

The 12000 - 12002 represents the action id of each lever

Code:
local items = {
    [12000] = {itemId = 2400, itemCount = 1, cost = 5000},
    [12001] = {itemId = 2431, itemCount = 1, cost = 100000},
    [12002] = {itemId = 2421, itemCount = 2, cost = 250000}
}

function onUse(player, item, fromPosition, itemEx, toPosition)
    local lever = items[item.actionid]
    local count = lever.itemCount
    local id = lever.itemId
    local cost = lever.cost

    if player:getMoney() >= cost then
        player:removeMoney(cost)
        player:addItem(id, count)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You purchased " .. count .. " " .. ItemType(id):getName() .. (count > 1 and 's' or '') .. " for " .. cost .. " gps.")
        Item(item.uid):transform(item.itemid == 1946 and 1945 or 1946)
        toPosition:sendMagicEffect(CONST_ME_MAGIC_RED)
    else
        player:sendCancelMessage("You need " .. cost .. " gps to pull this lever.")
        toPosition:sendMagicEffect(CONST_ME_POFF)
    end
    return true
end
 
lever.png


message.png


In the example below:
2400 = SoV
2431 = SCA
2421 = Thunder Hammer

The 12000 - 12002 represents the action id of each lever

Code:
local items = {
    [12000] = {itemId = 2400, itemCount = 1, cost = 5000},
    [12001] = {itemId = 2431, itemCount = 1, cost = 100000},
    [12002] = {itemId = 2421, itemCount = 2, cost = 250000}
}

function onUse(player, item, fromPosition, itemEx, toPosition)
    local lever = items[item.actionid]
    local count = lever.itemCount
    local id = lever.itemId
    local cost = lever.cost

    if player:getMoney() >= cost then
        player:removeMoney(cost)
        player:addItem(id, count)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You purchased " .. count .. " " .. ItemType(id):getName() .. (count > 1 and 's' or '') .. " for " .. cost .. " gps.")
        Item(item.uid):transform(item.itemid == 1946 and 1945 or 1946)
        toPosition:sendMagicEffect(CONST_ME_MAGIC_RED)
    else
        player:sendCancelMessage("You need " .. cost .. " gps to pull this lever.")
        toPosition:sendMagicEffect(CONST_ME_POFF)
    end
    return true
end
thnaks alot :)
 
Back
Top