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

Jak to jest z tymi NPC???

Kurczok

Newbie
Joined
Oct 22, 2009
Messages
497
Reaction score
4
Witam chciałem się was zapytać jak to jest z tymi npc ponieważ mam 2 npc 1 działa poprawnie 2 nie.

Domyślam się że pierwszy npc kiedyś działał ponieważ jest to npc Gesiora a teraz rozmowa zatrzymuje się po "Hi"

Code:
21:35 Mistrz Asasynow: Witaj Pall. Chcesz sie nauczyc czegos nowego? Tak?
21:35 Pall [62]: tak
I koniec rozmowy.

Nie besztajcie że noob czy coś bo nigdy w życiu nie bawiłem się npc zawsze jakoś obchodziło się bez npc.


pierwszynpc.lua (nie działa)
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

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(npcHandler.focus ~= cid) then
		return false
	end
	msg = string.lower(msg)
	if (talk_state ~= 1 and talk_state ~= 2) and (msgcontains(msg, 'ta') or msgcontains(msg, 'quest') or msgcontains(msg, 'profesj')) then
		talk_state = 0
		if getPlayerVocation(cid) == 7 then
			if getPlayerStorageValue(cid,91003) < 1 then
				selfSay('Chcialbys zostac Asasynem? Tak?')
				talk_state = 1
			elseif getPlayerStorageValue(cid,91003) == 1 then
				selfSay('Masz dla mnie 5 red dragon scale i 10 green dragon scale? Tak?')
				talk_state = 1
			elseif getPlayerStorageValue(cid,91003) == 2 then
				selfSay('Masz dla mnie 5 red dragon leathers i 10 green dragon leathers? Tak?')
				talk_state = 1
			elseif getPlayerStorageValue(cid,91003) == 3 then
				selfSay('Masz dla mnie 10 giant spider silk? Tak?')
				talk_state = 1
			end
		elseif getPlayerVocation(cid) ~= 13 then
			selfSay('Cwicze tylko z celnymi lucznikami.')
			talk_state = 0
		else
			selfSay('Nie moge juz ciebie nauczyc nic nowego.')
			talk_state = 0
		end
	elseif msgcontains(msg, 'assassin star') then
		selfSay('Nie rozmawiam z ludzmi na ten temat.')
		talk_state = 0
	elseif msgcontains(msg, 'azazin') then
		selfSay('Azazin 100, erok 1000 gp, Efruk?')
		talk_state = 2
	elseif talk_state == 2 and (msgcontains(msg, 'ta') or msgcontains(msg, 'yes') or msgcontains(msg, 'assassin star')) then
		selfSay('Nie rozmawiam z ludzmi na ten temat.')
		talk_state = 0
	elseif talk_state == 2 and msgcontains(msg, 'efruk') then
		if getPlayerVocation(cid) == 13 then
			if doPlayerRemoveMoney(cid, 1000) == TRUE then
				doPlayerAddItem(cid, 7368, 100)
				selfSay('100 azazin fur tr.')
			else
				selfSay('No erok, no azazin fur tr.')
			end
		else
			selfSay('Azazin feruk azazin 100.')
		end
		talk_state = 0
	elseif talk_state == 1 then
		talk_state = 0
		if getPlayerStorageValue(cid,91003) < 1 then
			if msgcontains(msg, 'ta') or msgcontains(msg, 'yes') then
				selfSay('Kazdy prawdziwy asasyn musi potrafic zabijac smoki. Przynies mi 5 red dragon scale i 10 green dragon scale.')
				setPlayerStorageValue(cid,91003,1)
			else
				selfSay('Zajmuje sie tylko treningiem lucznikow. Jesli nie chcesz cwiczyc to nie mamy o czym gadac.')
			end
		elseif getPlayerStorageValue(cid,91003) == 1 then
			if msgcontains(msg, 'ta') or msgcontains(msg, 'yes') then
				if getPlayerItemCount(cid,5920) >= 10 and getPlayerItemCount(cid,5882) >= 5 then 
					if doPlayerRemoveItem(cid,5920,10) == 1 and doPlayerRemoveItem(cid,5882,5) == 1 then
						setPlayerStorageValue(cid,91003,2)
						selfSay('Wykazales sie umiejetnosciami walki. Teraz przynies mi 5 red dragon leathers i 10 green dragon leathers.')
					end
				else
					selfSay('Przyjdz jak bedziesz mial 5 red dragon scale i 10 green dragon scale. Nie zawracaj mi glowy bez powodu.')
				end
			else
				selfSay('Nie? To na co jeszcze czekasz? Idz zbierac. Inaczej nigdy nie zostaniesz asasynem.')
			end
		elseif getPlayerStorageValue(cid,91003) == 2 then
			if msgcontains(msg, 'ta') or msgcontains(msg, 'yes') then
				if getPlayerItemCount(cid,5877) >= 10 and getPlayerItemCount(cid,5948) >= 5 then 
					if doPlayerRemoveItem(cid,5877,10) == 1 and doPlayerRemoveItem(cid,5948,5) == 1 then
						setPlayerStorageValue(cid,91003,3)
						selfSay('Niezle sobie radzisz z smokami. Teraz przynies mi 10 giant spider silk.')
					end
				else
					selfSay('Przyjdz jak bedziesz mial 5 red dragon leathers i 10 green dragon leathers.')
				end
			else
				selfSay('Nie? To na co jeszcze czekasz? Idz zbierac. Inaczej nigdy nie zostaniesz asasynem.')
			end
		elseif getPlayerStorageValue(cid,91003) == 3 then
			if msgcontains(msg, 'ta') or msgcontains(msg, 'yes') then
				if getPlayerItemCount(cid,5879) >= 10 then 
					if doPlayerRemoveItem(cid,5879,10) == 1 then
						setPlayerStorageValue(cid,91003,4)
						doPlayerSetVocation(cid, 13)
						doPlayerAddOutfit(cid, 156, 1)
						doPlayerAddOutfit(cid, 152, 1)
						doPlayerAddOutfit(cid, 156, 2)
						doPlayerAddOutfit(cid, 152, 2)
						selfSay('Wykazales sie wyjatkowymi umiejetnosciami walki. Mozesz stac sie jednym z nas. Asasynem! Od tej pory mozesz nosic nas stroj.')
					end
				else
					selfSay('Przyjdz jak bedziesz mial 10 giant spider silk.')
				end
			else
				selfSay('Nie? To na co jeszcze czekasz? Idz zbierac. Inaczej nigdy nie zostaniesz asasynem.')
			end
		end
	end
