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 function onGreet_Callback(cid)
local npc = Npc()
local player = Player(cid)...
I would like to know if it is possible a check to put in a npc that he only spoke to whoever was invited in the house I tried several things more without success
Try this out:I would like to know if it is possible a check to put in a npc that he only spoke to whoever was invited in the house I tried several things more without success
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 house_id = 1 -- SET HOUSE ID HERE
local function onGreet_Callback(cid)
local player = Player(cid)
local access_list = House(house_id):getAccessList(GUEST_LIST)
if access_list and access_list:find(player:getName()) then
npcHandler:say("Go away.", cid)
npcHandler:releaseFocus(cid)
npcHandler:resetNpc(cid)
return false
else
npcHandler:setMessage(MESSAGE_GREET, "Hello.")
end
return true
end
local function onSay_Callback(cid, type, msg)
if not npcHandler:isFocused(cid) then
return false
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, onSay_Callback)
npcHandler:setCallback(CALLBACK_GREET, onGreet_Callback)
npcHandler:addModule(FocusModule:new())
Realized I did this backwards lol. Here's the fix:I would like to know if it is possible a check to put in a npc that he only spoke to whoever was invited in the house I tried several things more without success
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 house_id = 1 -- SET HOUSE ID HERE
local function onGreet_Callback(cid)
local player = Player(cid)
local access_list = House(house_id):getAccessList(GUEST_LIST)
if access_list and access_list:find(player:getName()) then
npcHandler:setMessage(MESSAGE_GREET, "Hello.")
else
npcHandler:say("Go away.", cid)
npcHandler:releaseFocus(cid)
npcHandler:resetNpc(cid)
return false
end
return true
end
local function onSay_Callback(cid, type, msg)
if not npcHandler:isFocused(cid) then
return false
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, onSay_Callback)
npcHandler:setCallback(CALLBACK_GREET, onGreet_Callback)
npcHandler:addModule(FocusModule:new())
Is it possible to do this for all houses?Realized I did this backwards lol. Here's the fix:
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 house_id = 1 -- SET HOUSE ID HERE local function onGreet_Callback(cid) local player = Player(cid) local access_list = House(house_id):getAccessList(GUEST_LIST) if access_list and access_list:find(player:getName()) then npcHandler:setMessage(MESSAGE_GREET, "Hello.") else npcHandler:say("Go away.", cid) npcHandler:releaseFocus(cid) npcHandler:resetNpc(cid) return false end return true end local function onSay_Callback(cid, type, msg) if not npcHandler:isFocused(cid) then return false end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, onSay_Callback) npcHandler:setCallback(CALLBACK_GREET, onGreet_Callback) npcHandler:addModule(FocusModule:new())
Is it possible to do this for all houses?
without needing to boot the id of each house
Is it possible to do this for all houses?
without needing to boot the id of each house
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 function onGreet_Callback(cid)
local npc = Npc()
local house_id = npc and getTileHouseInfo(npc:getPosition())
local access_list = house_id and House(house_id):getAccessList(GUEST_LIST)
if access_list and access_list:find(player:getName()) then
npcHandler:setMessage(MESSAGE_GREET, "Hello.")
else
npcHandler:say("Go away.", cid)
npcHandler:releaseFocus(cid)
npcHandler:resetNpc(cid)
return false
end
return true
end
local function onSay_Callback(cid, type, msg)
if not npcHandler:isFocused(cid) then
return false
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, onSay_Callback)
npcHandler:setCallback(CALLBACK_GREET, onGreet_Callback)
npcHandler:addModule(FocusModule:new())
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 function onGreet_Callback(cid) local npc = Npc() local house_id = npc and getTileHouseInfo(npc:getPosition()) local access_list = house_id and House(house_id):getAccessList(GUEST_LIST) if access_list and access_list:find(player:getName()) then npcHandler:setMessage(MESSAGE_GREET, "Hello.") else npcHandler:say("Go away.", cid) npcHandler:releaseFocus(cid) npcHandler:resetNpc(cid) return false end return true end local function onSay_Callback(cid, type, msg) if not npcHandler:isFocused(cid) then return false end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, onSay_Callback) npcHandler:setCallback(CALLBACK_GREET, onGreet_Callback) npcHandler:addModule(FocusModule:new())
2019-04-03 19:40:22 - Lua Script Error: [Npc interface]
2019-04-03 19:40:22 - data/npc/scripts/npclootmakert.lua:onCreatureSay
2019-04-03 19:40:22 - data/npc/scripts/npclootmakert.lua:14: attempt to index global 'player' (a nil value)
2019-04-03 19:40:22 - stack traceback:
2019-04-03 19:40:22 - [C]: in function '__index'
2019-04-03 19:40:22 - data/npc/scripts/npclootmakert.lua:14: in function 'callback'
2019-04-03 19:40:22 - data/npc/lib/npcsystem/npchandler.lua:354: in function 'greet'
2019-04-03 19:40:22 - data/npc/lib/npcsystem/npchandler.lua:544: in function 'onGreet'
2019-04-03 19:40:22 - data/npc/lib/npcsystem/modules.lua:324: in function 'callback'
2019-04-03 19:40:22 - data/npc/lib/npcsystem/keywordhandler.lua:31: in function 'processMessage'
2019-04-03 19:40:22 - data/npc/lib/npcsystem/keywordhandler.lua:186: in function 'processNodeMessage'
2019-04-03 19:40:22 - data/npc/lib/npcsystem/keywordhandler.lua:154: in function 'processMessage'
2019-04-03 19:40:22 - data/npc/lib/npcsystem/npchandler.lua:428: in function 'onCreatureSay'
2019-04-03 19:40:22 - data/npc/scripts/npclootmakert.lua:7: in function <data/npc/scripts/npclootmakert.lua:7>
local player = Player(cid)
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 function onGreet_Callback(cid)
local npc = Npc()
local player = Player(cid)
local house_id = npc and getTileHouseInfo(npc:getPosition())
local access_list = house_id and House(house_id):getAccessList(GUEST_LIST)
if access_list and access_list:find(player:getName()) then
npcHandler:setMessage(MESSAGE_GREET, "Hello.")
else
npcHandler:say("Go away.", cid)
npcHandler:releaseFocus(cid)
npcHandler:resetNpc(cid)
return false
end
return true
end
local function onSay_Callback(cid, type, msg)
if not npcHandler:isFocused(cid) then
return false
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, onSay_Callback)
npcHandler:setCallback(CALLBACK_GREET, onGreet_Callback)
npcHandler:addModule(FocusModule:new())
what occurs from what I saw is that he talks to everyone both the guest and the street playersSeems like missingLua:local player = Player(cid)
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 function onGreet_Callback(cid) local npc = Npc() local player = Player(cid) local house_id = npc and getTileHouseInfo(npc:getPosition()) local access_list = house_id and House(house_id):getAccessList(GUEST_LIST) if access_list and access_list:find(player:getName()) then npcHandler:setMessage(MESSAGE_GREET, "Hello.") else npcHandler:say("Go away.", cid) npcHandler:releaseFocus(cid) npcHandler:resetNpc(cid) return false end return true end local function onSay_Callback(cid, type, msg) if not npcHandler:isFocused(cid) then return false end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, onSay_Callback) npcHandler:setCallback(CALLBACK_GREET, onGreet_Callback) npcHandler:addModule(FocusModule:new())
I have no idea if this one will run tho, no way to test
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 function onGreet_Callback(cid)
local npc = Npc()
local player = Player(cid)
local tile = npc:getTile()
local house = tile:getHouse()
if house then
local access_list = house:getAccessList(GUEST_LIST)
if access_list and access_list:find(player:getName()) then
npcHandler:setMessage(MESSAGE_GREET, "Hello.")
else
npcHandler:say("Go away.", cid)
npcHandler:releaseFocus(cid)
npcHandler:resetNpc(cid)
return false
end
end
return true
end
local function onSay_Callback(cid, type, msg)
if not npcHandler:isFocused(cid) then
return false
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, onSay_Callback)
npcHandler:setCallback(CALLBACK_GREET, onGreet_Callback)
npcHandler:addModule(FocusModule:new())