• 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 Quest log help

Jester753

New Member
Joined
Jun 15, 2012
Messages
30
Reaction score
0
Hey I've been trying to get my quest log to work but so far no luck, i was hoping that someone could take a look at my code and see if i missed something:

Here is my quests.xml document
PHP:
<?xml version="1.0" encoding="UTF-8"?>
<quests>
	<quest name="Rebellion beer run" startstorageid="25000" startstoragevalue="1">
        <mission name="Dabeers Ale" storageid="25001" startvalue="0" endvalue="3">
			<missionstate id="0" description="Speak to Dabeers."/>
            <missionstate id="1" description="Dabeers asked you to kill Amorfo, and retrieve his beer."/>
            <missionstate id="2" description="You obtained the beer, you should collect your reward from Dabeers."/>
            <missionstate id="3" description="Dabeers rewarded you for your noble act."/>
        </mission>
    </quest>
	
</quests>

Here is the npc script

PHP:
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)
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	
	local storage = 25001
	if(msgcontains(msg, 'quest') or msgcontains(msg, 'beer')) then
		if(getPlayerStorageValue(cid, storage) < 1) then
			npcHandler:say("The damn cyclops stole my beer. Kill Amorfo, their behemoth general, and bring it to me.", cid)
			setPlayerStorageValue(cid, storage, 1)
		elseif(getPlayerStorageValue(cid, storage) == 1) then
			npcHandler:say("Do you have my beer?", cid)
			talkState[talkUser] = 1
		elseif(getPlayerStorageValue(cid, storage) == 2) then
			npcHandler:say("I love this beer.", cid)
		end
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
		if(doPlayerRemoveItem(cid, 7706, 1) == TRUE) then
			npcHandler:say("Thanks! Take this dwarven armor!", cid)
			doPlayerAddItem(cid, 2503, 1)
			doPlayerAddItem(cid, 2504, 1)
			setPlayerStorageValue(cid, storage, 2)
			talkState[talkUser] = 0
		else
			npcHandler:say("You do not have my beer", cid)
			talkState[talkUser] = 0
		end
	elseif(msgcontains(msg, 'no') and talkState[talkUser] > 0) then
		npcHandler:say("damn", cid)
		talkState[talkUser] = 0
	end
	return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())


Setting the player storage value is working, because you can complete the whole quest and the npcs talk stages work, it just won't show up in the quest log.

thanks,
Jester
 
to open that mission, as you post, player should have storage 25000, so I just put to set this storage to player when he ask for mission. (line: 17)
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) 
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid 
     
    local storage = 25001 
    if(msgcontains(msg, 'quest') or msgcontains(msg, 'beer')) then 
        if(getPlayerStorageValue(cid, storage) < 1) then 
            npcHandler:say("The damn cyclops stole my beer. Kill Amorfo, their behemoth general, and bring it to me.", cid) 
            setPlayerStorageValue(cid, storage, 1) 
			setPlayerStorageValue(cid, 25000, 1) 
        elseif(getPlayerStorageValue(cid, storage) == 1) then 
            npcHandler:say("Do you have my beer?", cid) 
            talkState[talkUser] = 1 
        elseif(getPlayerStorageValue(cid, storage) == 2) then 
            npcHandler:say("I love this beer.", cid) 
        end 
    elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then 
        if(doPlayerRemoveItem(cid, 7706, 1) == TRUE) then 
            npcHandler:say("Thanks! Take this dwarven armor!", cid) 
            doPlayerAddItem(cid, 2503, 1) 
            doPlayerAddItem(cid, 2504, 1) 
            setPlayerStorageValue(cid, storage, 2) 
            talkState[talkUser] = 0 
        else 
            npcHandler:say("You do not have my beer", cid) 
            talkState[talkUser] = 0 
        end 
    elseif(msgcontains(msg, 'no') and talkState[talkUser] > 0) then 
        npcHandler:say("damn", cid) 
        talkState[talkUser] = 0 
    end 
    return TRUE 
end 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())
 
Back
Top