What's new

[B]Prosta rozmowa z npc i moze skrypcik[/B]

Bronievka1

Active User
Joined
Nov 4, 2009
Messages
83
Reaction score
0
Witam!

Czy m?g?by mi kto? napisac mniej wiecej prost? rozmowe z npc i wyt?umaczyc na jakiej zasadzie dziala to ,?e je?eli powiemy jedn? rzecz odpowie nam inna( nigdy nie rozumialem tworzenia npckow ;/ ) ewt jaki? npc maker? ale tez bym prosi? o instrukcje bo jednego znalaz?em na forum ale chyba pod wy?sze wersje i nie wiedzia?em jak go u?yc.

Pytanie nr2!
M?g?by kto? napisac jak zrobic cos takiego:
npc z ktorym mozemy rozmawiac dopiero po zaakceptowaniu misji od innego npc czyli po prostu:

Player : Hi
Npc : kim jeste?? Widze, ?e nie przys?a? cie tu NPC2. Id? pierw do niego!

Pytanie NR 3!!! :D
czy m?g?by kto? napisac jak zrobic cos takiego by otrzymac klucz od npc lecz by by? dost?pny tylko raz w czasie wykonywania misji ( tu m?j plan by wydawa? go npc z pytania drugiego po rozmowie z innym npc)

Bardzo prosze o pomoc poniewaz nigdy nie interesowalem sie skryptowaniem bo by?em mapperem a npc to dla mnie czarna magia ;(

Edit: mo?e macie jakie? linki do poradnik?w o tworzeniu npc? by?bym wdzi?czny
Edit2: wiem jak napisac prosta rozmowe z npc lecz nie kumam nadal tego co w pytaniu 2 i 3
 

Bronievka1

Active User
Joined
Nov 4, 2009
Messages
83
Reaction score
0
Odp: Prosta rozmowa z npc i moze skrypcik

refresh! plus dodaje pytanie!
stworzy?em nowego npc lecz gdy chce go zrespic za pomoc? komendy wyskakuje mi w konsoli:
sadasdadi.jpg

oto kod xml
Code:
<?xml version="1.0"?>

<npc name="Neato" script="data/npc/scripts/neato.lua" access="1" lookdir="2" autowalk="25">
	<mana now="800" max="800"/>
	<health now="200" max="200"/>
<look type="134" head="114" body="113" legs="113" feet="113"/>
</npc>

neato.lua istnieje i ma dobry folder. Co jest przyczyna tego, ze to nie dziala
 
Last edited:

Bronievka1

Active User
Joined
Nov 4, 2009
Messages
83
Reaction score
0
Odp: Prosta rozmowa z npc i moze skrypcik

refresh...........................
 

Jastro

Senior User
Joined
Aug 18, 2009
Messages
727
Reaction score
101
Odp: Prosta rozmowa z npc i moze skrypcik

Emm.. widz? jakie? RPG si? szykuje xP
A b??d jest nie w Neato.xml tylko w Neato.lua ;)
Podaj mi kod z Lua, spr?buj? co? poradzi?.
 

Bronievka1

Active User
Joined
Nov 4, 2009
Messages
83
Reaction score
0
Odp: Prosta rozmowa z npc i moze skrypcik

PHP:
local focus = 0
local talk_start = 0
local target = 0
local following = false
local attacking = false

function onThingMove(creature, thing, oldpos, oldstackpos)

end


function onCreatureAppear(creature)

end


function onCreatureDisappear(cid, pos)
  	if focus == cid then
          selfSay('Good bye then.')
          focus = 0
          talk_start = 0
  	end
end


function onCreatureTurn(creature)

end

function msgcontains(txt, str)
  	return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end


function onCreatureSay(cid, type, msg)
  	msg = string.lower(msg)
