• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Solved Simon The Beggar NPC

jigsaw

Member
Joined
Dec 21, 2008
Messages
137
Solutions
4
Reaction score
16
NPC does not respond when I say "help". I'm trying to get the key in fibula.

here is the lua.
 

Attachments

Solution
I really don't understand why all of this. Its unfair. I also help others, members, friends and everything.. I'm not a kid for christ sake.

The only thing I said its just "Okay, then don't. Thanks" for you, which didn't want to help because people might think that can be a virus or anything. And then I said I was being rational, like, if people think that might be a virus in the file, then don't download it. it is just a simple as that. And for that people start the histeria, others said that rational is related to the forum rules or the way I show the code. I mean, what the hell? (which I didn't read so far, but I will as soon as I have time for it). Anyway, I didn't make trouble, most of you guys did a storm over what I say.

I...
Please don't post your code as an attachment. Many would like to interpret it as a virus. Quote it as a code, and I may be able to help you.
 
Is that the way to respond to someone who is willing to give you free support?

I'm just being rational.. if someone does not want to help, okay then.

The problem is simple, I have a issue, I post here the code...if someone doesn't seem right or safe do download the code. Fine. Im not being a bully.. just being a rational guy.

Also, its solved already.
 
I'm just being rational.. if someone does not want to help, okay then.

The problem is simple, I have a issue, I post here the code...if someone doesn't seem right or safe do download the code. Fine. Im not being a bully.. just being a rational guy.

Also, its solved already.
What's rational in uploading the whole file that someone has bother to download? Instead of just pasting the code as text.
Also it's not just about what's more rational, but about Support rules.
 
I'm just being rational.. if someone does not want to help, okay then.

The problem is simple, I have a issue, I post here the code...if someone doesn't seem right or safe do download the code. Fine. Im not being a bully.. just being a rational guy.

Also, its solved already.

If it's solved you should take a look at the rules for the support boards (seems like you forgot to read them ??)
Rules for the Support board
#2, #8

Deleted the post you did 2 min before your last one, since the other one contained the same info.
its solved already. its over.
 
User since 2008. Nice attitude. What can I say? Wow?

„Rational guy”? This was just rude and stupid response.
 
No, you're being rude to people trying to help out, including myself. I really wanted to assist you, but you wouldn't comply. I would normally advice to abandon thread, but feel in all freedom to feed the troll..
latest


In all seriousness, I am sorry you couldn't get the help you needed. Try using the search button or being nicer/appropriate in your request.
 
No, you're being rude to people trying to help out, including myself. I really wanted to assist you, but you wouldn't comply. I would normally advice to abandon thread, but feel in all freedom to feed the troll..
latest


In all seriousness, I am sorry you couldn't get the help you needed. Try using the search button or being nicer/appropriate in your request.

I really don't understand why all of this. Its unfair. I also help others, members, friends and everything.. I'm not a kid for christ sake.

The only thing I said its just "Okay, then don't. Thanks" for you, which didn't want to help because people might think that can be a virus or anything. And then I said I was being rational, like, if people think that might be a virus in the file, then don't download it. it is just a simple as that. And for that people start the histeria, others said that rational is related to the forum rules or the way I show the code. I mean, what the hell? (which I didn't read so far, but I will as soon as I have time for it). Anyway, I didn't make trouble, most of you guys did a storm over what I say.

I will continue to search for help when I needed it for sure. And I'm grateful for those who respond politely.
 
I really don't understand why all of this. Its unfair. I also help others, members, friends and everything.. I'm not a kid for christ sake.

The only thing I said its just "Okay, then don't. Thanks" for you, which didn't want to help because people might think that can be a virus or anything. And then I said I was being rational, like, if people think that might be a virus in the file, then don't download it. it is just a simple as that. And for that people start the histeria, others said that rational is related to the forum rules or the way I show the code. I mean, what the hell? (which I didn't read so far, but I will as soon as I have time for it). Anyway, I didn't make trouble, most of you guys did a storm over what I say.

I will continue to search for help when I needed it for sure. And I'm grateful for those who respond politely.
I am sorry if I offended you, jigsaw. I truly don't want to be that guy. And I truly don't want to start flame wars again in OTLand. I will see if I can help you when I have some free time.

Thanks, dude.

EDIT: OMG DUDE DON'T DOWNLOAD THIS IS A VIRUS!! j/k
@ONT: I tried to figure out what's wrong with your code, but as I haven't kept up with recent distros development, and use a pretty ancient distro, I will just post my code to see if it works for you.

Simon the Beggar.xml
XML:
<npc name="Simon the Beggar" script="Simon the Beggar.lua" floorchange="0" walkinterval="1500" speed="100">
   <health now="100" max="100"/>
   <look type="128" head="116" body="123" legs="32" feet="40"/>
   <parameters>
<parameter key="idletime" value="60"/>
<parameter key="message_greet" value="Hello |PLAYERNAME|. I am a poor man. Please help me."/>
<parameter key="message_placedinqueue" value="Please wait, |PLAYERNAME|."/>
<parameter key="message_walkaway" value="Have a nice day."/>
<parameter key="message_farewell" value="Have a nice day."/>
<parameter key="message_idletimeout" value="Have a nice day."/>
   </parameters>
</npc>

Simon The Beggar.lua
Lua:
dofile(getDataDir() .. 'global/greeting.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
function creatureSayCallback(cid, type, msg)
   if(npcHandler.focus ~= cid) then
       return false
   end
  
   if msgcontains(msg, 'help') then
   npcHandler:say('I need gold. Can you spend me 100 gold pieces?')
   talk_state = 1
  
   elseif msgcontains(msg, 'yes') and talk_state == 1 and getPlayerMoney(cid) >= 100 then
   npcHandler:say('Thank you very much. Can you spend me 500 more gold pieces? I will give you a nice hint.')
   doPlayerRemoveMoney(cid, 100)
   talk_state = 2
   elseif msgcontains(msg, 'yes') and talk_state == 1 and getPlayerMoney(cid) < 100 then
   npcHandler:say('You\'ve not enough money for me.')
   talk_state = 0
   elseif msgcontains(msg, 'no') and talk_state == 1 then
   npcHandler:say('Hmm, maybe next time.')
   talk_state = 0
  
   elseif msgcontains(msg, 'yes') and talk_state == 2 and getPlayerMoney(cid) >= 500 then
   doPlayerRemoveMoney(cid, 500)
   npcHandler:say('That\'s great! I have stolen something from Dermot. You can buy it for 200 gold. Do you want to buy it?')
   talk_state = 3
   elseif msgcontains(msg, 'yes') and talk_state == 2 and getPlayerMoney(cid) < 500 then
   npcHandler:say('Sorry, that\'s not enough.')
   talk_state = 0
   elseif msgcontains(msg, 'no') and talk_state == 2 then
   npcHandler:say('It was your decision.')
   talk_state = 0
  
   elseif msgcontains(msg, 'yes') and talk_state == 3 and getPlayerMoney(cid) >= 200 then
   npcHandler:say('Now you own the hot key.')
   doPlayerRemoveMoney(cid, 200)
   key = doPlayerAddItem(cid, 2087,1)
   doSetItemActionId(key,3940)
   doSetItemSpecialDescription(key, "(Key: 3940)")
   talk_state = 0
   elseif msgcontains(msg, 'yes') and talk_state == 3 and getPlayerMoney(cid) < 200 then
   npcHandler:say('Pah! I said 200 gold. You don\'t have so much.')
   talk_state = 0
   elseif msgcontains(msg, 'no') and talk_state == 3 then
   npcHandler:say('Ok. No problem. I\'ll find another buyer.')
   talk_state = 0
  
   elseif msgcontains(msg, 'bye') and (talk_state >= 1 and talk_state <= 3) then
   npcHandler:say('Have a nice day.')
   talk_state = 0
  
   end
   return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
shopModule:addBuyableItem({'shovel'},                    ID_shovel, 50)
keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I have no job. I am a beggar."})
keywordHandler:addKeyword({'beggar'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I have no gold and no job, so I am a beggar."})
keywordHandler:addKeyword({'gold'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I need gold. I love gold. I need help."})
keywordHandler:addKeyword({'name'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "My name is Simon. I am a very poor man."})
keywordHandler:addKeyword({'simon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I am Simon. The poorest human all over the continent."})
keywordHandler:addKeyword({'dermot'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "The magistrate of the village. I heard he is selling something for the Fibula Dungeon."})
keywordHandler:addKeyword({'village'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "To the north is the village Fibula. A very small village."})
keywordHandler:addKeyword({'key'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Key? There are a lot of keys. Please change the topic."})
keywordHandler:addKeyword({'dungeon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I heard a lot about the Fibula Dungeon. But I never was there."})
keywordHandler:addKeyword({'fibula'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I hate Fibula. Too many wolves are here."})
keywordHandler:addKeyword({'timur'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I hate Timur. He is too expensive. But sometimes I find maces and hatchets. Timur is buying these items."})
keywordHandler:addKeyword({'wolf'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Please kill them ... ALL."})
keywordHandler:addKeyword({'flute'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Har, har. The stupid Dermot lost his flute. I know that some minotaurs have it in their treasure room."})
keywordHandler:addKeyword({'mino'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Very rich monsters. But they are too strong for me. However, there are even stronger monsters."})
keywordHandler:addKeyword({'treasure'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I know there are two rooms. And I know you can pass only the first door. The second door can't be opened."})
keywordHandler:addKeyword({'giant spider'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I know that terrible monster. It killed the fishers on the isle to the north"})
keywordHandler:addKeyword({'monster'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "The strongest monster I know is the giant spider."})
keywordHandler:addKeyword({'jetty'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I hate this jetty. I have never seen a ship here."})
keywordHandler:addKeyword({'ship'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "There is a large sea-monster outside. I think there is no gritty captain to sail in this quarter."})
keywordHandler:addKeyword({'tibia'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Hehe, do you have a shovel? I can sell you a shovel if you want to return to Tibia."})
npcHandler:addModule(FocusModule:new())[/lua]

Here's my greeting.lua if anybody is wondering
Lua:
-- Author:        David
-- Country:       Brazil
-- Email:        [email protected]


function FocusModule:init(handler)
   FOCUS_GREETSWORDS = {'hi', 'hello'}
   FOCUS_FAREWELLSWORDS = {'bye', 'farewell'}
       self.npcHandler = handler
       for i, word in pairs(FOCUS_GREETSWORDS) do
           local obj = {}
           table.insert(obj, word)
           obj.callback = FOCUS_GREETSWORDS.callback or FocusModule.messageMatcher
           handler.keywordHandler:addKeyword(obj, FocusModule.onGreet, {module = self})
       end
       
       for i, word in pairs(FOCUS_FAREWELLSWORDS) do
           local obj = {}
           table.insert(obj, word)
           obj.callback = FOCUS_FAREWELLSWORDS.callback or FocusModule.messageMatcher
           handler.keywordHandler:addKeyword(obj, FocusModule.onFarewell, {module = self})
       end
       
       return true
   end
 
Last edited:
Solution
I am sorry if I offended you, jigsaw. I truly don't want to be that guy. And I truly don't want to start flame wars again in OTLand. I will see if I can help you when I have some free time.

Thanks, dude.

EDIT: OMG DUDE DON'T DOWNLOAD THIS IS A VIRUS!! j/k
@ONT: I tried to figure out what's wrong with your code, but as I haven't kept up with recent distros development, and use a pretty ancient distro, I will just post my code to see if it works for you.

Simon the Beggar.xml
XML:
<npc name="Simon the Beggar" script="Simon the Beggar.lua" floorchange="0" walkinterval="1500" speed="100">
   <health now="100" max="100"/>
   <look type="128" head="116" body="123" legs="32" feet="40"/>
   <parameters>
<parameter key="idletime" value="60"/>
<parameter key="message_greet" value="Hello |PLAYERNAME|. I am a poor man. Please help me."/>
<parameter key="message_placedinqueue" value="Please wait, |PLAYERNAME|."/>
<parameter key="message_walkaway" value="Have a nice day."/>
<parameter key="message_farewell" value="Have a nice day."/>
<parameter key="message_idletimeout" value="Have a nice day."/>
   </parameters>
</npc>

Simon The Beggar.lua
Lua:
dofile(getDataDir() .. 'global/greeting.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
function creatureSayCallback(cid, type, msg)
   if(npcHandler.focus ~= cid) then
       return false
   end
 
   if msgcontains(msg, 'help') then
   npcHandler:say('I need gold. Can you spend me 100 gold pieces?')
   talk_state = 1
 
   elseif msgcontains(msg, 'yes') and talk_state == 1 and getPlayerMoney(cid) >= 100 then
   npcHandler:say('Thank you very much. Can you spend me 500 more gold pieces? I will give you a nice hint.')
   doPlayerRemoveMoney(cid, 100)
   talk_state = 2
   elseif msgcontains(msg, 'yes') and talk_state == 1 and getPlayerMoney(cid) < 100 then
   npcHandler:say('You\'ve not enough money for me.')
   talk_state = 0
   elseif msgcontains(msg, 'no') and talk_state == 1 then
   npcHandler:say('Hmm, maybe next time.')
   talk_state = 0
 
   elseif msgcontains(msg, 'yes') and talk_state == 2 and getPlayerMoney(cid) >= 500 then
   doPlayerRemoveMoney(cid, 500)
   npcHandler:say('That\'s great! I have stolen something from Dermot. You can buy it for 200 gold. Do you want to buy it?')
   talk_state = 3
   elseif msgcontains(msg, 'yes') and talk_state == 2 and getPlayerMoney(cid) < 500 then
   npcHandler:say('Sorry, that\'s not enough.')
   talk_state = 0
   elseif msgcontains(msg, 'no') and talk_state == 2 then
   npcHandler:say('It was your decision.')
   talk_state = 0
 
   elseif msgcontains(msg, 'yes') and talk_state == 3 and getPlayerMoney(cid) >= 200 then
   npcHandler:say('Now you own the hot key.')
   doPlayerRemoveMoney(cid, 200)
   key = doPlayerAddItem(cid, 2087,1)
   doSetItemActionId(key,3940)
   doSetItemSpecialDescription(key, "(Key: 3940)")
   talk_state = 0
   elseif msgcontains(msg, 'yes') and talk_state == 3 and getPlayerMoney(cid) < 200 then
   npcHandler:say('Pah! I said 200 gold. You don\'t have so much.')
   talk_state = 0
   elseif msgcontains(msg, 'no') and talk_state == 3 then
   npcHandler:say('Ok. No problem. I\'ll find another buyer.')
   talk_state = 0
 
   elseif msgcontains(msg, 'bye') and (talk_state >= 1 and talk_state <= 3) then
   npcHandler:say('Have a nice day.')
   talk_state = 0
 
   end
   return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
shopModule:addBuyableItem({'shovel'},                    ID_shovel, 50)
keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I have no job. I am a beggar."})
keywordHandler:addKeyword({'beggar'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I have no gold and no job, so I am a beggar."})
keywordHandler:addKeyword({'gold'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I need gold. I love gold. I need help."})
keywordHandler:addKeyword({'name'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "My name is Simon. I am a very poor man."})
keywordHandler:addKeyword({'simon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I am Simon. The poorest human all over the continent."})
keywordHandler:addKeyword({'dermot'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "The magistrate of the village. I heard he is selling something for the Fibula Dungeon."})
keywordHandler:addKeyword({'village'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "To the north is the village Fibula. A very small village."})
keywordHandler:addKeyword({'key'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Key? There are a lot of keys. Please change the topic."})
keywordHandler:addKeyword({'dungeon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I heard a lot about the Fibula Dungeon. But I never was there."})
keywordHandler:addKeyword({'fibula'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I hate Fibula. Too many wolves are here."})
keywordHandler:addKeyword({'timur'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I hate Timur. He is too expensive. But sometimes I find maces and hatchets. Timur is buying these items."})
keywordHandler:addKeyword({'wolf'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Please kill them ... ALL."})
keywordHandler:addKeyword({'flute'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Har, har. The stupid Dermot lost his flute. I know that some minotaurs have it in their treasure room."})
keywordHandler:addKeyword({'mino'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Very rich monsters. But they are too strong for me. However, there are even stronger monsters."})
keywordHandler:addKeyword({'treasure'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I know there are two rooms. And I know you can pass only the first door. The second door can't be opened."})
keywordHandler:addKeyword({'giant spider'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I know that terrible monster. It killed the fishers on the isle to the north"})
keywordHandler:addKeyword({'monster'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "The strongest monster I know is the giant spider."})
keywordHandler:addKeyword({'jetty'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I hate this jetty. I have never seen a ship here."})
keywordHandler:addKeyword({'ship'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "There is a large sea-monster outside. I think there is no gritty captain to sail in this quarter."})
keywordHandler:addKeyword({'tibia'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Hehe, do you have a shovel? I can sell you a shovel if you want to return to Tibia."})
npcHandler:addModule(FocusModule:new())[/lua]

Here's my greeting.lua if anybody is wondering
Lua:
-- Author:        David
-- Country:       Brazil
-- Email:        [email protected]


function FocusModule:init(handler)
   FOCUS_GREETSWORDS = {'hi', 'hello'}
   FOCUS_FAREWELLSWORDS = {'bye', 'farewell'}
       self.npcHandler = handler
       for i, word in pairs(FOCUS_GREETSWORDS) do
           local obj = {}
           table.insert(obj, word)
           obj.callback = FOCUS_GREETSWORDS.callback or FocusModule.messageMatcher
           handler.keywordHandler:addKeyword(obj, FocusModule.onGreet, {module = self})
       end
      
       for i, word in pairs(FOCUS_FAREWELLSWORDS) do
           local obj = {}
           table.insert(obj, word)
           obj.callback = FOCUS_FAREWELLSWORDS.callback or FocusModule.messageMatcher
           handler.keywordHandler:addKeyword(obj, FocusModule.onFarewell, {module = self})
       end
      
       return true
   end

Thank you! That work perfectly!
 
Back
Top