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

Problem with quest NPC

Hermes

dziwki kola gramy w lola
Joined
Nov 17, 2007
Messages
1,867
Reaction score
14
Location
Poland
Hi there, I have an error with NPC:

Code:
storage = 54164 -- storage ID
local reward = doPlayerAddItem(cid, 1981, 1)
text = "Legends book I /n In the old graveyard is a grave of mighty knight, Sam. Entrance to his crypt is closed by a magic word. This word is written in a place he died."

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 librarian(cid, message, keywords, parameters, node)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
    if (parameters.book == true) then
        if (getPlayerStorageValue(cid, storage) < 1) then
            doPlayerAddItem(cid, 1981, 1)
      	doSetItemText(item.itemid, text)
            setPlayerStorageValue(cid, storage, 1)
            npcHandler:say('Let me see... Take this book with you, it might help! But be careful, it is so old!', cid)
        else
            npcHandler:say('I gave you the book already!', cid)
        end
    else
        npcHandler:say('So be it..', cid)
    end
    npcHandler:resetNpc()
    return true
end

local noNode = KeywordNode:new({'no'}, librarian, {book = false})
local yesNode = KeywordNode:new({'password'}, librarian, {book = true})

keywordHandler:addKeyword({'librarian'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Yes, I am librarian. I am running this huge library!'})
keywordHandler:addKeyword({'library'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I am so happy seing people reading mine books! Some of them are really old...'})
keywordHandler:addKeyword({'mission'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Oh, I know something about a crypt posessed with demons. Some legends says that to proceed there you might need a password.'})

npcHandler:addModule(FocusModule:new())

Code:
[10/12/2008 15:34:41] Lua Script Error: [Npc interface] 
[10/12/2008 15:34:41] data/npc/scripts/library.lua

[10/12/2008 15:34:41] luaDoPlayerAddItem(). Player not found

And how I can give an action id for this book?

Regards,
Hermes
 
Code:
storage = 54164 -- storage ID
text = "Legends book I\n In the old graveyard is a grave of mighty knight, Sam. Entrance to his crypt is closed by a magic word. This word is written in a place he died."

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 librarian(cid, message, keywords, parameters, node)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
    if (parameters.book == true) then
        if (getPlayerStorageValue(cid, storage) < 1) then
            local reward = doPlayerAddItem(cid, 1981, 1)
	    doSetItemText(reward, text)
            setPlayerStorageValue(cid, storage, 1)
            npcHandler:say('Let me see... Take this book with you, it might help! But be careful, it is so old!', cid)
        else
            npcHandler:say('I gave you the book already!', cid)
        end
    else
        npcHandler:say('So be it..', cid)
    end
    npcHandler:resetNpc()
    return true
end

local noNode = KeywordNode:new({'no'}, librarian, {book = false})
local yesNode = KeywordNode:new({'password'}, librarian, {book = true})

keywordHandler:addKeyword({'librarian'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Yes, I am librarian. I am running this huge library!'})
keywordHandler:addKeyword({'library'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I am so happy seing people reading mine books! Some of them are really old...'})
keywordHandler:addKeyword({'mission'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Oh, I know something about a crypt posessed with demons. Some legends says that to proceed there you might need a password.'})

npcHandler:addModule(FocusModule:new())

'cid' returns nil up there.
 
Back
Top Bottom