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

Lever error

Middan

New Member
Joined
Dec 24, 2013
Messages
22
Reaction score
0
got this script
Code:
local config = {
    [5001] = {potion = 7618, cost = 5000, charges = 100, storage = 5001}, -- health potion
    [5002] = {potion = 7588, cost = 10000, charges = 100}, -- strong health potion
    [5003] = {potion = 7591, cost = 19000, charges = 100}, -- great health potion
    [5004] = {potion = 8473, cost = 31000, charges = 100},
    [5005] = {potion = 7620, cost = 5000, charges = 100}, -- mana potion
    [5006] = {potion = 7589, cost = 8000, charges = 100}, -- string mana potion
    [5007] = {potion = 7590, cost = 12000, charges = 100}, -- great mana potion
    [5008] = {potion = 8472, cost = 19000, charges = 100},
    [5009] = {potion = 2273, cost = 17500, charges = 100},
    [5010] = {potion = 2268, cost = 35000, charges = 100},
    [5011] = {potion = 2278, cost = 700000, charges = 100},
    [5012] = {potion = 2313, cost = 25000, charges = 100},
    [5013] = {potion = 2798, cost = 50000, charges = 100},
    [5014] = {potion = 2789, cost = 1000, charges = 100},
    [5015] = {potion = 2269, cost = 16000, charges = 100},
    [5016] = {potion = 2305, cost = 11700, charges = 100},
    [5018] = {potion = 2261, cost = 4500, charges = 100},
    [5019] = {potion = 2260, cost = 1000, charges = 100},
} -- config end --
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local potion = config[item.uid]
    if isInArray({1945, 1946}, item.itemid) ~= TRUE then
        return TRUE
    end
    if doPlayerBuyItemContainer(cid, potion, potion.potion, 1, potion.cost, 1) == TRUE then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You bought a backpack "..getItemNameById(potion.potion).." for "..potion.cost.." gold coins.")
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need "..potion.cost.." gold coins for a backpack "..getItemNameById(potion.potion)..".")
    end
    return TRUE
end

and gets this error
Code:
[30/12/2013 22:49:08] [Error - Action Interface]
[30/12/2013 22:49:08] data/actions/scripts/potions.lua:onUse
[30/12/2013 22:49:09] Description:
[30/12/2013 22:49:09] (luaDoCreateItemEx) Item not found

[30/12/2013 22:49:09] [Error - Action Interface]
[30/12/2013 22:49:09] data/actions/scripts/potions.lua:onUse
[30/12/2013 22:49:09] Description:
[30/12/2013 22:49:09] data/lib/050-function.lua:23: 'for' limit must be a number
[30/12/2013 22:49:09] stack traceback:
[30/12/2013 22:49:09]    data/lib/050-function.lua:23: in function 'doPlayerGiveItemContainer'
[30/12/2013 22:49:09]    data/lib/050-function.lua:62: in function 'doPlayerBuyItemContainer'
[30/12/2013 22:49:09]    data/actions/scripts/potions.lua:27: in function <data/actions/scripts/potions.lua:22>

