• 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 Npc Storage

adrenysny

Member
Joined
Feb 17, 2021
Messages
140
Reaction score
14
Help me make this npc ask you for this storage to be able to transport

  • Storage.Quest.FeasterOfSouls.Bosses.IrgixTheFlimsy.Killed
  • Storage.Quest.FeasterOfSouls.Bosses.VokTheFreakish.Killed
  • Storage.Quest.FeasterOfSouls.Bosses.UnazTheMean.Killed
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 voices = {
 {text = 'ANOTHER RABBIT, HMPF. OR IS IT A FOX? A BAT?! STAY OUT!'} ,
 {text = 'Come, take a seat! Or... oh, I see. Feel free to just stand there'}
 
 
 }

npcHandler:addModule(VoiceModule:new(voices))

local function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end
    local player = Player(cid)
 
     if msgcontains(msg, "boss") then
        if player:getStorageValue(Storage.Quest.FeasterOfSouls.Bosses.TheThaian.Timer) > 1 then
            npcHandler:say("You should wait to face the boss", cid)
            npcHandler.topic[cid] = 1
        elseif player:getStorageValue(Storage.Quest.FeasterOfSouls.Bosses.TheThaian.Timer) < 1 then
        player:teleportTo({x = 33898, y = 31887, z = 8})
            player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
            npcHandler.topic[cid] = 0
    end
    
    return true
end             

end

keywordHandler:addKeyword({'thaian'}, StdModule.say, {npcHandler = npcHandler, text = 'So you found non. No crystals, none at all. Go in to the dungeon and try to farm more luminescent crystals.'})
keywordHandler:addKeyword({'need'}, StdModule.say, {npcHandler = npcHandler, text = 'Nrgaaaah! Get back if you have enough info from {Spectulus}...'})
keywordHandler:addKeyword({'report'}, StdModule.say, {npcHandler = npcHandler, text = 'You have to find the way how to acces to the dungeon first.'})
keywordHandler:addKeyword({'mission'}, StdModule.say, {npcHandler = npcHandler, text = 'You have to find the way how to acces to the dungeon first.'})


npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Solution
Looks like you require this many times, you might aswell add just hasAllStorages to your Player lib. xD
Lua:
local function hasAllStorages(player)
    local storageKeys = {
        Storage.Quest.FeasterOfSouls.Bosses.IrgixTheFlimsy.Killed,
        Storage.Quest.FeasterOfSouls.Bosses.VokTheFreakish.Killed,
        Storage.Quest.FeasterOfSouls.Bosses.UnazTheMean.Killed
    }
    for _, storageKey in pairs(storageKeys) do
        if player:getStorageValue(storageKey) <= 0 then
            return false
        end
    end
    return true
end

local keywordHandler = KeywordHandler:new()
local npcHandler     = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid)...
Looks like you require this many times, you might aswell add just hasAllStorages to your Player lib. xD
Lua:
local function hasAllStorages(player)
    local storageKeys = {
        Storage.Quest.FeasterOfSouls.Bosses.IrgixTheFlimsy.Killed,
        Storage.Quest.FeasterOfSouls.Bosses.VokTheFreakish.Killed,
        Storage.Quest.FeasterOfSouls.Bosses.UnazTheMean.Killed
    }
    for _, storageKey in pairs(storageKeys) do
        if player:getStorageValue(storageKey) <= 0 then
            return false
        end
    end
    return true
end

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 voices = {
    {text = 'ANOTHER RABBIT, HMPF. OR IS IT A FOX? A BAT?! STAY OUT!'} ,
    {text = 'Come, take a seat! Or... oh, I see. Feel free to just stand there'}
}

npcHandler:addModule(VoiceModule:new(voices))
local function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end
    local player = Player(cid)
    if msgcontains(msg, "boss") then
        local timerStorage = player:getStorageValue(Storage.Quest.FeasterOfSouls.Bosses.TheThaian.Timer)
        if timerStorage > 1 then
            npcHandler:say("You should wait to face the boss", cid)
            npcHandler.topic[cid] = 1
            return true
        end
        if not hasAllStorages(player) then
            npcHandler:say("You have not defeated all the bosses.", cid)
            npcHandler.topic[cid] = 1
            return true
        end
        player:teleportTo({x = 33898, y = 31887, z = 8})
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
        npcHandler.topic[cid] = 0
        return true
    end
end

keywordHandler:addKeyword({'thaian'}, StdModule.say, {npcHandler = npcHandler, text = 'So you found non. No crystals, none at all. Go in to the dungeon and try to farm more luminescent crystals.'})
keywordHandler:addKeyword({'need'}, StdModule.say, {npcHandler = npcHandler, text = 'Nrgaaaah! Get back if you have enough info from {Spectulus}...'})
keywordHandler:addKeyword({'report'}, StdModule.say, {npcHandler = npcHandler, text = 'You have to find the way how to acces to the dungeon first.'})
keywordHandler:addKeyword({'mission'}, StdModule.say, {npcHandler = npcHandler, text = 'You have to find the way how to acces to the dungeon first.'})
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Solution
Back
Top