X
Xikini
Guest
The Forgotten Server, version 0.3.7_SVN (Crying Damson)
The npc doesn't stop and wait for the yes/no keywords.
If I say backpack it says this..
As always,
I would like to thank everyone in advance for any feedback, criticism, or help given!
The npc doesn't stop and wait for the yes/no keywords.
If I say backpack it says this..
Code:
11:13 Xikini [17]: backpack
11:13 Addon Checker: You like my backpack do you? I can make you one for 15,000 gold coins! Would you like to do that?
11:13 Addon Checker: That was not an available keyword. Let's start from the beginning.
I would like to thank everyone in advance for any feedback, criticism, or help given!
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)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
function greet(cid)
talkState[cid] = 0
return true
end
local player_gold = getPlayerItemCount(cid,2148)
local player_plat = getPlayerItemCount(cid,2152)*100
local player_crys = getPlayerItemCount(cid,2160)*10000
local player_money = player_gold + player_plat + player_crys
if msgcontains(msg, "job") then
selfSay("My job is to test peoples grammar.", cid)
elseif msgcontains(msg, "backpack") and (getPlayerStorageValue(cid,45052) < 1) then
selfSay("You like my backpack do you? I can make you one for 15,000 gold coins! Would you like to do that?", cid)
talkState[talkUser] = 1
if msgcontains(msg, "yes") and talkState[talkUser] == 1 then
if player_money >= 15000 then
doPlayerRemoveMoney(cid,15000)
selfSay("You carry that much money on you without a backpack? Imagine what you can carry now! Take care my good friend.", cid)
doPlayerAddOutfit(cid, 136, 1)
doPlayerAddOutfit(cid, 128, 1)
setPlayerStorageValue(cid,45052,1)
talkState[talkUser] = 0
else
selfSay("You simply don't have enough money my friend.", cid)
talkState[talkUser] = 0
end
elseif msgcontains(msg, "no") and talkState[talkUser] == 1 then
selfSay("Ah. That is a shame! I'll have to find some other fool to buy it then.", cid)
talkState[talkUser] = 0
else
selfSay("That was not an available keyword. Let's start from the beginning.", cid)
talkState[talkUser] = 0
end
-- QUEST COMPLETE MESSAGES --
elseif msgcontains(msg, "backpack") and (getPlayerStorageValue(cid,45052) == 1) then
selfSay("You already have a backpack mate. I don't think you need another.", cid)
elseif msgcontains(msg, "reset") then
selfSay("Reset complete.", cid)
setPlayerStorageValue(cid,45052,-1)
end
return true
end
npcHandler:setCallback(CALLBACK_GREET, greet)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())