• 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 Problem with Storage ID and Quest Log

8674011

New Member
Joined
Jun 21, 2010
Messages
160
Reaction score
3
Location
The House
I'm trying to make a quest in my server and I seemed to have put the code in correctly,
but i get this error (Which occurs after talking with him, when i say yes to the quest)
Code:
[26/01/2014 01:58:37] data/npc/scripts/doug.lua:21: attempt to call global 'doPlayerSetStorageValue' (a nil value)
[26/01/2014 01:58:37] stack traceback:
[26/01/2014 01:58:37]    [C]: in function 'doPlayerSetStorageValue'
[26/01/2014 01:58:37]    data/npc/scripts/doug.lua:21: in function 'callback'
[26/01/2014 01:58:37]    data/npc/lib/npcsystem/keywordhandler.lua:27: in function 'processMessage'
[26/01/2014 01:58:37]    data/npc/lib/npcsystem/keywordhandler.lua:135: in function 'processNodeMessage'
[26/01/2014 01:58:37]    data/npc/lib/npcsystem/keywordhandler.lua:103: in function 'processMessage'
[26/01/2014 01:58:37]    data/npc/lib/npcsystem/npchandler.lua:387: in function 'onCreatureSay'
[26/01/2014 01:58:37]    data/npc/scripts/doug.lua:7: in function <data/npc/scripts/doug.lua:7>
I'm using TFS 0.2.15
Here is my code in XML\Quests.lua


Code:
<quest name="Doug" startstorageid="80012" startstoragevalue="1">
        <mission name="Doug's Glasses" storageid="424242" startvalue="1" endvalue="3">
            <missionstate id="1" description="Doug asked you to find his glasses. He last saw them in Mount Minotaur."/>
            <missionstate id="2" description="Return the found glasses to Doug."/>
            <missionstate id="3" description="Doug praised you for your favour."/>
        </mission>
    </quest>

here is my NPC code in \data\npc\scripts


Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid)            npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)        npcHandler:onCreatureDisappear(cid)            end
function onCreatureSay(cid, type, msg)        npcHandler:onCreatureSay(cid, type, msg)        end
function onThink()                npcHandler:onThink()                    end

-- QUEST --
function Task1(cid, message, keywords, parameters, node)

local stor1 = 424242 -- this is the same STOR1 from quests.xml

    if(not npcHandler:isFocused(cid)) then
        return false
    end

    if getPlayerStorageValue(cid,stor1) < 0 then
                npcHandler:say('Hurry please find my glasses! I can not see a thing!',cid)
            doPlayerSetStorageValue(cid, stor1, 1)
    elseif getPlayerStorageValue(cid, stor1) == 1 then
                npcHandler:say('I am still waiting for you to find my glasses!',cid)
    elseif getPlayerStorageValue(cid, stor1) == 2 then
                npcHandler:say('Thank you so much for finding my glasses!',cid)
            doPlayerAddItem(cid, 2152, 25)
            doPlayerSetStorageValue(cid, stor1, 3)
                doSendMagicEffect(getCreaturePosition(cid), 13)
    elseif getPlayerStorageValue(cid, stor1) == 3 then
                npcHandler:say('You already unlocked the room, thank you!',cid)
    end
end

local node1 = keywordHandler:addKeyword({'help'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Can you help me find my glasses?!'})
      node1:addChildKeyword({'yes'}, Task1, {})
    node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Oh, sorry to bother you.', reset = true})

npcHandler:addModule(FocusModule:new())


anyone see the problem? Is there anything i'm forgetting?
 
Last edited:
Here you go
doPlayerSetStorageValue changed to
setPlayerStorageValue
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid)            npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)        npcHandler:onCreatureDisappear(cid)            end
function onCreatureSay(cid, type, msg)        npcHandler:onCreatureSay(cid, type, msg)        end
function onThink()                npcHandler:onThink()                    end

