• 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 LUA LEVER POTION SCRIPT 8.6 0.4TFS

Scal

RuneScape OT
Joined
Aug 3, 2014
Messages
33
Reaction score
13
Hello all,

Can someone help me, can someone change this script so it gives me 20x1 health potions rather than just 20, changed it around quite alot, but all they do is stack rather than seperate,

Code:
        hp_id = 7618 -- Item a ser vendido
        backpackhp_id = 2000 -- Backpack
        custohp_id =5000 -- Valor
        cargashp_id = 1 -- Cargas   (Doesn't work with '20' either)

local name = getItemNameById(hp_id)
----- End Config -----
function onUse(cid, item, fromPosition, itemEx, toPosition)
        if doPlayerRemoveMoney(cid, custohp_id) == TRUE then
                local bag = doPlayerAddItem(cid, backpackhp_id, 1)
                        doSendAnimatedText(fromPosition, "", TEXTCOLOR_YELLOW)
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have purchased a backpack of ".. name .."s for ".. custohp_id .." gold.")
                        for i=1,20 do
                        doAddContainerItem(bag, hp_id, cargashp_id)
                end
                else
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You need ".. custohp_id .." gold coins for a backpack of ".. name .."s.")
                end
        return FALSE
end

If someone can help it'll be very much appreciated. Cheers
 
Last edited by a moderator:
This:
Code:
for i=1,20 do
is what is adding it 20 times. This is a loop which will execute doAddContainerItem every one time it jumps a number between 1 and 20 (which is 20 times). I am on my phone but remove the loop and change the doAddContainerItem line to:
Code:
doAddContainerItem(bag, hp_id, cargashp_id)
and change cargashp_id to 20, also you should change your globals to locals. I.e cargashp_id = 20 to local cargashp_id = 20
 
Code:
local cfg = {
    [9080] = {backpack = 2000, pot_id = 7618, cost = 5000, count = 20, name = getItemNameById(7618)}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local tmp = cfg[item.actionid]
    local cost = tmp and tmp.cost
    if tmp and doPlayerRemoveMoney(cid, cost) then
        local bag = doPlayerAddItem(cid, tmp.backpack)
        doSendAnimatedText(fromPosition, "", TEXTCOLOR_YELLOW)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have purchased a backpack of ".. tmp.name .."s for ".. cost .." gold.")
        while getContainerSize(bag) < getContainerCap(bag) do
            doTransformItem(doContainerAddItem(bag, 1685), tmp.pot_id, 1)
        end
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You need ".. cost .." gold coins for a backpack of ".. tmp.name .."s.")
    end
    return true
end
i used a loop to add a heart pillow to the bag every container slot and then transform it so the potions dont stack
9080 is item actionid
just add more to the table each actionid if you want for multiple levers using the same script
 
Hi Xeraphus,

Thank you for your response. Highly appreciated, however once I click on the switch, I receive a backpack with no potions....

Do you have any idea?

thanks :)
 
Code:
local cfg = {
   [9080] = {backpack = 2000, pot_id = 7618, cost = 5000, count = 20}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local tmp = cfg[item.actionid]
    local cost = tmp and tmp.cost
    if tmp and doPlayerRemoveMoney(cid, cost) then
        local bag = doPlayerAddItem(cid, tmp.backpack)
        local name = getItemNameById(tmp.pot_id)
        doSendAnimatedText(fromPosition, "", TEXTCOLOR_YELLOW)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have purchased a backpack of ".. name .."s for ".. cost .." gold.")
        while getContainerSize(bag.uid) < getContainerCap(bag.uid) do
            doTransformItem(doContainerAddItem(bag.uid, 1685), tmp.pot_id, 1)
        end
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You need ".. cost .." gold coins for a backpack of "..name .."s.")
    end
    return true
end
forgot bag uids
 
Code:
local cfg = {
   [9080] = {backpack = 2000, pot_id = 7618, cost = 5000, count = 20}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local tmp = cfg[item.actionid]
    local cost = tmp and tmp.cost
    if tmp and doPlayerRemoveMoney(cid, cost) then
        local bag = doPlayerAddItem(cid, tmp.backpack)
        local name = getItemNameById(tmp.pot_id)
        doSendAnimatedText(fromPosition, "", TEXTCOLOR_YELLOW)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have purchased a backpack of ".. name .."s for ".. cost .." gold.")
        while getContainerSize(bag.uid) < getContainerCap(bag.uid) do
            doTransformItem(doAddContainerItem(bag.uid, 1685), tmp.pot_id, tmp.count)
        end
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You need ".. cost .." gold coins for a backpack of "..name .."s.")
    end
    return true
end
put doContainerAddItem instead of doAddContainerItem
next time check for errors in console lol
 
Back
Top