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

Problem with NPC.

Tenshinkhan

New Member
Joined
Nov 9, 2009
Messages
4
Reaction score
1
Hey,
Ihave problem with NPC. After he gets an item from player he don't teleport him. There is no errors in engine. I'm using TFS 0.3.5 tibia 8.5

Code:
 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
    if msgcontains(msg, 'help') then
        selfSay('Mozesz z tad wyjsc jesli masz kupon na wyjscie')
    elseif msgcontains(msg, 'kupon') then
        if getPlayerItemCount(cid,5809) >= 1 then
            selfSay('Czy przynisoles mi kupon?')
            talk_state = 1
        else
            selfSay('Potrzebuje kuponu by pozwolic Ci z tad szybciej wyjsc. Wroc jak bedziesz mial kupon')
            talk_state = 0
        end
        elseif msgcontains(msg, 'tak') and talk_state == 1 then
            talk_state = 0
        if getPlayerItemCount(cid,5809) >= 1 then 
		if
             doPlayerRemoveItem(cid,5809, 1) == 1 then
			              doTeleportThing(cid,{x=999, y=1001, z=7})
			  doSendMagicEffect(pos, 37)
			  
                selfSay('Czekam na ponowne spotkanie.')
				else
   return 0
end

return 1

            end
              
    elseif msgcontains(msg, 'nie') and talk_state == 1 then
            selfSay('Jak uwazasz. Milego siedzenia.')
            talk_state = 0
    end
    return 1
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Else. How to make him to write in "npc channel" because he write only messages like "17:38 Klawisz: Welcome, Lol! I have been expecting you.". Not this what i made in script.

Waiting for help ;D
 
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local Topic = {}
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
	if msgcontains(msg, "help") then
		npcHandler:say("Mozesz z tad wyjsc jesli masz kupon na wyjscie.", cid)
		Topic[cid] = 0
	elseif msgcontains(msg, "kupon") then
		local v = getPlayerItemCount(cid, 5809) > 0
		npcHandler:say(v and "Czy przynisoles mi kupon?" or "Potrzebuje kuponu by pozwolic Ci z tad szybciej wyjsc. Wroc jak bedziesz mial kupon.", cid)
		Topic[cid] = v and 1 or 0
	elseif msgcontains(msg, "tak") and Topic[cid] == 1 and doPlayerRemoveItem(cid, 5809, 1) == TRUE then
		npcHandler:say("Czekam na ponowne spotkanie.", cid)
		Topic[cid] = 0
		npcHandler:releaseFocus(cid)
		doTeleportThing(cid, {x=999, y=1001, z=7})
		doSendMagicEffect({x=999, y=1001, z=7}, 37)			
	elseif msgcontains(msg, "nie") and Topic[cid] == 1 then
		npcHandler:say("Jak uwazasz. Milego siedzenia.", cid)
		Topic[cid] = 0
	end
	return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Back
Top