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

Lua Buying Backpacks of Potions by a lever [were working but now is bugged]

drax skylon

o.O DrAx O.o
Joined
Sep 9, 2008
Messages
225
Reaction score
3
Hello!

Well...I have add a system in my server for players buy backpacks of potions by pushing a lever.

It was working perfectly when I was using TFS Crying Damson (8.41)

Now I have updated my server for TFS Crying Damson PL2 (8.42) and it are bugging...

Here is one script (Great Health Potion)
function onUse(cid, item, fromPosition, itemEx, toPosition)
local container = 0
local cost = 3825
local potion_id = 7591
local backpack_id = 2000
if item.uid == 6502 and item.itemid == 1945 then
if doPlayerRemoveMoney(cid, cost) == 1 then
doTransformItem(item.uid, item.itemid+1)
container = doPlayerAddItem(cid, backpack_id, 1)
for i = 1, 20 do
doAddContainerItem(container, potion_id)
end
else
doPlayerSendCancel(cid,"Sorry, you don't have enough money.")
end
elseif item.uid == 6502 and item.itemid == 1946 then
doTransformItem(item.uid, item.itemid-1)
end
return TRUE
end

Now when a player use the lever (ID:1945 UID:6502) he/she lost the money but do not receive his/her backpack and the lever do not change to ID:1946

Please help me!
Thanks a lot.
 
Hello!

Well...I have add a system in my server for players buy backpacks of potions by pushing a lever.

It was working perfectly when I was using TFS Crying Damson (8.41)

Now I have updated my server for TFS Crying Damson PL2 (8.42) and it are bugging...

Here is one script (Great Health Potion)


Now when a player use the lever (ID:1945 UID:6502) he/she lost the money but do not receive his/her backpack and the lever do not change to ID:1946

Please help me!
Thanks a lot.


PHP:
  --Advanced container lever ( By Pitufo)
local items = {
    [9000] = {itemId=2308, contMax=20, bp=2000, cost=4000, charges=2},
}
function onUse(cid, item, frompos, item2, topos)
    if items[item.uid] then
        if item.itemid == 1512 then
            local v = items[item.uid]
                if getPlayerFreeCap(cid) >= getItemWeightById(v.itemId, 20) then
                    if doPlayerRemoveMoney(cid, v.cost) == TRUE then
                    container = doPlayerAddItem(cid, v.bp, 1)
                        for i = 1, v.contMax do
                        if not(isItemRune(v.itemId)) then
                            doAddContainerItem(container, v.itemId, 1)
                            else
                            doAddContainerItem(container, v.itemId, v.charges)
                            end
                        end    
                            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have but a container with "..getItemNameById(v.itemId)..".")
                    else
                        doPlayerSendCancel(cid, "Sorry, not enough money [Cost: "..v.cost.."].")
                    end    
                else
                    doPlayerSendCancel(cid, "Not enough cap [Cap needed: "..getItemWeightById(v.itemId, 20).."].")
                end    
                doTransformItem(item.uid, item.itemid-1)
            elseif item.itemid == 1945 then
                doTransformItem(item.uid, item.itemid+1)
        end
    end    
return 1
end

This script is working.
 
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local container = 0
    local cost = 3825
    local potion_id = 7591
    local backpack_id = 2000
    if item.uid == 6502 and item.itemid == 1945 then
        if doPlayerRemoveMoney(cid, cost) == TRUE then
            doTransformItem(item.uid, item.itemid+1)
            container = doPlayerAddItem(cid, backpack_id, 1)
            for i = 1, 20 do
                doAddContainerItem(container, potion_id)
            end
        else
            doPlayerSendCancel(cid,"Sorry, you don't have enough money.")
        end
    elseif item.uid == 6502 and item.itemid == 1946 then
        doTransformItem(item.uid, item.itemid-1)
    end
return TRUE
end

Try this instead :)
 
Back
Top