• 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!

Lua TFS 1.5 Nekiro 772 real blue djinn behaviour

Gover

Member
Joined
Sep 3, 2009
Messages
41
Reaction score
6
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.

1741887133451.webp

#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).
1741887524374.webp
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())
 
Solution
There is onTradeRequest callback in NPC system. It should work on Nekiro:
LUA:
local function onTradeRequest(cid)
    local player = Player(cid)

    if 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)
        return false
    end

    return true
end

npcHandler:setCallback(CALLBACK_ONTRADEREQUEST, onTradeRequest)
and add all shopModule:addSellableItem outside local function creatureSayCallback(cid, type, msg).
It should block shop trading for players who did not finish quest.
Are you copying this code from some server?

Check if you have the storage data/lib/core/storages.lua
LUA:
PlayerStorageKeys.DjinnWar.MaridFaction.Mission03

Also check if in data/creaturescripts/creaturescripts.lua has something related to DjinnWar
 
yes yes, i have correct storages. This one is storage key 114 with value of 3 and it is working good.
When the user without the correct storage value tries to sell the item as the first player after the server was booted then djinn will answer the message "I\'m sorry, pal. But you need Gabel\'s permission to trade with me.". But when another player with correct storage value will try to sell the item to djinn then it unlocks the djinn for every player (even players without correct storage value)

I'm using orts datapack as the source for some scripts and trying to modify them to work with nekiro on old protocol.

I'm guessing that maybe shopmodule cannot be inside the creatureSayCallback function. Usually it is present right after the onThink, like in runes.lua template from nekiro:

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 shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

shopModule:addBuyableItem({'spellbook'}, 2175, 150, 'spellbook')
shopModule:addBuyableItem({'magic lightwand'}, 2162, 400, 'magic lightwand')

but with that i cannot use condition parameter (if elseif etc) I need a function to call that.

I'm a newbie in scripting, just returned to it after many years.

Update:

yes I confirmed that issue is propably with ShopModule. I think it cannot be inside the function (or can be, but have to be handled in different way).

Below is a shorter code. If I replace this 3 lines:
Code:
            local shopModule = ShopModule:new()
                        npcHandler:addModule(shopModule)
                        shopModule:addSellableItem({'spike sword', 'spike sword'}, 2383, 1000, 'spike sword')
With this one:
Code:
npcHandler:say("Your storageValue is correct", cid)

Then everything is working as it should. No matter which player asks first, djinn is answering always at first try and one player cannot unlock djinn for another players. ShopModule just complicates this :/

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 player = Player(cid)

        if msgcontains(msg, "buy") or msgcontains(msg, "sell") then
                if player:getStorageValue(PlayerStorageKeys.DjinnWar.MaridFaction.Mission03) == 3 then
                        local shopModule = ShopModule:new()
                        npcHandler:addModule(shopModule)
                        shopModule:addSellableItem({'spike sword', 'spike sword'}, 2383, 1000, 'spike sword')
                elseif player:getStorageValue(PlayerStorageKeys.DjinnWar.MaridFaction.Mission03) ~= 3 then
                        npcHandler:say("Your storageValue is incorrect", cid)
                end
        end
        return true
end

npcHandler:setMessage(MESSAGE_WALKAWAY, "Good bye and don't forget me!")
npcHandler:setMessage(MESSAGE_FAREWELL, "Good bye and don't forget me!")

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
There is onTradeRequest callback in NPC system. It should work on Nekiro:
LUA:
local function onTradeRequest(cid)
    local player = Player(cid)

    if 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)
        return false
    end

    return true
end

npcHandler:setCallback(CALLBACK_ONTRADEREQUEST, onTradeRequest)
and add all shopModule:addSellableItem outside local function creatureSayCallback(cid, type, msg).
It should block shop trading for players who did not finish quest.
 
Solution
Thanks Gesior.pl I have set it now and it really works as it should!
Thank you very much.

I dont know why I deleted it - this code was inside the orts files :/ I think it was blocking my keyword "trade" which is below:

LUA:
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!'})

But now everything is working fine.


even the keyword below like "shield", "helmets" - there was an issue with that when player tried to sell dragon shield for example, because shield was the common keyword in both. But now it looks like everything is working great :)

