Xadrian
Active Member
Witam.
Po trzeciej nieudanej próbie przepisania NPC zawierającego misję dla gracza postanowiłem spytać się Was jak to w końcu powinno wyglądać. Za każdym razem NPC nie odpowiadał w jakiejś części dialogu.
Starszych wersji nie mam, oto ostatnia, chyba najbardziej rozpisana:
Przysłowie 'do trzech razy sztuka' mnie się nie trzyma.
W konsoli 0 błędów.
Liczę, że ktoś pomoże,
Xadrian
Po trzeciej nieudanej próbie przepisania NPC zawierającego misję dla gracza postanowiłem spytać się Was jak to w końcu powinno wyglądać. Za każdym razem NPC nie odpowiadał w jakiejś części dialogu.
Starszych wersji nie mam, oto ostatnia, chyba najbardziej rozpisana:
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
local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local quest = {
storage = 13569,
state = getPlayerStorageValue(cid, 13569),
}
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if(msgcontains(msg, 'mission') or msgcontains(msg, 'quest')) then
if(quest.state == -1 or quest.state == 0) then
talkState[talkUser] = 1
error(liczba1)
elseif(quest.state == 1) then
talkState[talkUser] = 10
else
selfSay('I tink you already done all of my missions. Thank you!', cid)
return true
end
if(talkState[talkUser] == 1) then
selfSay('Do you want to help me in collecting rare types of food? Please, say {yes!}', cid)
talkState[talkUser] = 2
if(talkState[talkUser] == 2) then
if(msgcontains(msg, 'yes')) then
selfSay('Finally person, who can help me.. Im really tried with collecting this types of food. So, can you take to me {10 cocounts?}', cid)
talkState[talkUser] = 3
elseif(msgcontains(msg, 'no')) then
talkState[talkUser] = 1
selfSay('Maybe next time.', cid)
npcHandler:resetNpc()
end
elseif(talkState[talkUser] == 3) then
if(msgcontains(msg, 'yes')) then
selfSay('Thanks, again. I expect to you with {10 cocounts}. Ask me for mission or quest, when you are done.', cid)
doPlayerSetStorageValue(cid, quest.storage, 1)
npcHandler:resetNpc()
elseif(msgcontains(msg, 'no')) then
selfSay('Maybe next time.', cid)
npcHandler:resetNpc()
end
end
elseif(talkState[talkUser] == 10) then
selfSay('Do you want to give me {10 cocounts}?', cid)
talkState[talkUser] = 11
if(msgcontains(msg, 'yes')) then
if(getPlayerItemCount(cid, 2678) >= 10) then
selfSay('Thank you! If you want, to do something more for me, ask me again for mission or quest! However, you now are able to buy exotic types of vegetables and fruits!', cid)
doPlayerSetStorageValue(cid, quest.storage, 2)
talkState[talkUser] = 0
else
selfSay('You dont have {10 cocounts}!', cid)
npcHandler:resetNpc()
end
elseif(msgcontains(msg, 'no')) then
selfSay('So ask me when you are done!', cid)
npcHandler:resetNpc()
end
end
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Code:
http://wklej.org/hash/3f502be656/?zawin=0
Code:
20:22 Lilanne: Hello, Druid Sample. I sell much types of food!
20:22 Druid Sample [98]: mission
<nic>
W konsoli 0 błędów.
Liczę, że ktoś pomoże,
Xadrian