end
  	if (msgcontains(msg, 'hi') and focus == 0) and getDistanceToCreature(cid) < 4 then
  		selfSay('o nie! ' .. getCreatureName(cid) .. '!Przyslal cie tu Zenek?!')
  		focus = cid
  		talk_start = os.clock()

  	elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
  		selfSay('Ty tez , ' .. getCreatureName(cid) .. '!? Porozmawiam z tob? za chwilke.')

  	elseif focus == cid then
		talk_start = os.clock()

	if msgcontains(msg, 'tak') or msgcontains(msg, 'yes') then
        selfSay('On sprowadza tu ludzi by ich zabic! Mozesz wyjsc teraz torami lub isc przez "pieklo". Pamietaj on nie przyzna sie do tego ze chcial cie zabic')  
if msgcontains(msg, 'pieklo') then
        selfSay('W piekle spotasz sie z niebezpiecznymi demonami i faraonami. Gdy pokonasz ostatniego z nich na koncu twej drogi znajdziesz "nagrode" i teleport przez ktory mozesz wyjsc')		
		if msgcontains(msg, 'nagrode') or msgcontains(msg, 'nagroda') then
        selfSay('po zabiciu ostatniego z faraonow znajdziesz skrzynke.')

     

		elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
			selfSay('Powodzenia, ' .. getCreatureName(cid) .. '!')
			focus = 0
			talk_start = 0
		end
  	end
end
		end

function onCreatureChangeOutfit(creature)
end



function onThink()
	if focus > 0 then 
		x, y, z = creatureGetPosition(focus)
		myx, myy, myz = selfGetPosition()
		
		if ((myy-y==0) and (myx-x<=0 and myx-x>=-4)) then
			selfTurn(1)
		end 
		if ((myy-y==0) and (myx-x>=0 and myx-x<=4)) then
			selfTurn(3)
		end
		if ((myx-x==0) and (myy-y<=0 and myy-y>=-4)) then
			selfTurn(2)
		end
		if ((myx-x==0) and (myy-y>=0 and myy-y<=4)) then
			selfTurn(0)
		end
		if ((myy-y==-2) and (myx-x>=-1 and myx-x<=1)) then
			selfTurn(2)
		end
		if ((myy-y==2) and (myx-x>=-1 and myx-x<=1)) then
			selfTurn(0)
		end
		if ((myx-x==2) and (myy-y>=-1 and myy-y<=1)) then
			selfTurn(3)
		end
		if ((myx-x==-2) and (myy-y>=-1 and myy-y<=1)) then
			selfTurn(1)
		end
		if ((myy-y==-3) and (myx-x>=-2 and myx-x<=2)) then
			selfTurn(2)
		end
		if ((myy-y==3) and (myx-x>=-2 and myx-x<=2)) then
			selfTurn(0)
		end
		if ((myx-x==3) and (myy-y>=-2 and myy-y<=2)) then
			selfTurn(3)
		end
		if ((myx-x==-3) and (myy-y>=-2 and myy-y<=2)) then
			selfTurn(1)
		end
		if ((myy-y==-4) and (myx-x>=-3 and myx-x<=3)) then
			selfTurn(2)
		end
		if ((myy-y==4) and (myx-x>=-3 and myx-x<=3)) then
			selfTurn(0)
		end
		if ((myx-x==4) and (myy-y>=-3 and myy-y<=3)) then
			selfTurn(3)
		end
		if ((myx-x==-4) and (myy-y>=-3 and myy-y<=3)) then
			selfTurn(1)
		end
	end
	
  	if (os.clock() - talk_start) > 30 then
  		if focus > 0 then
  			selfSay('Nie mam tyle czasu... Nastepny!')
  		end
 		focus = 0
  	end
 	if focus ~= 0 then
 		if getDistanceToCreature(focus) > 5 then
 			selfSay('Powodzenia! Nigdy juz nie rozmawiaj z Zenkiem')
 			focus = 0
 		end
 	end
end
nie znam sie na npc zbyt ale tak to napisa?em
 

Jastro

Senior User
Joined
Aug 18, 2009
Messages
727
Reaction score
101
Odp: Prosta rozmowa z npc i moze skrypcik

Sprawd?:
PHP:
local focus = 0
local talk_start = 0
local target = 0
local following = false
local attacking = false

function onThingMove(creature, thing, oldpos, oldstackpos)

end


