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

Need small fix to my NPC

Sopelek

New Member
Joined
Jan 4, 2009
Messages
46
Reaction score
0
Hello everyone, I've made Npc to quest like 'brotherhood outfit quest' I don't know it's good but, when tfs loading, no errors, when i summon npc no errors, but when i say to him HI, he walking like idiot and don't answer me, Can anyone who know how repair it, do this?
NPC script : Questoutfit.lua
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

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, 'outfit') then
	if getPlayerStorageValue(cid, 67865) == -1 then
		        npcHandler:say('I can give you Brotherhood or Nightmare outfit, it is your choice which one you want.', cid)
		        talkState[talkUser] = 1
         elseif getPlayerStorageValue(cid, 67867) == 1 then
                npcHandler:say('Oh you choose Brotherhood?', cid)
                talkState[talkUser] = 2
        elseif getPlayerStorageValue(cid, 67866) == 1 then
                npcHandler:say('You already choosen outfit, and got present. It is all what you can do for me.', cid)
                talkState[talkUser] = 3
        end
        
    elseif talkState[talkUser] == 1 then
        if msgcontains(msg, 'Brotherhood') then
		if getPlayerStorageValue(cid, 67866) == 1 then
				npcHandler:say('You already choosen Nightmare, You can not have brotherhood and nightmare at once. Good bye', cid)
				else
                npcHandler:say('You go to good side of power, i have present for you', cid)
                doPlayerAddItem(cid,8980,1)
                setPlayerStorageValue(cid,67867,1)
                talkState[talkUser] = 2
				end
                else
                selfSay('You already have the present and outfit', cid)
				end
	   
    elseif talkState[talkUser] == 2 then
        if msgcontains(msg, 'Nightmare') then
		       if getPlayerStorageValue(cid, 67867) == 1 then
				npcHandler:say('You already choosen Brotherhood, You can not have nightmare and brotherhood at once. Good bye', cid)
				else
				npcHandler:say('You go to evil side of power, i have present for you', cid)
	            doPlayerAddItem(cid,8980,1)
                setPlayerStorageValue(cid,67866,1)
                talkState[talkUser] = 3
				end
                else
                npcHandler:say('You alreade have the present and outfit', cid)
            end
			end
			end

FutureCloser.XML
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="FutureCloser" script="outfitquest.lua" walkinterval="2000" floorchange="0">
	<health now="100" max="100"/>
	<look type="132" head="58" body="114" legs="78" feet="0" addons="1"/>
	<parameters>
		<parameter key="message_greet" value="Welcome, |PLAYERNAME|! Say {outfit} and I can give you, question, it's very important choice for you."/>
	</parameters>
</npc>

I'm using TFS 0.3.5 crying damson.
 
Very easy...
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

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, 'outfit') then
		if getPlayerStorageValue(cid, 67865) == -1 then
			npcHandler:say('I can give you Brotherhood or Nightmare outfit, it is your choice which one you want.', cid)
			talkState[talkUser] = 1
		elseif getPlayerStorageValue(cid, 67867) == 1 then
			npcHandler:say('Oh you choose Brotherhood?', cid)
			talkState[talkUser] = 2
		elseif getPlayerStorageValue(cid, 67866) == 1 then
			npcHandler:say('You already choosen outfit, and got present. It is all what you can do for me.', cid)
			talkState[talkUser] = 3
		end

	elseif talkState[talkUser] == 1 then
		if msgcontains(msg, 'Brotherhood') then
			if getPlayerStorageValue(cid, 67866) == 1 then
				npcHandler:say('You already choosen Nightmare, You can not have brotherhood and nightmare at once. Good bye', cid)
			else
				npcHandler:say('You go to good side of power, I have present for you', cid)
				doPlayerAddItem(cid,8980,1)
				setPlayerStorageValue(cid,67867,1)
				talkState[talkUser] = 2
			end
		else
			npcHandler:say('You already have the present and outfit', cid)
		end

	elseif talkState[talkUser] == 2 then
		if msgcontains(msg, 'Nightmare') then
			if getPlayerStorageValue(cid, 67867) == 1 then
				npcHandler:say('You already choosen Brotherhood, You can not have nightmare and brotherhood at once. Good bye', cid)
			else
				npcHandler:say('You go to evil side of power, I have present for you', cid)
				doPlayerAddItem(cid,8980,1)
				setPlayerStorageValue(cid,67866,1)
				talkState[talkUser] = 3
			end
		else
			npcHandler:say('You alreade have the present and outfit', cid)
		end
	end
	return TRUE
end
						
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Back
Top