Hello everyone,
I'm struggling with the npc script, which I would like to work like real Blue Djinn from old days.
I'm using clean Nekiro 1.5 772 downgrade with default npc libs from this distro.
This npc should be able to buy or sell items only if the player have correct storage value.
The behaviour is really strange with this one.
#1:BUG
The npc does not answer with a sell/buy offer at first try. This issue is present only after the server was booted. I just need to say it one more time - and then it works good, even for the another players. It seems that the first sale/purchase offer is blocked in some way, but each subsequent one works fine. This issue is not big, but maybe someone have a solution.

#2:BUG
When player does not have the proper storage and try to sell/buy the item the npc will answer correctly, but only when this player was talking to this npc as the first after server was booted.
When we talk to npc with another player which have proper storage it will unlock the npc for every player (even for players without proper storage).

And interesting thing is that if user does not have proper storage then the first message after server booted is handled correctly by the npc.
The code is below.
Do someone have an idea what could be wrong in it?
Many thanks for any help from you guys
Have a great day!
I'm struggling with the npc script, which I would like to work like real Blue Djinn from old days.
I'm using clean Nekiro 1.5 772 downgrade with default npc libs from this distro.
This npc should be able to buy or sell items only if the player have correct storage value.
The behaviour is really strange with this one.
#1:BUG
The npc does not answer with a sell/buy offer at first try. This issue is present only after the server was booted. I just need to say it one more time - and then it works good, even for the another players. It seems that the first sale/purchase offer is blocked in some way, but each subsequent one works fine. This issue is not big, but maybe someone have a solution.

#2:BUG
When player does not have the proper storage and try to sell/buy the item the npc will answer correctly, but only when this player was talking to this npc as the first after server was booted.
When we talk to npc with another player which have proper storage it will unlock the npc for every player (even for players without proper storage).

And interesting thing is that if user does not have proper storage then the first message after server booted is handled correctly by the npc.
The code is below.
Do someone have an idea what could be wrong in it?
Many thanks for any help from you guys

