ond
Veteran OT User
I have a problem with my script down below. The problem is that you can't script it like this:
BUT you can script it like this (Without start: hat)
Does anyone have an idea how to make it work Anyway?
Quote 1 = Not Work
Quote 2 = Works
if msgcontains(msg, 'hat') then
selfSay('What ever!')
talk_state = 1
elseif talk_state == 1 and msgcontains(msg, 'hat') then
selfSay('What ever again!')
talk_state = 2
BUT you can script it like this (Without start: hat)
if msgcontains(msg, 'random word') then
selfSay('What ever!')
talk_state = 1
elseif talk_state == 1 and msgcontains(msg, 'hat') then
selfSay('What ever again!')
talk_state = 2
elseif talk_state == 2 and msgcontains(msg, 'hat') then
selfSay('What ever again!')
talk_state = 3
Does anyone have an idea how to make it work Anyway?
Quote 1 = Not Work
Quote 2 = Works
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
-- OTServ event handling functions start
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
creaturepos1 = {x=32921, y=32074, z=9}
reaturepos2 = {x=32923, y=32074, z=9}
creaturepos3 = {x=32921, y=32076, z=9}
creaturepos4 = {x=32923, y=32076, z=9}
keywordHandler:addKeyword({'name'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "My name is not of your concern."})
keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "That's only my business, not yours."})
keywordHandler:addKeyword({'david'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I never heard that name and now get lost."})
keywordHandler:addKeyword({'brassacres'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I never heard that name and now get lost."})
function creatureSayCallback(cid, type, msg)
if(npcHandler.focus ~= cid) then
return false
end
msg = msg:lower()
if msgcontains(msg, 'hat') and getPlayerStorageValue(cid, 5209) == 1 then
selfSay('What? My hat?? Theres... nothing special about it!')
talk_state = 1
elseif talk_state == 1 and msgcontains(msg, 'hat') then
selfSay('Stop bugging me about that hat, do you listen?')
talk_state = 2
elseif talk_state == 2 and msgcontains(msg, 'hat') then
selfSay('Hey! Don\'t touch that hat! Leave it alone!!! Don\'t do this!!!!')
talk_state = 3
elseif talk_state == 3 and msgcontains(msg, 'hat') then
selfSay('Noooooo! Argh, ok, ok, I guess I can\'t deny it anymore, I am David Brassacres, the magnificent, so what do you want?')
doSummonCreature("Rat", creaturepos1)
doSummonCreature("Rat", creaturepos2)
doSummonCreature("Rat", creaturepos3)
doSummonCreature("Rat", creaturepos4)
setPlayerStorageValue(cid, 5210, 1)
talk_state = 4
elseif getPlayerStorageValue(cid, 5210) == 1 and msgcontains(msg, 'bill') and talk_state == 4 then
selfSay('A bill? Oh boy so you are delivering another bill to poor me?')
talk_state = 5
elseif talk_state == 5 and msgcontains(msg, 'yes') then
selfSay('Ok, ok, I\'ll take it. I guess I have no other choice anyways. And now leave me alone in my misery please.')
setPlayerStorageValue(cid, 5211, 1)
doPlayerRemoveItem(cid, 2329, 1)
talk_state = 6
-- Without Value --
elseif getPlayerStorageValue(cid, 5209) == -1 and msgcontains(msg, 'bill') then
selfSay('Thats not my concern, you are probably looking for someone else and now get lost!')
talk_state = 0
npcHandler:releaseFocus()
elseif msgcontains(msg, 'hat') and getPlayerStorageValue(cid, 5209) == -1 then
selfSay('Get lost!')
npcHandler:releaseFocus()
talk_state = 0
-- Without Value --
-- After Quest Questions --
elseif msgcontains(msg, 'david') and getPlayerStorage(cid, 5211) == 1 then
selfSay('Yes, yes... Its me .. you exposed me! Stop nagging me with that.')
talk_state = 0
elseif msgcontains(msg, 'brassacres') and getPlayerStorage(cid, 5211) == 1 then
selfSay('Yes, yes... Its me .. you exposed me! Stop nagging me with that.')
talk_state = 0
-- After Quest Questions --
elseif talk_state ~= 0 then
selfSay('Ok')
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Last edited: