• 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!

Insue with Npc System

Kayan

Active Member
Joined
Sep 19, 2007
Messages
1,561
Reaction score
38
Location
Santa Catarina
I don't know, this is bug of Tfs our problem with my npc

but i go post here...


I have other issue with NPC Sytem...


I have a NPC, him sell itens for gems,scarab coins and

others.

Example

I go buy a plate armor for 10 scarab coins

Npc say: Did you buy Plate armor for 10 scarab coins?

Me Say: Yes, "always i need repeat yes, much times for npc give reply"



Npc: Give me other item, but script are correct, other persons have this issue

This error is in tags and trunk

A example of My Npc

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
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
-- OTServ event handling functions end
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function creatureSayCallback(cid, type, msg)
	if(npcHandler.focus ~= cid) then
		return false
	end

		if msgcontains(msg, 'offer') then
			selfSay('I sell plate armor, blue robe. What\'s you need?')
			
			  --------------- Plate Armor ------------
		elseif msgcontains(msg, 'plate') then
			selfSay('Did you bring me 50 scarab coins, for a plate armor?')
			talk_state = 1
			
		elseif msgcontains(msg, 'yes') and talk_state == 1 then
			if getPlayerItemCount(cid,2159) >= 50 then
			if doPlayerTakeItem(cid,2159,50) == 0 then
			         selfSay('Here is your Plate Armor')
			doPlayerAddItem(cid,2463,1)
						talk_state = 0
					end
				
			else
				selfSay('Sorry, you don\'t have coins for buy this. Come back when you have them')
			end
			
                                       ----------- Blue Robe---------------
		elseif msgcontains(msg, 'blue') then 
					selfSay('Did you bring me 10 blue gem, for a blue robe?')
					talk_state = 2
					
		elseif msgcontains(msg, 'yes') and talk_state == 2 then
			if getPlayerItemCount(cid,2158) >= 10 then
			if doPlayerTakeItem(cid,2158,10) == 0 then
			        selfSay('Here is your Blue Robe')
			doPlayerAddItem(cid,2656,1)
						talk_state = 0
					end
				
			else
				selfSay('Sorry, you don\'t have gems for buy this. Come back when you have them')
			end
					---------------------------------------------------------------------------------------------------confirm no ----------------------------------------------------------------------------------------------------------------------------------------------
		elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 2) then
			selfSay('Ok. Next time.')
			talk_state = 0
		end
	-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
	return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Under:
selfSay('Sorry, you don\'t have coins for buy this. Come back when you have them')
Add:
talk_state = 0

Under:
selfSay('Sorry, you don\'t have gems for buy this. Come back when you have them')
Add:
talk_state = 0
 
Back
Top