end
--tu sie koncze skrypt NPCa
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())


druginpc.lua (działa)

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 tokenid = 2422
        local storage = 99088
        local getstorage = getPlayerStorageValue(cid, storage)
        local sorrymessage = "Sry Ale nie masz tych itemow."
        local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
        if msgcontains(msg, 'misja') then
                if getstorage == 1 then
                        npcHandler:say("Juz Wykonales ta Misje.", cid)
                elseif getstorage < 1 then
                        npcHandler:say("Przyniosles Mi 5x Knight Armor and 5x Iron Ore and Iron Hammer?.?", cid)
                        talkState[talkUser] = 1
                end
        elseif msgcontains(msg, 'Remove This shit if you want!') then
                if getstorage < 1 then
                        npcHandler:say("Nie masz dla mnie tych itemow idz czym predzej Zbierac.", cid)
                elseif getstorage == 1 then
                        npcHandler:say("Juz Ci Dalem Noserman Addony !!.", cid)
                end
        elseif msgcontains(msg, 'yes') then
                if talkState[talkUser] == 1 then
                        if getstorage < 0 then
                                if doPlayerRemoveItem(cid, 2422, 1) == TRUE then
                                        npcHandler:say("Dzieki teraz Mozesz przechodzic przez most'.", cid)
                                        setPlayerStorageValue(cid, storage, 1)
                                        doPlayerRemoveItem(cid, 2476, 1)
                                        doPlayerRemoveItem(cid, 2422, 1)
                                        doPlayerRemoveItem(cid, 5880, 5)
										doSendMagicEffect(getCreaturePosition(cid), 13)
										doPlayerAddOutfit(cid, 251, 1)
										doPlayerAddOutfit(cid, 252, 1)
										doPlayerAddOutfit(cid, 251, 2)
										doPlayerAddOutfit(cid, 252, 2)
                                        talkState[talkUser] = 0
                                elseif doPlayerRemoveItem(cid, tokenid, 1) == FALSE then
                                        npcHandler:say(sorrymessage, cid)
                                        talkState[talkUser] = 0
                                end
                        end
                end
        elseif(msgcontains(msg, 'no') and talkState[talkUser] == 1) then
                npcHandler:say("Nie masz itemow to nie przeszkadzaj mi musze pilnowac przejscia", cid)
                talkState[talkUser] = 0
        end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
A coś dokładniej? Mówiłem że słabo orientuje się w npc.
Co dokładniej z talkstate?
 
Chodzi mu o to, że:
To nie jest talk_state tylko talkstate
Popraw xD

Edit:
Edit był zły xD
 
Zmieniłem talk_state na talkState[talkUser]
dodalem
Code:
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
i
Code:
local talkState = {}
i nadal nic.

Jeśli w ogóle o to chodziło.
 
A sprawdź tylko bez "_". Bez żadnego odnoszenia się do local itp itd.
Bo talkstate(costam costam) odnosi sie do costam costam xD
Czy do czegostam czegostam xDD

"_" wyglada jak jakaś mina(czytaj wyraz twarzy ) ale chodzi mi o _ xD
 
A może:
Code:
function creatureSayCallback(cid, type, msg)
        if(not npcHandler:isFocused(cid)) then
                return false
Zamiast:
Code:
function creatureSayCallback(cid, type, msg)
        if(npcHandler.focus ~= cid) then
                return false

Moja metoda opiera się na wykluczaniu wszystkiego xD
Bo skoro pierwszy nie działa a drugi tak to coś w pierwszym jest rozjebane a podstawy muszą być zawarte xD
 
@Your Master
Bardzo dobra metoda, widzę że podobnie myślimy bo wpadłem na to samo przed tym jak napisałeś.

Teraz działa dobrze.

Jak będę mógł to dam rep+
 
Why wypowiadasz się skoro nie masz pojęcia o czym mówisz?

Mogę napisać "ta", "tak" czy "tarnobrzeg" i też będzie działało.
 
Back
Top