I have this script, and npc is bugging...
This npc must allow only certain level players to do this quest how many times they want, but once after allowed level or before, npc won't accept player...
Also,
When player receive exp. it should show in red letter that player received the points...
When I have a player who have above level 15 or under level 10 npc reacts fine, but if player is under allowed level, npc just dont respond nothing and console show error.
TFS Versions: 0.3.5 Crying Damson.
Here is the error:
[17/11/2009 20:24:30] Lua Script Error: [Npc interface]
[17/11/2009 20:24:30] data/npc/scripts/testandoquest.luanCreatureSay
[17/11/2009 20:24:30] data/npc/scripts/testandoquest.lua:1: attempt to index global 'Topic' (a nil value)
[17/11/2009 20:24:30] stack traceback:
[17/11/2009 20:24:30] data/npc/scripts/testandoquest.lua:1: in function 'callback'
[17/11/2009 20:24:30] data/npc/lib/npcsystem/npchandler.lua:333: in function 'greet'
[17/11/2009 20:24:30] data/npc/lib/npcsystem/npchandler.lua:499: in function 'onGreet'
[17/11/2009 20:24:30] data/npc/lib/npcsystem/modules.lua:224: in function 'callback'
[17/11/2009 20:24:30] data/npc/lib/npcsystem/keywordhandler.lua:40: in function 'processMessage'
[17/11/2009 20:24:30] data/npc/lib/npcsystem/keywordhandler.lua:168: in function 'processNodeMessage'
[17/11/2009 20:24:30] data/npc/lib/npcsystem/keywordhandler.lua:128: in function 'processMessage'
[17/11/2009 20:24:30] data/npc/lib/npcsystem/npchandler.lua:380: in function 'onCreatureSay'
[17/11/2009 20:24:30] data/npc/scripts/testandoquest.lua:1: in function <data/npc/scripts/testandoquest.lua:1>
And here follow the script:
Hope someone help me to fix...
I will be rep++ for any help
This npc must allow only certain level players to do this quest how many times they want, but once after allowed level or before, npc won't accept player...
Also,
When player receive exp. it should show in red letter that player received the points...
When I have a player who have above level 15 or under level 10 npc reacts fine, but if player is under allowed level, npc just dont respond nothing and console show error.
TFS Versions: 0.3.5 Crying Damson.
Here is the error:
[17/11/2009 20:24:30] Lua Script Error: [Npc interface]
[17/11/2009 20:24:30] data/npc/scripts/testandoquest.luanCreatureSay
[17/11/2009 20:24:30] data/npc/scripts/testandoquest.lua:1: attempt to index global 'Topic' (a nil value)
[17/11/2009 20:24:30] stack traceback:
[17/11/2009 20:24:30] data/npc/scripts/testandoquest.lua:1: in function 'callback'
[17/11/2009 20:24:30] data/npc/lib/npcsystem/npchandler.lua:333: in function 'greet'
[17/11/2009 20:24:30] data/npc/lib/npcsystem/npchandler.lua:499: in function 'onGreet'
[17/11/2009 20:24:30] data/npc/lib/npcsystem/modules.lua:224: in function 'callback'
[17/11/2009 20:24:30] data/npc/lib/npcsystem/keywordhandler.lua:40: in function 'processMessage'
[17/11/2009 20:24:30] data/npc/lib/npcsystem/keywordhandler.lua:168: in function 'processNodeMessage'
[17/11/2009 20:24:30] data/npc/lib/npcsystem/keywordhandler.lua:128: in function 'processMessage'
[17/11/2009 20:24:30] data/npc/lib/npcsystem/npchandler.lua:380: in function 'onCreatureSay'
[17/11/2009 20:24:30] data/npc/scripts/testandoquest.lua:1: in function <data/npc/scripts/testandoquest.lua:1>
And here follow the script:
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local tokenid = 2676
local storage = 5819
local sorrymessage = "Sorry, you don't have enough to share..."
local levelRange = {10, 15}
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 greetCallback(cid)
if getPlayerLevel(cid) < levelRange[1] then
npcHandler:say("I'm only recruiting players from level 10 to 15 to this task, come back after...", cid, TRUE)
elseif getPlayerLevel(cid) > levelRange[2] then
npcHandler:say("You are above level 15 maybe you got more importants things to do..." , cid, TRUE)
else
npcHandler:setMessage(MESSAGE_GREET, "Oh, hello, handsome! It's a pleasure to meet you |PLAYERNAME|.")
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
Topic[talkUser] = 0
return true
end
return false
end
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if msgcontains(msg, 'task') then
local getstorage = getPlayerStorageValue(cid, storage)
if getstorage == 3 then
npcHandler:say("I'm not hungry anymore.", cid)
talkState[talkUser] = 0
elseif getstorage < 3 then
npcHandler:say("Make days I don't eat nothing, could you bring me like five bananas? I will give you 100 experience points in return.", cid)
talkState[talkUser] = 1
end
elseif talkState[talkUser] == 1 then
if msgcontains(msg, 'yes') then
setPlayerStorageValue(cid, storage, 1)
if getstorage == 1 then
if doPlayerRemoveItem(cid, tokenid, 5) == TRUE then
setPlayerStorageValue(cid, storage, 2)
doPlayerAddExp(cid, 100)
doSendAnimatedText(getCreaturePosition(cid), "+100", TEXTCOLOR_WHITE_EXP)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You received 100 experience points.")
npcHandler:say("Here you have, 100 experience points. Thank you.", cid)
setPlayerStorageValue(cid, storage, 1)
else
npcHandler:say(sorrymessage, cid)
end
end
else
npcHandler:say("Ok then.", cid)
end
talkState[talkUser] = 0
end
return TRUE
end
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Hope someone help me to fix...
I will be rep++ for any help
Last edited: