What's new

[NPC] Poszukuje pewnej funkcji.

Status
Not open for further replies.

Erevius

Advanced User
Joined
Mar 15, 2009
Messages
150
Reaction score
10
Mam ju? skrypt NPC, lecz chcia?bym doda? pewn? funkcj?. Ot?? chc? aby NPC,
przy jednej odpowiedzi poprostu mnie zlekcewarzy?. Tzn. odszed? sobie
(zachowuje si? jakbym powiedzia? bye). Mo?liwe, ?e jest to co? zwi?zane
z "focus"em- czyli skupieniem. Da rad? tak zrobi??

Btw. mam tfsa 0.3.6
 

Oskar

Forum friend
Joined
Jan 24, 2009
Messages
2,256
Reaction score
331
Odp: [NPC] Poszukuje pewnej funkcji.

Oto funkcja:
PHP:
function NpcHandler:onWalkAway(cid)
		if(self:isFocused(cid)) then
			local callback = self:getCallback(CALLBACK_CREATURE_DISAPPEAR)
			if(callback == nil or callback()) then
				if(self:processModuleCallback(CALLBACK_CREATURE_DISAPPEAR, cid)) then
					if(self.queue == nil or not self.queue:greetNext()) then
						local msg = self:getMessage(MESSAGE_WALKAWAY)
						local parseInfo = { [TAG_PLAYERNAME] = getPlayerName(cid) }
						msg = self:parseMessage(msg, parseInfo)

						self:say(msg, cid)
						self:releaseFocus(cid)
						self:say(msg)
					end
				end
			end
		end
	end
Jest w ka?dym TFSie.
 

Erevius

Advanced User
Joined
Mar 15, 2009
Messages
150
Reaction score
10
Odp: [NPC] Poszukuje pewnej funkcji.

Chyba si? nie zrozumieli?my, chodzi?o mi o to co wstawi? do skryptu NPC'ka aby ten odszed? po pewniej odpowiedzi
 

Oskar

Forum friend
Joined
Jan 24, 2009
Messages
2,256
Reaction score
331
Odp: [NPC] Poszukuje pewnej funkcji.

PHP:
if msgcontains(msg, "m") then
	npcHandler:onPlayerCloseChannel(cid)
end
Lub, dla starszych silnik?w.
PHP:
if msgcontains(msg, "m") then
	npcHandler:onFarewell(cid)
end
Jeszcze jedn? znalaz?em:
PHP:
if msgcontains(msg, "m") then
	npcHandler:onWalkAway(cid)
end
 
Last edited:

Erevius

Advanced User
Joined
Mar 15, 2009
Messages
150
Reaction score
10
Odp: [NPC] Poszukuje pewnej funkcji.

Dzi?ki ci Oskar. Mam te? inne pytanie. Jak co zrobi? aby w tym skrypcie:
PHP:
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
	if msgcontains(msg, "knight") then
		if(getPlayerVocation(cid) == 0) then
			selfSay('This is one of your life decision and it\'s irreversible. Are you sure '.. getPlayerName(cid) ..'?', cid)
			talkState[talkUser] = 1
		else
			selfSay('Sorry. You already have a vocation, I can\'t help you right now.', cid)
			talkState[talkUser] = 0
		end
	elseif(msgcontains(msg, "no") and talkState[talkUser] == 1) then
		npcHandler:onFarewell(cid)
		talkState[talkUser] = 0
	elseif (msgcontains(msg, "yes") and talkState[talkUser] == 1) then
		selfSay("I ASK AGAIN, IS THAT YOUR FINAL DECISION?", cid)
		talkState[talkUser] = 2
	elseif(msgcontains(msg, "no") and talkState[talkUser] == 2) then
		npcHandler:onFarewell(cid)
		talkState[talkUser] = 0
	elseif(msgcontains(msg, "yes") and talkState[talkUser] == 2) then
		if(getPlayerVocation(cid) == 0) then
			doPlayerSetVocation(cid, 4)
			selfSay("Great! Now, you're one of us!", cid)
			talkState[talkUser] = 0
		end
	end
	return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Doda? Animacj? (nr 12) na playera gdy NPC mowi "Great! Now, you're one of us!"
(funkcja doSendMagicEffect bezpo?rednio do??czona do skryptu nie dzia?a)

#DOWN
Ju? sam znalaz?em i dzia?a mi funkcja "doSendMagicEffect(getThingPos(cid), 12)". Mo?e twoja te? ;p
 
Last edited:

Oskar

Forum friend
Joined
Jan 24, 2009
Messages
2,256
Reaction score
331
Odp: [NPC] Poszukuje pewnej funkcji.

Daj pod doPlayerSetVocation
PHP:
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_BLUE)
 
Status
Not open for further replies.
Top