Here is a full code for blue djinn for nekiro 1.5 772. Maybe someone will have similar issue :)

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 onTradeRequest(cid)
    if Player(cid):getStorageValue(PlayerStorageKeys.DjinnWar.MaridFaction.Mission03) ~= 3 then
        npcHandler:say('I\'m sorry, pal. But you need Gabel\'s permission to trade with me.', cid)
        return false
    end

    return true
end

            local shopModule = ShopModule:new()
                npcHandler:addModule(shopModule)
                        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')

                        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')

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. ...\nIf you have the permission to trade with us, check out my latest offers.'})
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 \'world rule!\' all day long. Those people should chill out a bit.'})
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, you know. ...\nBut then, I don\'t like the Efreets\' gibberish about war and world domination, either. ...\nIn the end I chose the side which seemed more tolerant towards attitudes that are a bit... different. And that was clearly the Marid. ...\nBesides, Bo\'ques chose to side with Gabel. And I would have hated never to eat his cooking again. Did you ever try his Chat d\'Aramignon?'})
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 lamp. Gabel should have gotten rid of Malor for good when he had the chance to do so.'})
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 to do so.'})
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, because it was not Daraman who built it. The name refers to Daraman\'s teachings, you know.'})
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 blackmail you. ...\nOr torture you. ...\nOr just kill you for no reason. ...\nBut all in all I think humans are amusing little people.'})
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 not so sure about some of the Efreet, but as for me I think he\'s done a lousy job.'})
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 on all matters. I mean - that thing about asceticism... I think he was a bit extreme there.'})
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 the days...!'})
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 head filled with some crazy religious idea.'})
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 boredom. I hate excitement. Whenever somebody said \'Oh-that\'s-gonna-be-so-exciting\' some really, really bad thing happened.'})
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 verdant - a veritable paradise. ...\nThere were flowers and birds everywhere, and more delicious food anybody could ever eat. ...\nBut then that blockhead Baa\'leal decided it was a good idea to burn it all down. Damn those stupid Efreet!'})
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 him. No human can fool a djinn for long, you know.'})

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 of Daraman, he and his brother. ...\nI guess that happens when you get all freaky about some silly idea. I\'m sure that wouldn\'t have happened if he had taken a more relaxed approach to things. ...\nI remember how I always told him to chill out. But he was stubborn as a headstrong donkey. Just like his brother.'})
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\'s all right. He has suffered enough.'})
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 old cynic.'})
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 stay.'})
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 of laughs together, she and me - playing chess, telling stories, playing tricks on Haroun. ...\nI really like her. I will miss her lots when she\'s gone. <clears his throat> Hey! Don\'t tell her I have said that, ok?'})
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 devout follower of Daraman, but I think he seriously misunderstood his teachings. ...\nI don\'t think it was the old prophet\'s intention to rid this world of laughter and of smiles.'})
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 sided with Malor. Wasn\'t a great loss anyway. ...\nHe may be one mean djinn, but he is thicker than a senile ox. To think Malor made him his lieutenant <laughs>!'})

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 swords, ice rapiers, dragon lances, fire axes and broadswords from you, if you have any.'})
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, crown shields and phoenix 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 helmets.'})
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_ONTRADEREQUEST, onTradeRequest)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

gesior the legend
 
onTradeRequestum retorno de chamada no sistema NPC. Deve funcionar em Nekiro:
LUA:
função local onTradeRequest(cid)
    jogador local = Jogador(cid)

    se jogador:getStorageValue(PlayerStorageKeys.DjinnWar.MaridFaction.Mission03) ~= 3 então
        npcHandler:say("Sinto muito, amigo. Mas você precisa da permissão de Gabel para negociar comigo.", cid)
        retornar falso
    fim

    retornar verdadeiro
fim

npcHandler:setCallback(CALLBACK_ONTRADEREQUEST, onTradeRequest)
e adicione tudo shopModule:addSellableItemde fora local function creatureSayCallback(cid, type, msg).
Deveria bloquear a troca na loja para jogadores que não concluíram a missão.
Very good, one day I want to be like you, hug dear @Gesior.pl
 
Back
Top