• logo_cipsoft
    Nowe serwery zostały otwarte 19 Lut 2025:
    Noctalia (Open PvP) Ignitera (Open PvP) us_logo Xybra (Open PvP)

NPC The Oracle Angielsko-Polski

Status
Zamknięty.

Mikix95

Advanced User
Dołączył
Listopad 3, 2009
Posty
169
Liczba reakcji
6
Witam, ostatnio szuka?em dla siebie takiego NPC. Ot?? chcia?em, by mo?na by?o m?wi? do niego zar?wno po angielsku jak i po polsku. Niestety zawiod?em si?, poniewa? go nie znalaz?em, wi?c sam musia?em przerobi? NPC. Oto on:
xxx\data\npc\scripts\oracle.lua
Kod:
focus = 0
talk_start = 0
target = 0
following = false
attacking = false
talk_state = 0
cname = ''
vocation = 0
mainlevel = 8
function onThingMove(creature, thing, oldpos, oldstackpos)
end
function onCreatureAppear(creature)
end
function onCreatureDisappear(cid, pos)
  	if focus == cid then
          selfSay('Good bye then. / Zegnaj.')
          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)
  	cname = creatureGetName(cid)
	msg = string.lower(msg)
  	if (msgcontains(msg, 'hi') or string.find(msg, '(%a*)siema(%a*)') or string.find(msg, '(%a*)witam(%a*)') or string.find(msg, '(%a*)hello(%a*)') or string.find(msg, '(%a*)czesc(%a*)') or string.find(msg, '(%a*)yo(%a*)') or string.find(msg, '(%a*)elo(%a*)') or string.find(msg, '(%a*)cze(%a*)') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
  		selfSay('Hello ' .. cname .. '! (Speak English or Polish) Are you ready to face your destiny? / Witaj ' .. cname .. '! (Mow po Angielsku lub Polsku) Czy jestes gotow stawic czola swojemu przeznaczeniu?')
  		talk_state = 0
  		focus = cid
  		talk_start = os.clock()
	elseif msgcontains(msg, 'hi') or string.find(msg, '(%a*)siema(%a*)') or string.find(msg, '(%a*)witam(%a*)') or string.find(msg, '(%a*)hello(%a*)') or string.find(msg, '(%a*)czesc(%a*)') or string.find(msg, '(%a*)yo(%a*)') or string.find(msg, '(%a*)elo(%a*)') or string.find(msg, '(%a*)cze(%a*)') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
  		selfSay('Sorry, ' .. cname .. '! I talk to you in a minute. / Przepraszam, ' .. cname .. '! Porozmawiamy za chwile.')
  	elseif msgcontains(msg, 'bye') or string.find(msg, '(%a*)zegnaj(%a*)') and focus == cid and getDistanceToCreature(cid) < 4 then
 		selfSay('Good bye, ' .. cname .. '! / Do zobaczenia, ' .. cname .. '!')
 		talk_state = 0
 		focus = 0
 		talk_start = 0  	elseif focus == cid then
		talk_start = os.clock()  		if talk_state == 0 then
			if msgcontains(msg, 'yes') or string.find(msg, '(%a*)tak(%a*)') then		-- wanna go to mainland
  				level = getPlayerLevel(cname)
  				if level >= mainlevel then
 					selfSay('Great! Do you want to be a knight, a paladin, a sorcerer or a druid? / Swietnie! Chcesz byc rycerzem, paladynem, czarodziejem czy medrcem?')
 					talk_state = 1
  				else
  					selfSay('Sorry, you need level ' .. mainlevel .. ' to go to the mainland. / Przepraszam, osiagnij przynajmniej 8 poziom, by dostac sie na main.')
 					talk_state = 0
  				end
 			else
 				selfSay('Come back when you are ready then. / Wroc, kiedy bedzie gotowy.')
 				talk_state = 0
 			end
 		elseif talk_state == 1 then		-- telling vocation
 			talk_state = 2
 			if msgcontains(msg, 'sorcerer') or string.find(msg, '(%a*)sorc(%a*)') or string.find(msg, '(%a*)sorcem(%a*)') or string.find(msg, '(%a*)mag(%a*)') or string.find(msg, '(%a*)czarodziej(%a*)') or string.find(msg, '(%a*)czarodziejem(%a*)') or string.find(msg, '(%a*)magiem(%a*)') then
 				selfSay('A Sorcerer! Are you sure? / Czarodziej! Czy na pewno?')
 				vocation = 1
 			elseif msgcontains(msg, 'druid') or string.find(msg, '(%a*)druidem(%a*)') or string.find(msg, '(%a*)medrzec(%a*)') or string.find(msg, '(%a*)medrcem(%a*)') or string.find(msg, '(%a*)drutem(%a*)') then
 				selfSay('A Druid! Are you sure? / Medrzec! Czy na pewno?')
 				vocation = 2
 			elseif msgcontains(msg, 'paladin') or string.find(msg, '(%a*)paladinem(%a*)') or string.find(msg, '(%a*)palladynem(%a*)') or string.find(msg, '(%a*)palkiem(%a*)') or string.find(msg, '(%a*)palem(%a*)') or string.find(msg, '(%a*)paladynem(%a*)') then
 				selfSay('A Paladin! Are you sure? / Paladyn! Czy na pewno?')
 				vocation = 3
 			elseif msgcontains(msg, 'knight') or string.find(msg, '(%a*)knightem(%a*)') or string.find(msg, '(%a*)knajtem(%a*)') or string.find(msg, '(%a*)rycerzem(%a*)') or string.find(msg, '(%a*)rycerz(%a*)') then
 				selfSay('A Knight! Are you sure? / Rycerz! Czy na pewno?')
 				vocation = 4
 			else
 				selfSay('Sorry, there is no such vocation. / Przepraszam, niema takiego powolania.')
 				vocation = 0
 				talk_state = 1
 			end
 		elseif talk_state == 2 then		-- confirming vocation
 			if msgcontains(msg, 'yes') or string.find(msg, '(%a*)tak(%a*)') then
 				selfSay('Great! Are you sure you want to do? / Swietnie! Na pewno chcesz to zrobic?')
 				talk_state = 3
 			else
 				selfSay('For what vocation you want to change? / Na jakie powolanie chcesz zmienic?')
 				talk_state = 1
 			end
 		elseif talk_state == 3 then		-- nazwa miasta
 			if msgcontains(msg, 'yes') or string.find(msg, '(%a*)tak(%a*)') then
 				selfSay('Good luck in the following way! / Powodzenia w dalszej drodze!')
 				setPlayerVocation(cid,vocation)
 				setPlayerMasterPos(cid,[COLOR="Lime"]1000[/COLOR],[COLOR="Lime"]1000[/COLOR],[COLOR="Lime"]6[/COLOR])
 				selfSay('/send ' .. cname .. ', [COLOR="Lime"]1000[/COLOR] [COLOR="Lime"]1000[/COLOR] [COLOR="Lime"]6[/COLOR]')
 				talk_state = 0
 				focus = 0
 				talk_start = 0
 			else
 				selfSay('Did you not ready? / Czyzbys nie byl gotow?')
 				talk_state = 3
 			end
  		end
  	end
end
function onCreatureChangeOutfit(creature)
end
function onThink()
  	if (os.clock() - talk_start) > 45 then
  		if focus > 0 then
  			selfSay('Next Please... / Nastepny prosze...')
  		end
  			focus = 0
  	end
 	if focus ~= 0 then
 		if getDistanceToCreature(focus) > 5 then
 			selfSay('Good bye then. / Zegnaj.')
 			focus = 0
 		end
 	end
end
Wsp??rz?dne miasta
Zamieni?em te? tak? linijk?:
Kod:
Great! Are you sure you want to do? / Swietnie! Na pewno chcesz to zrobic?
Zazwyczaj Oracle pyta?, do jakiego miasta chcesz si? uda?, ale ?e na wi?kszo?ci OTS'?w 7.6 jest tylko jedno miasto g??wne, to pozwoli?em sobie, by zadawa? takie pytanie.
Jak kto? si? przypatrzy to wida?, ?e przy wyborze profesji doda?em nietypowe nazwy typu: knajt, sorc, palek itp. itd. ot?? jest to dla analfabet?w xD (dzieci tibii), kt?rych w Tibi? gra du?o. :p
Jakby kto? niewiedzia? jak go dok?adnie doda? to w xxx\data\npc tworzymy The Oracle.xml i wklejamy do niego to:
Kod:
<?xml version="1.0"?>
<npc name="The Oracle" script="data/npc/scripts/oracle.lua" access="3">
	<look type="1448" head="57" body="59" legs="40" feet="76"/>
</npc>
A ?eby postawi? na mapce to w xxx\world\npc.xml
Kod:
<npc name="The Oracle" x="x" y="y" z="z"/>
Ot?? jeszcze raz, mo?na zacz?? z nim rozmow? "hi", ale odpisa? potem "tak" lub "yes"... no to chyba ka?dy skuma?. Wiem, ?e teraz jest ma?o OTS'?w 7.6 wi?c prosz? o wyrozumia?o?? i niepisanie post?w typu "niepotrzebne... beznadzieja.... i po ch** to komu?". Pozdro ^^
 
Status
Zamknięty.
Do góry