• 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 - No Response

Ecstacy

Mothafuckaaa
Joined
Dec 26, 2008
Messages
3,836
Reaction score
108
Location
The Netherlands
Hey, I'm having some problems with this NPC.
When I say 'hi' it doesn't response :(.

the script is meant for TFS 0.4.

LUA:
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

local t = {
	[1] = {x=1,y=1,z=7},
	[2] = {x=1,y=1,z=7},
	[3] = {x=1,y=1,z=7}
	}
	
function giveAbility(cid, msg, keywords, parameters, node)
	if(not npcHandler:isFocused(cid)) then
		return false
	end

	local v,b = getPlayerStorageValue(cid,1889,0)
	if v == 0 then
		if msgcontains(msg:lower(),'yes') then
			npcHandler:say('Great! I\'ve been working on a way to get out of here and after studying the art of magic, I have learned a teleport spell! I can only teleport others though... Are you willing to be teleported away from this place?',cid)
			b = 1
			setPlayerStorageValue(cid,1889,b)
		else
			npcHandler:say('Then may you burn in hell, demon!',cid)
			b = 0
			setPlayerStorageValue(cid,1889,b)
			npcHandler:releaseFocus(cid)
		end
	elseif v == 1 then
		if msgcontains(msg:lower(),'yes') then
			npcHandler:say('Great, but first I will need to gather some information from you. Are you ready?',cid)
			b = 2
			setPlayerStorageValue(cid,1889,b)
		else
			npcHandler:say('Come back when you are ready.',cid)
			b = 0
			setPlayerStorageValue(cid,1889,b)
			npcHandler:releaseFocus(cid)
		end
	elseif v == 2 then
		if msgcontains(msg:lower(),'yes') then
			npcHandler:say('What special ability do you wish to have from these three, The ability to eat from a {corpse}, the ability to {tame} certain monsters or the ability to {brew} potions?',cid)
			b = 3
			setPlayerStorageValue(cid,1889,b)
		else
			npcHandler:say('Come back when you are ready!',cid)
			b = 0
			setPlayerStorageValue(cid,1889,b)
			npcHandler:releaseFocus(cid)
		end
	elseif v == 3 then
		if msgcontains(msg:lower(),'corpse') then
			npcHandler:say('Alright, so you are a barbarian, are you ready for your lesson to eat your first corpse?',cid)
			setPlayerStorageValue(cid,ABILITY_EAT_CORPSE,1)
			b = 4
			setPlayerStorageValue(cid,1889,b)
		elseif msgcontains(msg:lower(),'tame') then
			npcHandler:say('Alright, so you are a hunter, are you ready for your lesson to tame your first monster?',cid)
			setPlayerStorageValue(cid,ABILITY_TAME_MONSTER,1)
			b = 5
			setPlayerStorageValue(cid,1889,b)
		elseif msgcontains(msg:lower(),'brew') then
			npcHandler:say('Alright, so you are a magician, are you ready for your lesson to brew your first potion(s)?',cid)
			setPlayerStorageValue(cid,ABILITY_BREW_POTIONS,1)
			b = 6
			setPlayerStorageValue(cid,1889,b)
		else
			npcHandler:say('Sorry, you must choose between the three given abilities, try again',cid)
			b = 3
			setPlayerStorageValue(cid,1889,b)
		end
	elseif v == 4 then
		if msgcontains(msg:lower(),'yes') then
			npcHandler:say('Good luck in the future, brave barbarian!',cid)
			doTeleportThing(cid,t[1])
			b = 0
			setPlayerStorageValue(cid,1889,b)
		else
			npcHandler:say('Come back when you are ready!',cid)
			b = 0
			setPlayerStorageValue(cid,1889,b)
			npcHandler:releaseFocus(cid)
		end
	elseif v == 5 then
		if msgcontains(msg:lower(),'yes') then
			npcHandler:say('Good luck in the future, brave hunter!',cid)
			doTeleportThing(cid,t[2])
			b = 0
			setPlayerStorageValue(cid,1889,b)
		else
			npcHandler:say('Come back when you are ready!',cid)
			b = 0
			setPlayerStorageValue(cid,1889,b)
			npcHandler:releaseFocus(cid)
		end
	elseif v == 6 then
		if msgcontains(msg:lower(),'yes') then
			npcHandler:say('Good luck in the future, brave magician!',cid)
			doTeleportThing(cid,t[3])
			b = 0
			setPlayerStorageValue(cid,1889,b)
		else
			npcHandler:say('Come back when you are ready!',cid)
			b = 0
			setPlayerStorageValue(cid,1889,b)
			npcHandler:releaseFocus(cid)
		end
	end
	return true
end

There are no errors given or anything.

Thanks in advance,
unknown666
 
Last edited:
I dont know how on 0.4, but on 0.3 with Jiddo (default) npc system you have to define what function is callback for messages to make it work (paste it below function 'end'):
PHP:
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, giveAbility)
and at end of every NPC script is (it make NPC add/remove focuses = response for hi/bye):
PHP:
npcHandler:addModule(FocusModule:new())
 
Back
Top