Have a great day!
LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
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 function creatureSayCallback(cid, type, msg)
if not npcHandler:isFocused(cid) then
return false
end
local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
local player = Player(cid)
if player:getStorageValue(PlayerStorageKeys.DjinnWar.MaridFaction.Mission03) == 3 then
shopModule:addSellableItem({'spike sword', 'spike sword'}, 2383, 1000, 'spike sword')
shopModule:addSellableItem({'war hammer', 'war hammer'}, 2391, 1200, 'war hammer')
shopModule:addSellableItem({'obsidian lance'}, 2425, 500, 'obsidian lance')
shopModule:addSellableItem({'beholder shield'}, 2518, 1200, 'beholder shield')
shopModule:addSellableItem({'noble armor'}, 2486, 900, 'noble armor')
shopModule:addSellableItem({'fire sword'}, 2392, 4000, 'fire sword')
shopModule:addSellableItem({'ice rapier'}, 2396, 1000, 'ice rapier')
shopModule:addSellableItem({'broadsword'}, 2413, 500, 'broadsword')
shopModule:addSellableItem({'dragon lance'}, 2414, 9000, 'dragon lance')
shopModule:addSellableItem({'fire axe'}, 2432, 8000, 'fire axe')
shopModule:addSellableItem({'guardian shield'}, 2515, 2000, 'guardian shield')
shopModule:addSellableItem({'dragon shield'}, 2516, 4000, 'dragon shield')
shopModule:addSellableItem({'crown shield'}, 2519, 8000, 'crown shield')
shopModule:addSellableItem({'phoenix shield'}, 2539, 16000, 'phoenix shield')
shopModule:addSellableItem({'crown armor'}, 2487, 12000, 'crown armor')
shopModule:addSellableItem({'crown legs'}, 2488, 12000, 'crown legs')
shopModule:addSellableItem({'crown helmet'}, 2491, 2500, 'crown helmet')
shopModule:addSellableItem({'crusader helmet'}, 2497, 6000, 'crusader helmet')
shopModule:addSellableItem({'royal helmet'}, 2498, 30000, 'royal helmet')
shopModule:addSellableItem({'blue robe'}, 2656, 10000, 'blue robe')
shopModule:addSellableItem({'boots of haste'}, 2195, 30000, 'boots of haste')
elseif player:getStorageValue(PlayerStorageKeys.DjinnWar.MaridFaction.Mission03) ~= 3 then
npcHandler:say("I\'m sorry, pal. But you need Gabel\'s permission to trade with me.", cid)
end
if player:getStorageValue(PlayerStorageKeys.DjinnWar.MaridFaction.Mission03) == 3 then
shopModule:addBuyableItem({'spike sword'}, 2383, 8000, 'spike sword')
shopModule:addBuyableItem({'war hammer'}, 2391, 10000, 'war hammer')
shopModule:addBuyableItem({'obsidian lance'}, 2425, 8000, 'obsidian lance')
shopModule:addBuyableItem({'beholder shield'}, 2518, 7000, 'beholder shield')
shopModule:addBuyableItem({'noble armor'}, 2486, 8000, 'noble armor')
elseif player:getStorageValue(PlayerStorageKeys.DjinnWar.MaridFaction.Mission03) ~= 3 then
npcHandler:say("I\'m sorry, pal. But you need Gabel\'s permission to trade with me.", cid)
end
end
local node3 = keywordHandler:addKeyword({'name'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Well, my name is Nah\'bob, but I don\'t like it. Just call me Bob.'})
local node4 = keywordHandler:addKeyword({'nah\'bob'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I don\'t like that name. Call me Bob.'})
local node5 = keywordHandler:addKeyword({'bob'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Yep, that\'s me.'})
local node6 = keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I\'m a trader. You know... selling stuff, buying stuff... that kind of thing. Quite a hassle, actually. ...\>
local node7 = keywordHandler:addKeyword({'trade'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'You want to buy something? Well, be my guest. Just ask me for my offers!'})
local node8 = keywordHandler:addKeyword({'permission'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I am not allowed to trade with you unless Gabel gave you the permission to trade with us.'})
local node9 = keywordHandler:addKeyword({'gabel'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'He\'s the boss around here. You know - the big djinn. He\'s all right.'})
local node10 = keywordHandler:addKeyword({'king'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'King? We do not have kings. Not anymore.'})
local node11 = keywordHandler:addKeyword({'djinn'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Yes, I am a djinn. How long did it take you to notice?'})
local node12 = keywordHandler:addKeyword({'efreet'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'The Efreet are a bunch of freaked out loonies, believe me. Nothing but \'war!\' and \'domination!\' and >
local node13 = keywordHandler:addKeyword({'marid'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I guess I am one. I don\'t know why because I\'m not really into all that Daraman stuff about ascetism, y>
local node14 = keywordHandler:addKeyword({'malor'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Now THAT djinn really means stress. Too bad that doofus of an orc king freed him from his prison in the l>
local node15 = keywordHandler:addKeyword({'mal\'ouquah'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Mal\'ouquah the Efreet\'s fortress. I have never seen it, and I don\'t feel any particular desire t>
local node16 = keywordHandler:addKeyword({'ashta\'daramai'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ashta\'daramai is the name of this place - \'Daraman\'s gift\'. It\'s actually a bit misleading,>
local node17 = keywordHandler:addKeyword({'human'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I have nothing against humans. ...\nSure, there are always those who want to steal from you. ...\nOr blac>
local node18 = keywordHandler:addKeyword({'zathroth'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'They say Zathroth created us because he wanted us to be mindless, greedy killing machines. Well, I\'m >
local node19 = keywordHandler:addKeyword({'tibia'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'It\'s a mad, mad world.'})
local node20 = keywordHandler:addKeyword({'daraman'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ah yes. Daraman. The old prophet. Well - he was all right, I guess. But I am not sure I agree with him >
local node21 = keywordHandler:addKeyword({'darashia'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'They say Darashia is full of relaxed people. To me that sounds like a good place to be.'})
local node22 = keywordHandler:addKeyword({'scarab'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Yuk! I wouldn\'t eat that!'})
local node23 = keywordHandler:addKeyword({'edron'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'You are talking about some human place, aren\'t you?'})
local node24 = keywordHandler:addKeyword({'thais'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'You are talking about some human place, aren\'t you?'})
local node25 = keywordHandler:addKeyword({'venore'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'You are talking about some human place, aren\'t you?'})
local node26 = keywordHandler:addKeyword({'kazordoon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'You are talking about some human place, aren\'t you?'})
local node27 = keywordHandler:addKeyword({'carlin'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'You are talking about some human place, aren\'t you?'})
local node28 = keywordHandler:addKeyword({'ab\'dendriel'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'You are talking about some human place, aren\'t you?'})
local node29 = keywordHandler:addKeyword({'ankrahmun'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I know Ankrahmun - I\'ve been there before. Lots of pyramids and stuff. Wicked.'})
local node30 = keywordHandler:addKeyword({'pharaoh'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'The pharaoh? I have heard about that guy. That man is as mad as a march hare.'})
local node31 = keywordHandler:addKeyword({'palace'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'The palace in Ankrahmun used to be a place of orgies and of all kinds of debauchery. Aah - those were th>
local node32 = keywordHandler:addKeyword({'ascension'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Yeah right. I don\'t know what it is about you humans. I have rarely met a human who did not have his>
local node33 = keywordHandler:addKeyword({'kha\'zeel'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I like the Kha\'zeel mountains. It is true they are boring as hell, but personally I don\'t mind bore>
local node34 = keywordHandler:addKeyword({'kha\'labal'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Did you know that desert used to be fertile land? You should have seen it. It was all lush and verda>
local node35 = keywordHandler:addKeyword({'melchior'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Of course I remember old Melchior. He used to come up here regularly. Is he dead?'})
node35:addChildKeyword({'yes'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'Oh. Well, I suppose that is bad. For him, anyway.'})
node35:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, reset = true, text = 'So the old skinflint is still alive? Amazing! I could have sworn the Efreet knocked the stuffing out of >
local node36 = keywordHandler:addKeyword({'alesar'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I know Alesar. Ran off to the Efreet, didn\'t he? Weird story. Always used to be such fanatic followers >
local node37 = keywordHandler:addKeyword({'brother'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Haroun is Alesar\'s brother. Don\'t talk to him about it, though. Haroun may be a zealous fool, but he\>
local node38 = keywordHandler:addKeyword({'fa\'hradin'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I think Fa\'hradin has stopped taking things too seriously long time ago. You just got to love the o>
local node39 = keywordHandler:addKeyword({'bo\'ques'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Honestly, if I did not have any other reason for hanging out here Bo\'ques\'s cooking would make me st>
local node40 = keywordHandler:addKeyword({'djem'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'The little girl djema is bored out of her mind here so she often comes round. We\'ve always had a barrel o>
local node41 = keywordHandler:addKeyword({'haroun'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ah yes - Haroun. My esteemed fellow trader. Stiff like a butler and boring like a tax collector. He is a>
local node42 = keywordHandler:addKeyword({'baa\'leal'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Baa\'leal? Of course I remember old bulldog face. I wasn\'t surprised at all when I heard that he sid>
local node43 = keywordHandler:addKeyword({'wares'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'My job around here is to buy and sell weapons, armors, helmets, legs, and shields.'})
local node44 = keywordHandler:addKeyword({'offer'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'My job around here is to buy and sell weapons, armors, helmets, legs, and shields.'})
local node45 = keywordHandler:addKeyword({'goods'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'My job around here is to buy and sell weapons, armors, helmets, legs, and shields.'})
local node46 = keywordHandler:addKeyword({'equipment'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'My job around here is to buy and sell weapons, armors, helmets, legs, and shields.'})
local node47 = keywordHandler:addKeyword({'do', 'you', 'sell'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'My job around here is to buy and sell weapons, armors, helmets, legs, and shields.'})
local node48 = keywordHandler:addKeyword({'do', 'you', 'have'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'My job around here is to buy and sell weapons, armors, helmets, legs, and shields.'})
local node49 = keywordHandler:addKeyword({'weapon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I\'m selling and buying spike swords, war hammers and obsidian lances. Furthermore I would buy fire swor>
local node50 = keywordHandler:addKeyword({'shield'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I\'m just selling beholder shields. But I\'m buying guardian shields, dragon shields, beholder shields, >
local node51 = keywordHandler:addKeyword({'armor'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I\'m selling and buying noble armors. Furthermore I\'m buying crown armors and blue robes.'})
local node52 = keywordHandler:addKeyword({'helmet'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'At this time I\'m not selling any helmets. I\'m only buying crown helmets, crusader helmets and royal he>
local node53 = keywordHandler:addKeyword({'trousers'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'At this time I\'m only buying crown legs. Oh, and I\'m also looking for boots of haste!'})
local node54 = keywordHandler:addKeyword({'legs'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'At this time I\'m only buying crown legs. Oh, and I\'m also looking for boots of haste!'})
npcHandler:setMessage(MESSAGE_GREET, "<Sighs> Another {customer}! I've only just sat down! What is it, |PLAYERNAME|?")
npcHandler:setMessage(MESSAGE_FAREWELL, "Bye now, Neutrala |PLAYERNAME|. Visit old Bob again one day!")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Bye then.")
npcHandler:setMessage(MESSAGE_SENDTRADE, 'At your service, just browse through my wares.')
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())