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

[Support] My NPC + Function not working correctly

Michael Orsino

Premium User
Premium User
Support Team
Joined
Nov 15, 2007
Messages
854
Solutions
10
Reaction score
389
Location
Santiago, Chile (Australian)
Unfortunately the NPC script I have just written is not working as I had hoped it would. I am unsure what the problem is, most likely something small and stupid.
Sometimes no error is displayed, and others, I get the following:
[21/01/2010 21:19:26] [Error - Npc interface]
[21/01/2010 21:19:26] data/npc/scripts/javian.lua:eek:nCreatureSay
[21/01/2010 21:19:26] Description:
[21/01/2010 21:19:26] (luaGetCreatureStorage) Creature not found

Code:
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

function javian(cid, message, keywords, parameters, node)
    if(not npcHandler:isFocused(cid)) then
        return false
    end

local skillpointstor = 6666
local skillpoints = getCreatureStorage(cid,skillpointstor)

        if getPlayerLevel(cid) <= 2  then
            npcHandler:say('Good, head there now!', cid)
            	setCreatureStorage(cid,skillpointstor,skillpoints + 5)
		doPlayerPopupFYI(cid, 'You have been awarded 5 skill points. Skill points can be used in order to learn or train with certain NPCs. The ex-guardsman to the north 

is the first Trainer. From him you can learn a few things to keep you alive. To check your current skill points, simply type !skillpoints. You will gain 2 skill points for every 

level you advance.')
end
return TRUE
        else
            npcHandler:say('Please reconcider, you will die out there without his help!', cid)
end
end


keywordHandler:addKeyword({'happened'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "What, you dont remember...anything? How is that possible?? You are in 

the farming village of {Deeken}."})
keywordHandler:addKeyword({'deeken'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "This is only a small town, we just look after outself really, it has 

been a long time since anyone {new} arrived"})
keywordHandler:addKeyword({'new'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "With the orcs constanly laying {seige} to the cities it is rare that anyone 

travels at all, let alone to a small village like ours."})
keywordHandler:addKeyword({'seige'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Well of course, the Orcs all but control the continent, it is only lucky 

that we are left alone out here in the forrest. Even the small towns are attacked!"})
keywordHandler:addKeyword({'towns'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "There are many towns scattered over the continent, the closest is 

{Delve}. Last I heard, they are still holding out against the Orcs."})
keywordHandler:addKeyword({'delve'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "The orcs have been slowly taking over the entire {continent}, enslaving 

the humans, taking over towns"})
keywordHandler:addKeyword({'continent'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Yes well the world is large, you should explore - but be careful and 

don't leave unprepared! Talk to everyone, I am sure they could offer you some equipment in return for doing jobs. Also, to the north is an ex-{guardsman}. You should talk to 

him."})

local node1 = keywordHandler:addKeyword({'guardsman'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'He has made his home just north of here in a clearing 

in the forrest. Will you go to him? Please say {yes}! We need more strong people around!'})
    node1:addChildKeyword({'yes'}, javian, {npcHandler = npcHandler, onlyFocus = true, reset = true})
    node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Please reconcider, you will die out there without his help!', reset = true})
npcHandler:addModule(FocusModule:new())

You talk to the NPC, go through the conversation following the keywords, and then trigger the function. Everything works up till the function, where nothing happens. Any clues? Much appreciated.

-Michael
 
Back
Top