Itutorial
Legendary OT User
- Joined
- Dec 23, 2014
- Messages
- 2,339
- Solutions
- 68
- Reaction score
- 1,024
It seems the CALLBACK_GREET doesn't work. The NPC just says the default message. This is the NPC file, I haven't modified anything in the npc lib or cpp files. I did check npchandler.lua and modles.lua and it looks correct to me.
***************************************************
The fix is return false at the end not return true
*****************************************************
Lua:
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
local storages = {
[1] = {msg = "|PLAYERNAME| did you visit the merchants?"
}
}
local talkState = {}
local key = 45000
function greetCallback(cid, message)
local player = Player(cid)
if not player then return false end
local pStorage = player:getStorageValue(key)
local storage = storages[pStorage]
if pStorage == -1 and not storage then
storage = storages[1]
end
npcHandler:say(storage.msg, cid)
return true
end
function creatureSayCallback(cid, type, msg)
if not npcHandler:isFocused(cid) then
return false
end
local player = Player(cid)
if not player then return false end
local pStorage = player:getStorageValue()
local storage = storages[player:getStorageValue()]
if pStorage == -1 and not storage then
storage = storages[1]
end
return true
end
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
***************************************************
The fix is return false at the end not return true
*****************************************************
Last edited: