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

TFS 1.X+ Djinn NPC talk only if quest is done

Hayvosh

Member
Joined
Feb 7, 2019
Messages
40
Solutions
2
Reaction score
10
Location
Sweden
Hello,

I have been working on getting the Djinn War quest complete, for TFS 1.5 Nekiros downgrade 7.72.
And the quest in whole works fine now, however I can not get the Djinn NPCs only talk to me if I have completed the quest.
Been searching around this forum for ideas, but I'm stuck.
The npcs talks and sells me items just fine, the problem is that they do it even if the quest is not even complete.
They should only greet me and talk to me if the player have storage 9032 with value 8.

Here's my lua of Haroun

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
-- OTServ event handling functions end


local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)


shopModule:addSellableItem({'sword ring'}, 2207, 500, 'sword ring')
shopModule:addSellableItem({'club ring'}, 2209, 500, 'club ring')
shopModule:addSellableItem({'axe ring'}, 2208, 500, 'axe ring')
shopModule:addSellableItem({'power ring'}, 2166, 100, 'power ring')
shopModule:addSellableItem({'stealth ring'}, 2165, 200, 'stealth ring')
shopModule:addSellableItem({'stone skin amulet'}, 2197, 5000, 'stone skin amulet')
shopModule:addSellableItem({'elven amulet'}, 2198, 500, 'elven amulet')
shopModule:addSellableItem({'bronze amulet'}, 2172, 100, 'bronze amulet')
shopModule:addSellableItem({'garlic necklace'}, 2199, 100, 'garlic necklace') 
shopModule:addSellableItem({'magic light wand'}, 2162, 35, 'magic light wand')
shopModule:addSellableItem({'wand of vortex'}, 2190, 100, 'wand of vortex')
shopModule:addSellableItem({'wand of dragonbreath'}, 2191, 200, 'wand of dragonbreath')
shopModule:addSellableItem({'wand of plague'}, 2188, 1000, 'wand of plague')
shopModule:addSellableItem({'wand of cosmic energy'}, 2189, 2000, 'wand of cosmic energy')
shopModule:addSellableItem({'wand of inferno'}, 2187, 3000, 'wand of inferno')
shopModule:addSellableItem({'orb'}, 2176, 750, 'orb')
shopModule:addSellableItem({'mind stone'}, 2178, 100, 'mind stone')
shopModule:addSellableItem({'life crystal'}, 2177, 50, 'life crystal')

shopModule:addBuyableItem({'sword ring'}, 2207, 500, 'sword ring')
shopModule:addBuyableItem({'club ring'}, 2209, 500, 'club ring')
shopModule:addBuyableItem({'axe ring'}, 2208, 500, 'axe ring')
shopModule:addBuyableItem({'power ring'}, 2166, 100, 'power ring')
shopModule:addBuyableItem({'stealth ring'}, 2165, 5000, 'stealth ring')
shopModule:addBuyableItem({'stone skin amulet'}, 2197, 5000, 'stone skin amulet')
shopModule:addBuyableItem({'elven amulet'}, 2198, 500, 'elven amulet')
shopModule:addBuyableItem({'bronze amulet'}, 2172, 100, 'bronze amulet')
shopModule:addBuyableItem({'garlic necklace'}, 2199, 100, 'garlic necklace')

keywordHandler:addKeyword({'offer'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I sell and buy different rings and amulets. I also extract magic sulphur from fire swords, warrior\'s sweat from warrior helmets, fighting spirit from royal helmets and enchanted chicken wings from boots of haste."})
keywordHandler:addKeyword({'sell'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Why would I need that rubbish? Just fooling you... I buy Sword ring, Club ring, Axe ring, Power ring and Stealth rings. Stone skin amulet, Elven amulet, Bronze amulet and Garlic necklaces. Magic light wand, Wand of Vortex, Wand of Dragonbreath, Wand of Plague, Wand of Cosmic Energy and Wand of Inferno. I also buy Orbs, Mind stones and Life Crystals."})
keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = " seel all kinds of tools."})
keywordHandler:addKeyword({'wand'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I'm buying wands of vortex, wands of dragonbreath, wands of plague, wands of cosmic energy and wands of inferno as well as magic light wands."})
keywordHandler:addKeyword({'special'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I'm selling and buying magic light wands. I'm currently also looking for mind stones, life crystals and orbs."})
keywordHandler:addKeyword({'quest'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "A quest is nothing I want to be involved in."})
keywordHandler:addKeyword({'mission'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I can\'t help you in that area, son."})
keywordHandler:addKeyword({'buy'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Sorry but I do not sell those. Just fooling you... I sell Sword ring, Club ring, Axe ring, Power ring, Stealth rings. Stone Skin amulet, Elven amulet, Bronze amulet and Garlic necklace."})

function BlueGreetCallback(cid)
    if getPlayerStorageValue(cid, 9032) ~= 2 then --this is the storagevalue that you want to allow you to say "hi" to this npc
        npcHandler:say("Shove off, little one! Humans are not welcome here.", cid)
        return false
    end
    return true
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

local donestorage = 9032
          
if msgcontains(msg, "items") or msgcontains(msg, "change") and getPlayerStorageValue(cid, donestorage) == 8 then
if getPlayerStorageValue(cid, donestorage) == 8 then
        npcHandler:say('I trade Enchanted Chicken Wind  for Boots of Haste ,Warrior Sweat for 4 Warrior Helmets ,Fighting Spirit for 2 Royal Helmet Magic Sulphur for 3 Fire Swords and Loterry ticket for 100 empty vials', cid)
  end
    elseif msgcontains(msg,'enchanted chicken wind') or msgcontains(msg,'boots of haste') then
    if getPlayerStorageValue(cid, donestorage) == 8 then
        npcHandler:say('Do you want to trade Boots of haste for Enchanted Chicken Wind?', cid)
        talk_state = 1
        end
 
    elseif msgcontains(msg,'warrior Sweat') or msgcontains(msg,'warrior helmet') then
    if getPlayerStorageValue(cid, donestorage) == 8 then
        npcHandler:say('Do you want to trade 4 Warrior Helmet for Warrior Sweat?', cid)
        talk_state = 2
        end
 
    elseif msgcontains(msg,'fighting Spirit') or msgcontains(msg,'royal helmet') then
    if getPlayerStorageValue(cid, donestorage) == 8 then
        npcHandler:say('Do you want to trade 2 Royal Helmet for Fighting Spirit', cid)       
        talk_state = 3
        end
 
    elseif msgcontains(msg,'magic sulphur') or msgcontains(msg,'fire sword') then
    if getPlayerStorageValue(cid, donestorage) == 8 then
        npcHandler:say('Do you want to trade 3 Fire Sword for Magic Sulphur', cid)
        talk_state = 4
        end
 
    elseif msgcontains(msg,'lottery ticket') or msgcontains(msg,'lottery') or msgcontains(msg,'ticket') then
    if getPlayerStorageValue(cid, donestorage) == 8 then
        npcHandler:say('Do you want to trade 100 empty vials for lottery ticket', cid)     
        talk_state = 5
        end
 
    elseif msgcontains(msg,'yes') and talk_state == 1 then
        if getPlayerItemCount(cid,2195) >= 1 then
            if doPlayerRemoveItem(cid,2195,1) then
                npcHandler:say(msg,'Here you are', cid)
                doPlayerAddItem(cid,5891,1)
            end
        else
            npcHandler:say('Sorry you don\'t have the item', cid)
        end
 
    elseif msgcontains(msg,'yes') and talk_state == 2 then
        if getPlayerItemCount(cid,2475) >= 4 then
            if doPlayerRemoveItem(cid,2475,4) then
                npcHandler:say(msg,'Here you are', cid)
                doPlayerAddItem(cid,5885,1)
            end
        else
            npcHandler:say('Sorry you don\'t have the item', cid)
        end
 
    elseif msgcontains (msg,'yes') and talk_state == 3 then
        if getPlayerItemCount(cid,2498) >= 2 then
            if doPlayerRemoveItem(cid,2498,2) then
                npcHandler:say(msg,'Here you are', cid)
                doPlayerAddItem(cid,5884,2)
            end
        else
            npcHandler:say('Sorry but you don\'t have the item', cid)
        end
 
    elseif msgcontains(msg,'yes') and talk_state == 4 then
        if getPlayerItemCount (cid,2392) >= 3 then
            if doPlayerRemoveItem (cid,2392,3) then
                npcHandler:say(msg,'Here you are', cid)
                doPlayerAddItem(cid,5904,1)
            end
        else
            npcHandler:say('Sorry but you don\'t have the item', cid)
        end
 
    elseif msgcontains(msg,'yes') and talk_state == 5 then
        if getPlayerItemCount (cid,2006) >= 100 then
            if doPlayerRemoveItem (cid,2006,100) then
                npcHandler:say(msg,'Here you are', cid)
                doPlayerAddItem(cid,5957,1)
            end
        else
            npcHandler:say('Sorry but you don\'t have the item', cid, cid)
        end
 
        elseif msgcontains(msg,'no') and (talk_state >= 1 and talk_state <= 5) then
             npcHandler:say(msg,'Ok then', cid)
             talk_state = 0
    end
    return true
end

npcHandler:setMessage(MESSAGE_GREET, "Be greeted, human |PLAYERNAME|. How can a humble djinn be of service?")
npcHandler:setMessage(MESSAGE_FAREWELL, "Farewell! May the serene light of the enlightened one rest shine on your travels.")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Farewell, human.")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, BlueGreetCallback)
npcHandler:addModule(FocusModule:new())
 
Solution
at bottom of code
Lua:
npcHandler:setMessage(MESSAGE_GREET, "Be greeted, human |PLAYERNAME|. How can a humble djinn be of service?")
npcHandler:setMessage(MESSAGE_FAREWELL, "Farewell! May the serene light of the enlightened one rest shine on your travels.")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Farewell, human.")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, BlueGreetCallback)
npcHandler:addModule(FocusModule:new())
change to
Lua:
npcHandler:setMessage(MESSAGE_GREET, "Be greeted, human |PLAYERNAME|. How can a humble djinn be of service?")
npcHandler:setMessage(MESSAGE_FAREWELL, "Farewell! May the serene light of the enlightened one rest shine on your travels.")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Farewell, human.")...
at bottom of code
Lua:
npcHandler:setMessage(MESSAGE_GREET, "Be greeted, human |PLAYERNAME|. How can a humble djinn be of service?")
npcHandler:setMessage(MESSAGE_FAREWELL, "Farewell! May the serene light of the enlightened one rest shine on your travels.")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Farewell, human.")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, BlueGreetCallback)
npcHandler:addModule(FocusModule:new())
change to
Lua:
npcHandler:setMessage(MESSAGE_GREET, "Be greeted, human |PLAYERNAME|. How can a humble djinn be of service?")
npcHandler:setMessage(MESSAGE_FAREWELL, "Farewell! May the serene light of the enlightened one rest shine on your travels.")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Farewell, human.")
npcHandler:setCallback(CALLBACK_GREET, BlueGreetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Solution
Back
Top