what are im doing wrong? :(
 
Can you post your 050-funtion.lua in libs (lines 23, 62 (all about the functions doPlayerGiveItemContainer and doPlayerBuyItemContainer)?
 
there u go.. culdnt find anything wrong ther ;P

Code:
function doPlayerGiveItemContainer(cid, containerid, itemid, amount, subType)
    for i = 1, amount do
        local container = doCreateItemEx(containerid, 1)
        for x = 1, getContainerCapById(containerid) do
            doAddContainerItem(container, itemid, subType)
        end

        if(doPlayerAddItemEx(cid, container, true) ~= RETURNVALUE_NOERROR) then
            return false
        end
    end

    return true
end

function getPlayerVipDays(cid)
local Info = db.getResult("SELECT `vipdays` FROM `accounts` WHERE `id` = " .. getPlayerAccountId(cid) .. " LIMIT 1")
if Info:getID() ~= LUA_ERROR then
local days= Info:getDataInt("vipdays")
Info:free()
return days
end
return LUA_ERROR
end

function doAddVipDays(cid, days)
db.executeQuery("UPDATE `accounts` SET `vipdays` = `vipdays` + " .. days .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end

function doRemoveVipDays(cid, days)
db.executeQuery("UPDATE `accounts` SET `vipdays` = `vipdays` - " .. days .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
end

function doPlayerTakeItem(cid, itemid, amount)
    return getPlayerItemCount(cid, itemid) >= amount and doPlayerRemoveItem(cid, itemid, amount)
end

function doPlayerBuyItem(cid, itemid, count, cost, charges)
    return doPlayerRemoveMoney(cid, cost) and doPlayerGiveItem(cid, itemid, count, charges)
end

function doPlayerBuyItemContainer(cid, containerid, itemid, count, cost, charges)
    return doPlayerRemoveMoney(cid, cost) and doPlayerGiveItemContainer(cid, containerid, itemid, count, charges)
end
 
Code:
local config = {
     [5001] = {bp = 2000, potion = 7618, cost = 5000, charges = 100, storage = 5001}, -- health potion
     [5002] = {bp = 2000, potion = 7588, cost = 10000, charges = 100}, -- strong health potion
     [5003] = {bp = 2000, potion = 7591, cost = 19000, charges = 100}, -- great health potion
     [5004] = {bp = 2000, potion = 8473, cost = 31000, charges = 100},
     [5005] = {bp = 2001, potion = 7620, cost = 5000, charges = 100}, -- mana potion
     [5006] = {bp = 2001, potion = 7589, cost = 8000, charges = 100}, -- strong mana potion
     [5007] = {bp = 2001, potion = 7590, cost = 12000, charges = 100}, -- great mana potion
     [5008] = {bp = 2000, potion = 8472, cost = 19000, charges = 100},
     [5009] = {bp = 2000, potion = 2273, cost = 17500, charges = 100},
     [5010] = {bp = 2000, potion = 2268, cost = 35000, charges = 100},
     [5011] = {bp = 2000, potion = 2278, cost = 700000, charges = 100},
     [5012] = {bp = 2000, potion = 2313, cost = 25000, charges = 100},
     [5013] = {bp = 2000, potion = 2798, cost = 50000, charges = 100},
     [5014] = {bp = 2000, potion = 2789, cost = 1000, charges = 100},
     [5015] = {bp = 2000, potion = 2269, cost = 16000, charges = 100},
     [5016] = {bp = 2000, potion = 2305, cost = 11700, charges = 100},
     [5018] = {bp = 2000, potion = 2261, cost = 4500, charges = 100},
     [5019] = {bp = 2000, potion = 2260, cost = 1000, charges = 100},
} -- config end --

function onUse(cid, item, fromPosition, itemEx, toPosition)

     local potion = config[item.uid]
     if isInArray({1945, 1946}, item.itemid) ~= TRUE then
         return true
     end
     if doPlayerBuyItemContainer(cid, potion.bp, potion.potion, 1, potion.cost, 1) == TRUE then
         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You bought a backpack "..getItemNameById(potion.potion).." for "..potion.cost.." gold coins.")
         doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
     else
         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need "..potion.cost.." gold coins for a backpack "..getItemNameById(potion.potion)..".")
     end
     return true
end
 
Code:
local config = {
     [5001] = {bp = 2000, potion = 7618, cost = 5000, charges = 100}, -- health potion
     [5002] = {bp = 2000, potion = 7588, cost = 10000, charges = 100}, -- strong health potion
     [5003] = {bp = 2000, potion = 7591, cost = 19000, charges = 100}, -- great health potion
     [5004] = {bp = 2000, potion = 8473, cost = 31000, charges = 100},
     [5005] = {bp = 2001, potion = 7620, cost = 5000, charges = 100}, -- mana potion
     [5006] = {bp = 2001, potion = 7589, cost = 8000, charges = 100}, -- strong mana potion
     [5007] = {bp = 2001, potion = 7590, cost = 12000, charges = 100}, -- great mana potion
     [5008] = {bp = 2000, potion = 8472, cost = 19000, charges = 100},
     [5009] = {bp = 2000, potion = 2273, cost = 17500, charges = 100},
     [5010] = {bp = 2000, potion = 2268, cost = 35000, charges = 100},
     [5011] = {bp = 2000, potion = 2278, cost = 700000, charges = 100},
     [5012] = {bp = 2000, potion = 2313, cost = 25000, charges = 100},
     [5013] = {bp = 2000, potion = 2798, cost = 50000, charges = 100},
     [5014] = {bp = 2000, potion = 2789, cost = 1000, charges = 100},
     [5015] = {bp = 2000, potion = 2269, cost = 16000, charges = 100},
     [5016] = {bp = 2000, potion = 2305, cost = 11700, charges = 100},
     [5018] = {bp = 2000, potion = 2261, cost = 4500, charges = 100},
     [5019] = {bp = 2000, potion = 2260, cost = 1000, charges = 100},
} -- config end --

function onUse(cid, item, fromPosition, itemEx, toPosition)

     local potion = config[item.uid]
     if isInArray({1945, 1946}, item.itemid) ~= TRUE then
         return true
     end
     if doPlayerBuyItemContainer(cid, potion.bp, potion.potion, 1, potion.cost, potion.charges) == TRUE then
         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You bought a backpack "..getItemNameById(potion.potion).." for "..potion.cost.." gold coins.")
         doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
     else
         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need "..potion.cost.." gold coins for a backpack "..getItemNameById(potion.potion)..".")
         doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
     end
     return true
end
 
Code:
local config = {
     [5001] = {potion = 7618, cost = 5000, charges = 100}, -- health potion
     [5002] = {potion = 7588, cost = 10000, charges = 100}, -- strong health potion
     [5003] = {potion = 7591, cost = 19000, charges = 100}, -- great health potion
     [5004] = {potion = 8473, cost = 31000, charges = 100},
     [5005] = {potion = 7620, cost = 5000, charges = 100}, -- mana potion
     [5006] = {potion = 7589, cost = 8000, charges = 100}, -- strong mana potion
     [5007] = {potion = 7590, cost = 12000, charges = 100}, -- great mana potion
     [5008] = {potion = 8472, cost = 19000, charges = 100},
     [5009] = {potion = 2273, cost = 17500, charges = 100},
     [5010] = {potion = 2268, cost = 35000, charges = 100},
     [5011] = {potion = 2278, cost = 700000, charges = 100},
     [5012] = {potion = 2313, cost = 25000, charges = 100},
     [5013] = {potion = 2798, cost = 50000, charges = 100},
     [5014] = {potion = 2789, cost = 1000, charges = 100},
     [5015] = {potion = 2269, cost = 16000, charges = 100},
     [5016] = {potion = 2305, cost = 11700, charges = 100},
     [5018] = {potion = 2261, cost = 4500, charges = 100},
     [5019] = {potion = 2260, cost = 1000, charges = 100},
} -- config end --

function onUse(cid, item, fromPosition, itemEx, toPosition)

     local potion = config[item.uid]
     if isInArray({1945, 1946}, item.itemid) ~= TRUE then
         return true
     end
     if doPlayerRemoveMoney(cid, potion.cost) then
         doPlayerAddItem(cid, potion.potion, potion.charges)
         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You bought "..potion.charges.." "..getItemNameById(potion.potion).."s for "..potion.cost.." gold coins.")
         doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
     else
         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need "..potion.cost.." gold coins for "..potion.charges.." "..getItemNameById(potion.potion).."s.")
         doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
     end
     return true
end
 
Back
Top