Hermes
dziwki kola gramy w lola
Hi there!
For Gattaca's request >HERE< I have made little quest NPC example.
It's supposed to give 20CC in exchange to 10CC, only once.
(EXAMPLE PLX!!!!)
Also take a closer look on talkStates, that's important in bigger NPCs.
@edit
Renusek asked me to add quests.xml example, and so I did. Remember to set "YOURSTORAGE" in both codes. These values MUST be the same ofcourse to work with each other.
and quests.xml example for this quest:
Made really fast, I was hurryin' :f
Regards,
Hermes
For Gattaca's request >HERE< I have made little quest NPC example.
It's supposed to give 20CC in exchange to 10CC, only once.
(EXAMPLE PLX!!!!)
Also take a closer look on talkStates, that's important in bigger NPCs.
@edit
Renusek asked me to add quests.xml example, and so I did. Remember to set "YOURSTORAGE" in both codes. These values MUST be the same ofcourse to work with each other.
Code:
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
--[[
REMEMBER TO SET YOUR STORAGE AS YOURSTORAGE!
]]--
local storage = YOURSTORAGE
if(msgcontains(msg, 'quest') or msgcontains(msg, 'crystal')) then
if(getPlayerStorageValue(cid, storage) < 1) then
npcHandler:say("Hey, I have super quest for you. Bring me please {10 crystal coins}.", cid)
setPlayerStorageValue(cid, storage, 1)
elseif(getPlayerStorageValue(cid, storage) == 1) then
npcHandler:say("Do you have 10 crystal coins for me?", cid)
talkState[talkUser] = 1
elseif(getPlayerStorageValue(cid, storage) == 2) then
npcHandler:say("Sorry, you have already done my super quest.", cid)
end
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if(doPlayerRemoveMoney(cid, 100000) == TRUE) then
npcHandler:say("Thanks! As I said, here\'s 20 crystal coins!", cid)
doPlayerAddItem(cid, 2160, 20)
setPlayerStorageValue(cid, storage, 2)
talkState[talkUser] = 0
else
npcHandler:say("Sorry, you don\'t have enough money.", cid)
talkState[talkUser] = 0
end
elseif(msgcontains(msg, 'no') and talkState[talkUser] > 0) then
npcHandler:say("Then not.", cid)
talkState[talkUser] = 0
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
and quests.xml example for this quest:
Code:
<quest name="Super Quest" startstorageid="YOURSTORAGE" startstoragevalue="1">
<mission name="Money deliver." storageid="YOURSTORAGE" startvalue="1" endvalue="2">
<missionstate id="1" description="You've been asked to deliver 10 crystal coins to NPC. Perhaps you will have profit from this."/>
<missionstate id="2" description="You have successfully delivered money. You earned 20 crystal coins for this task."/>
</mission>
</quest>
Made really fast, I was hurryin' :f
Regards,
Hermes
Last edited: