• 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 Npc with global storage value

Status
Not open for further replies.

d4rkbl0od

Member
Joined
Mar 21, 2008
Messages
160
Reaction score
7
Hello,

I'm having problem on checking a global storage value on NPC. It gives this error:
Code:
Lua Script Error: [Npc interface]
data/npc/scripts/Orockle.lua:eek:nCreatureSay
data/npc/scripts/Orockle.lua:21: attempt to compare nil with number
stack traceback:
        [C]: in function '__le'
        data/npc/scripts/Orockle.lua:21: in function 'callback'
        data/npc/lib/npcsystem/npchandler.lua:412: in function 'onCreatureSay'
        data/npc/scripts/Orockle.lua:8: in function <data/npc/scripts/Orockle.lua:8>
My TFS is 1.2.

Here is the code:

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

function onCreatureAppear(cid)            npcHandler:eek:nCreatureAppear(cid)            end
function onCreatureDisappear(cid)        npcHandler:eek:nCreatureDisappear(cid)            end
function onCreatureSay(cid, type, msg)        npcHandler:eek:nCreatureSay(cid, type, msg)        end
function onThink()                npcHandler:eek:nThink()                    end

local function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end


    if msgcontains(msg, "fight") then
        npcHandler:say("You can help in the fight against the hive. There are several missions available to destabilise the hive. Just ask for them if you want to learn more. After completing many missions you might be worthy to get a reward.", cid)
        npcHandler.topic[cid] = 0
    elseif msgcontains(msg, "mission") then
        if Game.getStorageValue(Storage.WarAgainstTheHive.hiveStage) <= 199 then
            npcHandler:say({
                "You could try to blind the hive, you might disrupt its digestion, you could gather acid or you can disable the swarm pores. ...",
                "Due to our recent success, the hives' defences are broken and it is also possible to kill the guards or to break the control crystals ...",
                "You can always quit a mission of course."
            }, cid)
            npcHandler.topic[cid] = 1
        elseif Game:getStorageValue(Storage.WarAgainstTheHive.hiveStage) >= 200 then
            npcHandler:say({
                "You could try to blind the hive, you might disrupt its digestion, you could gather acid or you can disable the swarm pores. ...",
                "Due to our recent success, the hives' defences are broken and it is also possible to kill the guards or to break the control crystals ...",
                "You can always quit a mission of course."
            }, cid)
            npcHandler.topic[cid] = 6
        end
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Change
Code:
Game.getStorageValue
for
Code:
getGlobalStorageValue
 
Status
Not open for further replies.
Back
Top