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

Solved Helmet of the Ancients

Demnish

Tibian Hero
Joined
Sep 28, 2011
Messages
401
Solutions
2
Reaction score
63
Location
Sweden
SOLVED:
Thanks to Xeraphus for his expertise.

This is the working hota.lua
Code:
local HOTA_FINISHED = 2343
local HOTA_UNFINISHED = 2342
local ANCIENT_GEM = 2363
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(getPlayerFlagValue(cid, PLAYERFLAG_CANNOTPICKUPITEM)) then
        return false
    end
    if (item.itemid == HOTA_UNFINISHED) and (getPlayerItemCount(cid, ANCIENT_GEM) >= 1) then
        doPlayerRemoveItem(cid, ANCIENT_GEM, 1)
        doTransformItem(item.uid, HOTA_FINISHED, 1)
        doSendMagicEffect(fromPosition, CONST_ME_MAGIC_RED)
        doPlayerSendTextMessage(cid, 19, "The ancient helmet is complete!")
    elseif (item.itemid == HOTA_FINISHED) then
        doTransformItem(item.uid, HOTA_UNFINISHED, 1)
        doPlayerAddItem(cid, ANCIENT_GEM, 1)
        doSendMagicEffect(fromPosition, CONST_ME_POFF)
    end
    return true
end


Distro: OTServ 0.6.4 STABLE
Client: 8.6

Problem:
I've edited my gold changer script to work with the helmet of the ancients, but nothing happens when I right-click the items.

Scripts:
hota.lua
Code:
local HOTA_FINISHED = 2343
local HOTA_UNFINISHED = 2342
local ANCIENT_GEM = 2363

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(getPlayerFlagValue(cid, PLAYERFLAG_CANNOTPICKUPITEM)) then
        return false
    end

    if(HOTA_UNFINISHED and ANCIENT_GEM == 1) then
        doRemoveItem(cid, HOTA_UNFINISHED, 1)
        doRemoveItem(cid, ANCIENT_GEM, 1)
        doPlayerAddItem(cid, HOTA_FINISHED, 1)
        doSendMagicEffect(frompos, CONST_ME_MAGIC_RED)
        doPlayerSendTextMessage(cid, 180, "The ancient helmet is complete!")

    elseif(HOTA_FINISHED == 1) then
        doRemoveItem(cid, HOTA_FINISHED, 1)
        doPlayerAddItem(cid, HOTA_UNFINISHED, 1)
        doPlayerAddItem(cid, ANCIENT_GEM, 1)
        doSendMagicEffect(frompos, CONST_ME_POFF)
    end
    return true
end

actions.xml
Code:
<action itemid="2343" script="custom/hota.lua"/>
<action itemid="2342" script="custom/hota.lua"/>
<action itemid="2363" script="custom/hota.lua"/>

EDIT:
Noticed, I've added "== 1" to the itemid (what a tard, lol)
Even so, I don't really know how to solve this puzzle since "count" didn't change anything.
 
Last edited:
Solution
you're just comparing your variable numbers with other numbers, you aren't getting the item from the player or comparing the item id with anything
LUA:
local HOTA_FINISHED = 2343
local HOTA_UNFINISHED = 2342
local ANCIENT_GEM = 2363

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(getPlayerFlagValue(cid, PLAYERFLAG_CANNOTPICKUPITEM)) then
        return false
    end

    if (item.itemid == HOTA_UNFINISHED) and (getPlayerItemCount(ANCIENT_GEM) >= 1) then
        doPlayerRemoveItem(cid, ANCIENT_GEM, 1)
        doTransformItem(item.uid, HOTA_FINISHED)
        doSendMagicEffect(fromPosition, CONST_ME_MAGIC_RED)
        doPlayerSendTextMessage(cid, 180, "The ancient helmet is complete!")
    elseif (item.itemid ==...
you're just comparing your variable numbers with other numbers, you aren't getting the item from the player or comparing the item id with anything
LUA:
local HOTA_FINISHED = 2343
local HOTA_UNFINISHED = 2342
local ANCIENT_GEM = 2363

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(getPlayerFlagValue(cid, PLAYERFLAG_CANNOTPICKUPITEM)) then
        return false
    end

    if (item.itemid == HOTA_UNFINISHED) and (getPlayerItemCount(ANCIENT_GEM) >= 1) then
        doPlayerRemoveItem(cid, ANCIENT_GEM, 1)
        doTransformItem(item.uid, HOTA_FINISHED)
        doSendMagicEffect(fromPosition, CONST_ME_MAGIC_RED)
        doPlayerSendTextMessage(cid, 180, "The ancient helmet is complete!")
    elseif (item.itemid == HOTA_FINISHED) then
        doTransformItem(item.uid, HOTA_UNFINISHED, 1)
        doPlayerAddItem(cid, ANCIENT_GEM, 1)
        doSendMagicEffect(frompos, CONST_ME_POFF)
    end
    return true
end
 
Last edited:
Solution
Haha yeah I noticed it, change it to "count" but didn't matter.

Anyway, I see now that I forgot all about the "item.itemid" o_O
I tried the script, I can disassemble the helmet, but not assemble it.

Doesn't show any errors in the console either.

TD;LR:
the second part of the script works, but not the first part
(HOTA FINISHED >> HOTA_UNFINISHED + ANCIENT GEM) works
but not (HOTA_UNFINISHED + ANCIENT GEM >> HOTA FINISHED)


Also, I don't know if this matters or not but ANCIENT_GEM is not stackable.
 
Now it assembles! :)

Though, "doRemoveItem(cid, ANCIENT_GEM, 1)" does not seem to work.
It duplicates the ANCIENT_GEM and I get the console error:
Lua Script Error: [Action Interface]
data/actions/scripts/custom/hota.lua:eek:nUse

LuaScriptInterface::luaDoRemoveItem(). Item not found
:p

EDIT:
I seem to have fixed it, instead of using "doRemoveItem(cid, ANCIENT_GEM, 1)",
I used "doPlayerRemoveItem(cid, ANCIENT_GEM, 1)".

Thanks alot for your help Xeraphus! :D
 
Last edited:
Back
Top