vingo
Active Member
- Joined
- Oct 27, 2012
- Messages
- 464
- Reaction score
- 43
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)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if(msgcontains(msg, "warrior sword")) then
if(getPlayerStorageValue(cid, 1003) < 1) then
npcHandler:say("to get the warrior sword you need to bring me 100 iron ores and a piece of royal steel, will you do that?", cid)
talkState[talkUser] = 1
end
elseif(msgcontains(msg, "iron ore")) then
if(getPlayerStorageValue(cid, 1003) == 1) then
npcHandler:say("Did you bring me 100 iron ores?", cid)
talkState[talkUser] = 3
end
elseif(msgcontains(msg, "royal steel")) then
if(getPlayerStorageValue(cid, 1003) == 2) then
npcHandler:say("Finally! you brought me the royal steel?", cid)
talkState[talkUser] = 4
end
elseif(msgcontains(msg, "knight sword")) then
if(getPlayerStorageValue(cid, 1003) == 3) then
npcHandler:say("If you want the knight sword...hmm thats a hard one, but you will need to bring me 100 iron ores and a HUGE chunk of crude iron?", cid)
talkState[talkUser] = 5
end
elseif(msgcontains(msg, "iron ores")) then
if(getPlayerStorageValue(cid, 1003) == 4) then
npcHandler:say("Is it your true wish to sacrifice a ring of the sky to Zathroth?", cid)
talkState[talkUser] = 6
end
elseif(msgcontains(msg, "yes")) then
if(talkState[talkUser] == 1) then
npcHandler:say("You will probably have to face many dangerous monsters, are you still up for the task?", cid)
talkState[talkUser] = 2
elseif(talkState[talkUser] == 2) then
npcHandler:say("Good decision, now get on with your collecting", cid)
setPlayerStorageValue(cid, 1003, 1)
talkState[talkUser] = 0
elseif(talkState[talkUser] == 3) then
if(getPlayerItemCount(cid, 5880) >= 100) then
doPlayerRemoveItem(cid, 5880, 100)
npcHandler:say("Good, let me get to work, don't forget that I need a piece of the royal steel we talked about.", cid)
setPlayerStorageValue(cid, 1003, 2)
talkState[talkUser] = 0
end
elseif(talkState[talkUser] == 4) then
if(getPlayerItemCount(cid, 5887) >= 1) then
npcHandler:say("Alright, I think I have one laying around here somewhere, here you are, the warrior sword!", cid)
doPlayerRemoveItem(cid, 5887, 1)
setPlayerStorageValue(cid, 1003, 3)
doPlayerAddOutfit(cid, getPlayerSex(cid) == 0 and 134 or 142, 2)
talkState[talkUser] = 0
end
if(talkState[talkUser] == 5) then
npcHandler:say("You will probably have to face many dangerous monsters, are you still up for the task?", cid)
talkState[talkUser] = 6
elseif(talkState[talkUser] == 2) then
npcHandler:say("Good decision, now get on with your collecting", cid)
setPlayerStorageValue(cid, 1003, 1)
talkState[talkUser] = 0
end
elseif(talkState[talkUser] == 6) then
if(getPlayerItemCount(cid, 2123) >= 1) then
npcHandler:say("Here you are, the knight sword! ", cid)
doPlayerRemoveItem(cid, 2123, 1)
setPlayerStorageValue(cid, 1003, 5)
doPlayerAddOutfit(cid, getPlayerSex(cid) == 0 and 131 or 139, 2)
talkState[talkUser] = 0
end
end
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Can someone help me finish this,?
The first part is done (getting the warrior sword) but how do I implement the second part (getting the knight sword addon)