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

Quest with quest log

jesseripper

New Member
Joined
Mar 12, 2008
Messages
20
Reaction score
1
Hi there, I'm in need of some support, I can't figure this out myself since I still suck at .lua.

Ok, so basically, I have created a quest, using a tutorial. At the moment, it's one quest, with one mission. I will add more missions later on. However, I can't get it working. I have followed the tutorial and made some changes myself, can you please check the it out?

So this is quests.xml :

Code:
<?xml version="1.0" encoding="UTF-8"?>
<quests>
	
	<quest name="In service of Fairport" startstorageid="80012" startstoragevalue="1">
        <mission name="Prove your loyalty" storageid="25578" startvalue="0" endvalue="2">
            <missionstate id="0" description="The King has asked you for assistance. He's willing to hire you as his lackey, but first you have to prove your loyalty. To do this, you have to kill 500 orcs."/>
            <missionstate id="1" description="You have successfully killed 500 orcs. You should report back to the King."/>
            <missionstate id="2" description="You have proven yourself loyal to the kingdom of Fairport, the King will now accept you as his personal lackey. You should probably ask him for more missions."/>
        </mission>
    </quest>
</quests>

This is the NPC

Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="The King" script="theking.lua" walkinterval="0" floorchange="0">
    <health now="100000" max="100000"/>
    <look type="266" head="40" body="45" legs="99" feet="79"/>
    <parameters>
        <parameter key="message_greet" value="Greetings |NAME|."/>
    </parameters>
</npc>

and here's the lua script

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 = 25578 -- 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('You have not killed enough orcs |NAME|. Slay 500 of these loathsome creatures, then report back to me.',cid)
            doPlayerSetStorageValue(cid, stor1, 0)
    elseif getPlayerStorageValue(cid, stor1) == 0 then
                npcHandler:say('To prove your loyalty, you have to slay 500 orcs. This must be done!',cid)
    elseif getPlayerStorageValue(cid, stor1) == 1 then
                npcHandler:say('Congratulations |NAME|. You are hired. Feel free to ask me for another mission. We have to destroy the orc race!',cid)
			doPlayerAddExperience(cid,100000)
            doPlayerSetStorageValue(cid, stor1, 2)
                 doSendMagicEffect(getCreaturePosition(cid), 13)
    elseif getPlayerStorageValue(cid, stor1) == 2 then
                npcHandler:say('Thank you.',cid)
    end
end

local node1 = keywordHandler:addKeyword({'mission'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Hmm, are you asking me for a mission? Before you and I discuss missions, I need to know where your loyalty stands. Slay 500 orcs, then report back to me, understood?'})
      node1:addChildKeyword({'yes'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Perfect. By the way, feel free to use the orc tunnel. It is located downstairs in the room to the right.'}, Task1, {})
    node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'What a shame...', reset = true})

npcHandler:addModule(FocusModule:new())

I then added

<event type="kill" name="monsterkill" event="script" value="orcs.lua"/>

to data/creaturescripts/creaturescripts.xml

then

registerCreatureEvent(cid, "monsterkill")

to login.lua in creaturescripts/scripts catalogue

and finally, I made a .lua called orcs.lua

here's the code

Code:
local monsters = {
	--name = storage
	["orc"] = 55004,
	["orc warrior"] = 55004,
	["orc spearman"] = 55004,
	["orc warlord"] = 55004,
	["orc leader"] = 55004,
	["orc berserker"] = 55004
}

function onKill(cid, target)
	local monster = monsters[getCreatureName(target):lower()]
	if(isPlayer(target) == FALSE and monster and getPlayerStorageValue(cid, 25578) == 0) then
		if getPlayerStorageValue(cid, monster) < 500 then 
			local killedMonsters = getPlayerStorageValue(cid, monster)
            if(killedMonsters == -1) then
                killedMonsters = 1
			end
			setPlayerStorageValue(cid, monster, killedMonsters + 1)
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have killed " .. killedMonsters .. " of 500 orcs.")
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have crushed 500 orcs. Report back to the King.")
			setPlayerStorageValue(cid, 25578, 1)
		end
	end
	return TRUE
end

does anyone know why it isn't working? the transcripts works, but I never get the quest and the quest log doesn't work. thanks, +++++++++++ rep if you help me

- - - Updated - - -

anoyne?
 

Similar threads

  • Question Question
Replies
4
Views
289
Back
Top