-- QUEST --
function Task1(cid, message, keywords, parameters, node)
    local stor1 = 424242 -- this is the same STOR1 from quests.xml

    if(not npcHandler:isFocused(cid)) then
        return false
    end

    if getPlayerStorageValue(cid,stor1) < 0 then
        npcHandler:say('Hurry please find my glasses! I can not see a thing!',cid)
        setPlayerStorageValue(cid, stor1, 1)
    elseif getPlayerStorageValue(cid, stor1) == 1 then
        npcHandler:say('I am still waiting for you to find my glasses!',cid)
    elseif getPlayerStorageValue(cid, stor1) == 2 then
        npcHandler:say('Thank you so much for finding my glasses!',cid)
        doPlayerAddItem(cid, 2152, 25)
        setPlayerStorageValue(cid, stor1, 3)
        doSendMagicEffect(getCreaturePosition(cid), 13)
    elseif getPlayerStorageValue(cid, stor1) == 3 then
        npcHandler:say('You already unlocked the room, thank you!',cid)
    end
end

local node1 = keywordHandler:addKeyword({'help'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Can you help me find my glasses?!'})
node1:addChildKeyword({'yes'}, Task1, {})
node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Oh, sorry to bother you.', reset = true})

npcHandler:addModule(FocusModule:new())
 
Here you go
doPlayerSetStorageValue changed to
setPlayerStorageValue
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid)            npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)        npcHandler:onCreatureDisappear(cid)            end
function onCreatureSay(cid, type, msg)        npcHandler:onCreatureSay(cid, type, msg)        end
function onThink()                npcHandler:onThink()                    end

-- QUEST --
function Task1(cid, message, keywords, parameters, node)
    local stor1 = 424242 -- this is the same STOR1 from quests.xml

    if(not npcHandler:isFocused(cid)) then
        return false
    end

    if getPlayerStorageValue(cid,stor1) < 0 then
        npcHandler:say('Hurry please find my glasses! I can not see a thing!',cid)
        setPlayerStorageValue(cid, stor1, 1)
    elseif getPlayerStorageValue(cid, stor1) == 1 then
        npcHandler:say('I am still waiting for you to find my glasses!',cid)
    elseif getPlayerStorageValue(cid, stor1) == 2 then
        npcHandler:say('Thank you so much for finding my glasses!',cid)
        doPlayerAddItem(cid, 2152, 25)
        setPlayerStorageValue(cid, stor1, 3)
        doSendMagicEffect(getCreaturePosition(cid), 13)
    elseif getPlayerStorageValue(cid, stor1) == 3 then
        npcHandler:say('You already unlocked the room, thank you!',cid)
    end
end

local node1 = keywordHandler:addKeyword({'help'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Can you help me find my glasses?!'})
node1:addChildKeyword({'yes'}, Task1, {})
node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Oh, sorry to bother you.', reset = true})

npcHandler:addModule(FocusModule:new())


This worked, but now the quest is not displaying in the quest log.
 
I believe missionstate id="1" should actually start at 0 so...

Code:
<missionstate id="0" description="Doug asked you to find his glasses. He last saw them in Mount Minotaur."/>
            <missionstate id="1" description="Return the found glasses to Doug."/>
            <missionstate id="2" description="Doug praised you for your favour."/>
 
I believe missionstate id="1" should actually start at 0 so...

Code:
<missionstate id="0" description="Doug asked you to find his glasses. He last saw them in Mount Minotaur."/>
            <missionstate id="1" description="Return the found glasses to Doug."/>
            <missionstate id="2" description="Doug praised you for your favour."/>
Yes put something like this in quests.xml
 
Yes put something like this in quests.xml
I believe missionstate id="1" should actually start at 0 so...

Code:
<missionstate id="0" description="Doug asked you to find his glasses. He last saw them in Mount Minotaur."/>
            <missionstate id="1" description="Return the found glasses to Doug."/>
            <missionstate id="2" description="Doug praised you for your favour."/>

it shouldn't make a difference, as long as you set the values, but it's still not popping up
 
Here
Code:
<quest name="The glasses" startstorageid="424242" startstoragevalue="1">
    <mission name="Dougs glasses" storageid="424242" startvalue="1" endvalue="3">
        <missionstate id="0" description="Doug asked you to find his glasses. He last saw them in Mount Minotaur."/>
        <missionstate id="1" description="Return the found glasses to Doug."/>
        <missionstate id="2" description="Doug praised you for your favour."/>
    </mission>
</quest>
 
Back
Top