Hello
I have a little problem with my NPC. In console I can see this error:
This is my code:
Can you help me ?
I have a little problem with my NPC. In console I can see this error:
HTML:
[05/12/2009 11:13:45] data/lib/function.lua:234: attempt to index a boolean value
[05/12/2009 11:13:45] stack traceback:
[05/12/2009 11:13:45] data/lib/function.lua:234: in function 'getItemName'
[05/12/2009 11:13:45] data/npc/scripts/santa.lua:48: in function 'callback'
[05/12/2009 11:13:45] data/npc/lib/npcsystem/keywordhandler.lua:40: in function 'processMessage'
[05/12/2009 11:13:45] data/npc/lib/npcsystem/keywordhandler.lua:168: in function 'processNodeMessage'
[05/12/2009 11:13:45] data/npc/lib/npcsystem/keywordhandler.lua:122: in function 'processMessage'
[05/12/2009 11:13:45] data/npc/lib/npcsystem/npchandler.lua:380: in function 'onCreatureSay'[PHP][/PHP]
[05/12/2009 11:13:45] data/npc/scripts/santa.lua:23: in function <data/npc/scripts/santa.lua:23>
[05/12/2009 11:17:33] Lua Script Error: [Npc interface]
[05/12/2009 11:17:33] data/npc/scripts/santa.lua:onCreatureSay
[05/12/2009 11:17:33] luaGetItemDescriptions(). Item not found
[05/12/2009 11:17:33] Lua Script Error: [Npc interface]
[05/12/2009 11:17:33] data/npc/scripts/santa.lua:onCreatureSay
This is my code:
PHP:
random_items = {
{5,2514,1}, -- 0.5% to get teddy bear
{20,2493,1}, -- 2% to get santa doll
{40,2195,1}, -- 4% to get piggy bank
{80,2492,5}, -- 8% to get 5 snowballs
{80,2470,8}, -- 8% to get 8 candy canes
{80,2160,30}, -- 8% to get doll
{400,2160,15}, -- 40% to get 15 red apples
{450,2160,10}, -- 45% to get 10 oranges
{1000,2173,1} -- 100% to get 8 cookies
}
PRESENT_STORAGE = 54163 -- storage ID
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 santaNPC(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
return false
end
if (parameters.present == true) then
if (getPlayerStorageValue(cid, PRESENT_STORAGE) < 1) then
local item = {}
local reward = 0
local count = ""
for i = 1, #random_items do
item = random_items[i]
if (math.random(0,999) < item[1]) then
reward = item[2]
subType = item[3]
if subType > 1 then
count = subType .. " "
end
break
end
end
doPlayerAddItem(cid, reward, subType)
setPlayerStorageValue(cid, PRESENT_STORAGE, 1)
npcHandler:say('HO HO HO! You were good like a little dwarf this year! I got ' .. count .. getItemName(reward) .. ' for you.', cid)
else
npcHandler:say('I gave you a present already.', cid)
end
else
npcHandler:say('Come back when you start behaving good.', cid)
end
npcHandler:resetNpc()
return true
end
npcHandler:setMessage(MESSAGE_GREET, "Merry Christmas |PLAYERNAME|. I'm Santa Claus. I got presents for good children.")
local noNode = KeywordNode:new({'no'}, santaNPC, {present = false})
local yesNode = KeywordNode:new({'yes'}, santaNPC, {present = true})
local node = keywordHandler:addKeyword({'pre'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Were you good this year?'})
node:addChildKeywordNode(yesNode)
node:addChildKeywordNode(noNode)
npcHandler:addModule(FocusModule:new())
Can you help me ?