• 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 [8.6 OTServ 0.6.4] (SOLVED) Need help with simple quest.

Demnish

Tibian Hero
Joined
Sep 28, 2011
Messages
401
Solutions
2
Reaction score
63
Location
Sweden
This is the code that I wrote:
Code:
local ITEM = 2195
local COUNT = 1
local DROPONGROUND = false

local ITEMNAME = getItemName(ITEM)
local STORAGE = getItemIdByName(ITEMNAME)
local WEIGHT = getItemWeight(ITEM, COUNT)

function onUse(cid, item, frompos, item2, topos)
    if getPlayerFreeCap(cid) >= WEIGHT then
        if getPlayerStorageValue(cid, STORAGE) ~= 1 then
            doPlayerAddItem(cid, ITEM, COUNT, DROPONGROUND)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found "..ITEMNAME.."!")
            doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_GREEN)
            setPlayerStorageValue(cid, STORAGE, 1)
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is empty.")
            doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
        end
    else
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You do not have enough capacity.")
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
    end
end

This is the error message I got:
Lua Script Error: [Action Interface]
data/actions/scripts/custom/quests/bohquest.lua

LuaScriptInterface::luaGetItemWeight(). Item not found

I have no idea how to solve it since I don't understand the problem with it.
I'm trying to use "getItemWeight(uid)" with "getPlayerFreeCap(cid)" to make sure that people that doesn't have enough cap won't complete the quest, get a storage value and then never recieve the item.

If you need additional information just ask!


King regards, Z.
 
Thank you, it worked!
However, I couldn't find "getItemWeightById" in luascript.cpp? (Which is why I thought it didn't exist in my distro)

Do you know where I can find all available functions?
 
Back
Top