• 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 Help with NPC script who checks/changes storage ids or cids

Sallsback

New Member
Joined
Apr 19, 2012
Messages
11
Reaction score
0
Hey, I wanted to know how I would be able to edit a npc script to make quest chains possible. I am currently using this script (source: http://otland.net/f132/npc-who-checks-amount-storages-159464/index2.html) and it looks like this:

LUA Code:
LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
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
function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
    lvl,stor,n = 30,9745474,0
    if(msgcontains(msg, 'quest') or msgcontains(msg, 'mission')) then
        selfSay('Oh, did you do your missions?', cid)
        talkState[talkUser] = 1
    elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
        if(getPlayerLevel(cid) >= lvl) then
        if getPlayerStorageValue(cid, stor) == -1 then setPlayerStorageValue(cid, stor, 0) end
        for i= 7000,7200 do
        if getPlayerStorageValue(cid, i) >= 1 then 
        n = n+1
        end
        end
        if n >= (getPlayerStorageValue(cid, stor)+5) then
            npcHandler:say("Nice.", cid)
            doPlayerAddExp(cid, 5000)
            setPlayerStorageValue(cid, stor, getPlayerStorageValue(cid, stor)+5)
            talkState[talkUser] = 0
        else
        selfSay('you must finish at least 5 quest.', cid)
        end
        else
        selfSay('You have to be level '..lvl, cid)
        end
    elseif (msgcontains(msg, 'no') and talkState[talkUser] >= 1) then
        talkState[talkUser] = 0
        selfSay('Then not!', cid)
    end
    return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

I would really love it if I could get some help. Thanks
 
Last edited by a moderator:
hm you're the Polish right?

lmao, no I'm from the United States.

But I need help figuring out how to update storage ids for npc quest chains

Example:

This is the server's quest.xml file and this is what would show up in the tibia quest log (depending on id)
PHP:
 <?xml version="1.0" encoding="UTF-8"?>
<quests>
    <quest name="Tutorial Island" startstorageid="9745474" startstoragevalue="0">
        <mission name="Meeting the Villagers" storageid="9745474" startvalue="1" endvalue="4">
[B]            <missionstate id="1" description="Talk to Riona at her shop."/>
            <missionstate id="2" description="Talk to the banker."/>
            <missionstate id="3" description="Talk to the mayor"/>[/B]
        </mission>
    </quest>
</quests>

I am wondering what sections of xml code need to be edited to advance in missions (from mission state 1 to mission state 2).

I hope this helps
 
::::
Code:
<mission name="miss 1" storageid="1111" startvalue="1" endvalue="4">
           <missionstate id="1" description="Talk to Riona at her shop."/>
            <missionstate id="2" description="Talk to the banker."/>
            <missionstate id="3" description="Talk to the mayor"/>
        </mission>
<mission name="miss 2" storageid="9745474" startvalue="5" endvalue="9">
           <missionstate id="0" description="Trolololo."/>
            <missionstate id="1" description="bakakak."/>
            <missionstate id="2" description="Twaka waka eheher"/>
        </mission>
 
Thanks, but I understand that part, the issue is when I start a quest (at mission state 1), I cannot figure out how to make it possible to reach mission state 2 and so on.
 
Back
Top