• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Npc window

salty

New Member
Joined
Mar 20, 2013
Messages
14
Reaction score
0
Hey,
How do i change so when i say "hi" to my npc's, the NPCs window pops up with the response?

Example:
[Player]: Hi
-The NPCs channel/window pops up-
[NPC]: Welcome, Player! I have been expecting you.

//Thanks.
 
PHP:
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 shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
 

---
--Buy Items
---
 
shopModule:addBuyableItem({'Elven amulet'}, 2198, 500, 1, 'Elven amulet')
---
--Sell Items
---
shopModule:addSellableItem({'Elven amulet'}, 2198, 100, 'Elven amulet')


npcHandler:addModule(FocusModule:new())
 
Well it should work, hm its wierd.

Try this:
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 shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

--- 
--Buy Items 
--- 
  
shopModule:addBuyableItem({'Elven amulet'}, 2198, 500, 1, 'Elven amulet') 
--- 
--Sell Items 
--- 
shopModule:addSellableItem({'Elven amulet'}, 2198, 100, 'Elven amulet') 

npcHandler:addModule(FocusModule:new())
 
Last edited:
That gave me errors :s

[30/03/2013 20:54:58] Lua Script Error: [Npc interface]
[30/03/2013 20:54:58] data/npc/scripts/trader.lua
[30/03/2013 20:54:58] data/npc/scripts/trader.lua:14: attempt to index global 'shopModule' (a nil value)
[30/03/2013 20:54:58] stack traceback:
[30/03/2013 20:54:58] [C]: in function '__index'
[30/03/2013 20:54:58] data/npc/scripts/trader.lua:14: in main chunk
[30/03/2013 20:54:58] [Warning - NpcScript::NpcScript] Can not load script: data/npc/scripts/trader.lua
 
Well, idk what to say, its just wierd. You done any changes into the npc/libs or sources?
 
Nope, ill figure it out somehow. Thanks alot for trying tho :)
I got these other test npcs that do open it but not from the start.

Like this one opens it if you say "mount", but not when you say "hi".
LUA:
-- Npc A
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
 
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 creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false
	end
 
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	local storage = 9105 
 
	if(msgcontains(msg, 'mount')) then
		if(getPlayerStorageValue(cid, storage) == -1) then
			selfSay('Go visit npc B.', cid)
			setPlayerStorageValue(cid, storage, 1)
 
		elseif(getPlayerStorageValue(cid, storage) == 1) then
			selfSay('Already visited npc B? Haven\'t heard anything from him yet, please go visit him.', cid)
 
		elseif(getPlayerStorageValue(cid, storage) > 1) then
			selfSay('Npc B told me you were helping him, that is great.', cid)
		end
	end
	return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Im really new to this so.. :P
 
Then i think something is really wierd with you server :) Since it should open when you say hi.
 
Back
Top