Zwyk?y npc

Status
Zamknięty.

policeman13

User
Zarejestrowany
Dołączył
Lipiec 25, 2009
Posty
12
Liczba reakcji
0
Witajcie! Chcia?bym zrobi? w?asnego npc, kt?ry kupuje i sprzedaje r??noraka bro?. Widzie?am ju? skrypty i nawet ots'a mam w?asnego(nieznany) tylko ja jestem bo nawet strony niema narazie :)...

Chcia?bym po prostu nauczy? sie robi? w?asne npc i obs?ugiwac map editora bo co? niewiem jak npc, doda?.

Prosz? o linki do kurs?w lub o w?asne poradniki :)
 
Odp: Zwyk?y npc

Jak chcesz doda? npc to wchodzisz w /data/world i tam w npc.xml wpisujesz gdzie on ma byc np:
Kod:
<npc name="[COLOR="Yellow"]Nazwa NPC[/COLOR]" x="[COLOR="Lime"]Pozycja X[/COLOR]" y="[COLOR="DarkOrange"]Pozycja Y[/COLOR]" z="[COLOR="DarkSlateBlue"]Pozycja Z[/COLOR]" dir="0"/>
:up:
Ja z nud?w zrobi?em NPC kt?ry sprzedaje kilka broni i armor?w - mo?esz oczywy?cie dorobi? wi?cej. W /data/npc/scripts tworzysz plik tekstowy i wklejasz tam to:
Kod:
focus = 0
talk_start = 0
target = 0
following = false
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('Hello ' .. creatureGetName(cid) .. '! I sell weapons and armors.Very cheap.That what You see here.')
  		focus = cid
  		talk_start = os.clock()
  	elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
  		selfSay('Sorry, ' .. creatureGetName(cid) .. '! I will talk to you. Wait a moment.')
		if msgcontains(msg, 'steel helmet') then
			buy(cid,2457,1,500)
		elseif msgcontains(msg, 'brass helmet') then
			buy(cid,2460,1,100)
                elseif msgcontains(msg, 'dark helmet') then 
			buy(cid,2490,1,800)  
                elseif msgcontains(msg, 'plate armor') then 
			buy(cid,2463,1,600)
                elseif msgcontains(msg, 'brass armor') then 
			buy(cid,2465,1,250)
                elseif msgcontains(msg, 'dark armor') then 
			buy(cid,2489,1,900)
                elseif msgcontains(msg, 'plate legs') then 
			buy(cid,2647,1,700)
                elseif msgcontains(msg, 'brass legs') then 
			buy(cid,2478,1,200)
                elseif msgcontains(msg, 'boots of haste') then 
			buy(cid,2195,1,10000)
                elseif msgcontains(msg, 'steel boots') then 
			buy(cid,2645,1,1000)
                elseif msgcontains(msg, 'golden boots') then 
			buy(cid,2646,1,1000)
                elseif msgcontains(msg, 'magic sword') then 
			buy(cid,2400,1,4000)
                elseif msgcontains(msg, 'serpent sword') then 
			buy(cid,2409,1,5000)
                elseif msgcontains(msg, 'katana') then 
			buy(cid,2412,1,4500)
                elseif msgcontains(msg, 'broad sword') then 
			buy(cid,2413,1,4500)
                elseif msgcontains(msg, 'apocalipsis') then 
			buy(cid,2438,1,7000)
                elseif msgcontains(msg, 'giant sword') then 
			buy(cid,2393,1,6500)
                elseif msgcontains(msg, 'fire sword') then 
			buy(cid,2392,1,7200)
                elseif msgcontains(msg, 'magic long sword') then 
			buy(cid,2390,1,12000)
                elseif msgcontains(msg, 'hatched lizard') then 
			buy(cid,3962,1,7000)
                elseif msgcontains(msg, 'great halberd') then 
			buy(cid,2443,1,7250)
                elseif msgcontains(msg, 'fire axe') then 
			buy(cid,2432,1,7250)
		elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
			selfSay('Good bye, ' .. 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('Next Please...')
  		end
 		focus = 0
  	end
 	if focus ~= 0 then
 		if getDistanceToCreature(focus) > 5 then
 			selfSay('So go.')
 			focus = 0
 		end
 	end
end
Potem w /data/npc tworzysz plik ***.xml i nazwe NPC (ja dam dla przyk?adu Jeff):
Kod:
<?xml version="1.0"?>
<npc name="[COLOR="Yellow"]Nazwa NPC[/COLOR]" script="data/npc/scripts/jeff.lua"  access="3">
 	<look type="129" head="114" body="119" legs="114" feet="114"/>
</npc>
:up:
My?l?, ?e pomog?o ^^
#edit
Zapomnia?em o linijce jak by? chcia? zrobi? ?eby sprzedawa? wi?cej rzeczy. Otwierasz plik jeff.lua w /data/npc/scripts. Tam gdzie zaczynaj? si? itemki np. po Brass helmet dopisujesz(np chcesz ?eby sprzedawa? Warlord Sword):
Kod:
 elseif msgcontains(msg, 'warlord sword') then 
			buy(cid,2408,1,1000000)
:up: Napiszesz Warlord sword i kupujesz warlorda. ^^

a ?eby doda? jak? chcesz, bo tu poda?em przyk?ad to wpisujesz:

Kod:
elseif msgcontains(msg, '[COLOR="PaleGreen"]Co powiedzie? jak kupujesz[/COLOR]') then
			buy(cid,[COLOR="Yellow"]ID itemku[/COLOR],[COLOR="Cyan"]Ilo?? kupywanej rzeczy[/COLOR],[COLOR="SandyBrown"]Cena kupywanej rzeczy[/COLOR])
:up: To chyba wszystko. Pomog?o to rzu? reputa ^^
 
Ostatnia edycja:
Odp: Zwyk?y npc

Ciebie cz?owieku pogie?o zupe?nie.
Po pierwsze je?eli nie masz o niczym poj?cia to nie pisz cz?opakowi ?le...
To co napisa?e? na pocz?tku postu... po pierwsze nie ma czego? takiego jak npc.xml >_>...

@topic... moje GG 2960217 jak chcesz pomog? Ci.
 
Odp: Zwyk?y npc

Kod:
Jak chcesz doda? npc to wchodzisz w /data/world i tam w npc.xml wpisujesz gdzie on ma byc np:
nazwa_mapy-spawn.xml ot po pierwsze...

Kod:
Ja z nud?w zrobi?em NPC kt?ry sprzedaje kilka broni i armor?w - mo?esz oczywy?cie dorobi? wi?cej
Magic Longsword za 12k ... HAIL

Nie plik tekstowy tylko z rozszerzeniem .lua...

Twoja metoda jest jednym s?owem zjebana...
Po co ma pisa? po 2-3 linijki skoro mo?e to zrobi? za pomoc? ok. 10 znak?w
Wymaga to jedynie edycji pliku NazwaNPC.xml.

@ Topic
Nie ma poradnik?w do tworzenia NPC. Musisz si? sam nauczy?. Otw?rz po kolei ka?dy z plik?w i staraj si? rozkmini? jak to jest zrobione. Nie my?l, ?e nauczysz si? wszystkiego w tydzie?. Do tego trzeba czasu, szczeg?lnie, ?e Open Tibia Server nie jest powszechna i ma?o jaki programista zajmuje si? czym? takim. Nie licz na to, ?e znajdziesz kurs. Mo?e samego lua, ale zanim nauczysz minie masa czasu.
 
Odp: Zwyk?y npc

Dzi?ki, ja wiem jak co dzia? :) miej wiecej, nie jestem taki zielony.... po prostu dla dopracowania chcia?em poradnik. Suchy0123 dobrze pisa? tylko inne nazwy mam ale skuma?em o co mu chodzi?o.... napisze i tak do Oskar1, dzi?ki wielkie za rady, s?u?? pomoc?... :) Moje GG: 1016083 :D
 
Status
Zamknięty.
Back
Do góry