function onCreatureAppear(creature)

end


function onCreatureDisappear(cid, pos)
  	if focus == cid then
          selfSay('Good bye then.')
          focus = 0
          talk_start = 0
  	end
end


function onCreatureTurn(creature)

end


function msgcontains(txt, str)
  	return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end


function onCreatureSay(cid, type, msg)
  	msg = string.lower(msg)

  	if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
  		selfSay('Elo, ' .. creatureGetName(cid) .. '! Ja sprzedaje ropes (50gp), shovels (20gp), backpacks (10gp), manafluids (100gp), Blessed Wooden Stake (6k), Obsidian Knife (10k), aol (10k),I SPRZEDAJE KURWA | BP MANAFLUIDS |(1k). Kupie vials (10gp).')
  		focus = cid
  		talk_start = os.clock()

  	elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
  		selfSay('Przepraszam, ' .. creatureGetName(cid) .. '! Rozmiawiam z toba juz minute.')

	elseif focus == cid then
		talk_start = os.clock()

		
    if msgcontains(msg, 'tak') or msgcontains(msg, 'yes') then 
        selfSay('On sprowadza tu ludzi by ich zabic! Mozesz wyjsc teraz torami lub isc przez "pieklo". Pamietaj on nie przyzna sie do tego ze chcial cie zabic')  
		elseif msgcontains(msg, 'pieklo') then 
        selfSay('W piekle spotkasz sie z niebezpiecznymi demonami i faraonami. Gdy pokonasz ostatniego z nich na koncu twej drogi znajdziesz "nagrode" i teleport przez ktory mozesz wyjsc')

        elseif msgcontains(msg, 'nagrode') or msgcontains(msg, 'nagroda') then 
        selfSay('po zabiciu ostatniego z faraonow znajdziesz skrzynke.') 


		elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
			selfSay('Powodzenia ' .. creatureGetName(cid) .. '!')
			focus = 0
			talk_start = 0
		end
	end
end


function onCreatureChangeOutfit(creature)

end


function onThink()
  	if (os.clock() - talk_start) > 30 then
  		if focus > 0 then
  			selfSay('Nie mam tyle czasu... Nastepny!')
  		end
  			focus = 0
  	end
 	if focus ~= 0 then
 		if getDistanceToCreature(focus) > 5 then
 			selfSay('Powodzenia! Nigdy juz nie rozmawiaj z Zenkiem!')
 			focus = 0
 		end
 	end
end
 

Bronievka1

Active User
Joined
Nov 4, 2009
Messages
83
Reaction score
0
Odp: Prosta rozmowa z npc i moze skrypcik

dzi?ki wielkie! :)
Ju? dzia?a. Mo?esz poda? co napisane by?o ?le? xd. Bo chyba bra?e? z innego npc i podmienia?e? teksty bo jeden by? nie zmieniony ;p
Repucik leci :)
 

Jastro

Senior User
Joined
Aug 18, 2009
Messages
727
Reaction score
101
Odp: Prosta rozmowa z npc i moze skrypcik

Mia?e? wsz?dzie "if".
If stosujemy tylko na pocz?tku, potem "elseif".
PHP:
if msgcontains(msg, 'tak') or msgcontains(msg, 'yes') then  
        selfSay('On sprowadza tu ludzi by ich zabic! Mozesz wyjsc teraz torami lub isc przez "pieklo". Pamietaj on nie przyzna sie do tego ze chcial cie zabic')   
        elseif msgcontains(msg, 'pieklo') then  
        selfSay('W piekle spotkasz sie z niebezpiecznymi demonami i faraonami. Gdy pokonasz ostatniego z nich na koncu twej drogi znajdziesz "nagrode" i teleport przez ktory mozesz wyjsc')
:)
 

Bronievka1

Active User
Joined
Nov 4, 2009
Messages
83
Reaction score
0
Odp: Prosta rozmowa z npc i moze skrypcik

oo dzi?ki
Jestem nowicjusz przy zabawie z robieniem tego bo zawsze mappowa?em wi?c ta informacja mi si? przyda ; >
 
Top