Najlepszy OTS
 
Szukanie zaawansowane
   
 
Home Rejestracja FAQ Użytkownicy Grupy Galerie  
 
 

Forum Najlepszy OTS Strona Główna Skrypty Straznik Miasta
Wyświetl posty z ostatnich:   
       
Napisz nowy temat  Odpowiedz do tematu

Sob 16:03, 18 Mar 2006
Autor Wiadomość
Administrator
Administrator
Administrator



Dołączył: 05 Mar 2006
Posty: 118
Przeczytał: 0 tematów

Ostrzeżeń: 0/5

Temat postu: Straznik Miasta

Ponieważ mi się nudziło postanowiłem zrobić jakiegoś NPC. Wpadł mi do głowy straznik. W sumie to banalne ale zawsze. Komuś się może przydać.

Zaczynajmy. W pliku ots\data\npc\scripts tworzymy plik o nazwie straz.lua i wklejamy to:

Kod:
-- the id of the creature we are attacking, following, etc.

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 ((string.find(msg, '(%a*)hi(%a*)')) and (focus == 0)) and getDistanceToCreature(cid) < 4 then
selfSay('Hello, ' .. creatureGetName(cid) .. '! Jestem straznikiem miasta. Bronie je przed napadami zla, ktore ostatnio grasuje po oklicy. Jak chcesz to mozesz ze mna posiedziec i popilnowac...')
focus = cid
talk_start = os.clock()
end

if string.find(msg, '(%a*)hi(%a*)') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Leave us alone, ' .. creatureGetName(cid) .. '!')
end if msgcontains(msg, 'buy beer') and focus == cid then
buy(cid,2006,3,10)
talk_start = os.clock()
end



if msgcontains(msg, 'quest') and focus == cid then
talk_start = os.clock()
queststatus = getPlayerStorageValue(cid,5019)

if queststatus == -1 then
selfSay('Moja misja to ratowanie ci tylka jak przyjda potwory! Tacy jak wy zawsze szukacie miejsca gdzie mozna komus przeszkadzac! Won')



end
end

if string.find(msg, '(%a*)bye(%a*)') and focus == cid and getDistanceToCreature(cid) < 4 then
selfSay('Taa... Uciekaj puki nie ma potworow. Takich jak wy powinno sie wieszac. Pasozyty jedne.' .. creatureGetName(cid) .. '!')
focus = 0
talk_start = 0
end
end


function onCreatureChangeOutfit(creature)

end


function onThink()
if (os.clock() - talk_start) > 30 then
if focus > 0 then
selfSay('Taa... Uciekaj puki nie ma potworow. Takich jak wy powinno sie wieszac. Pasozyty jedne.')
end
focus = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
selfSay('Bywaj. Obys se dedl... Hahahah')
focus = 0
end
end
end


Następnie w folderze ots\data\npc tworzymy plik o nazwie Straznik.xml i wklejamy to:

Kod:
<?xml version="1.0"?>
<npc name="Straznik" script="data/npc/scripts/straz.lua" access="3">
<look type="131" head="57" body="57" legs="57" feet="57"/>
</npc>


Ostatnim krokiem jest w folderze ots\data\world wpisać w pliku npc.xml polożenie. U mnie jest takie

Kod:
<npc name="Straznik" x="141" y="65" z="7" dir="1"/>
<npc name="Straznik" x="165" y="61" z="7" dir="1"/>


Tam gdzie wspolrzedne ustaw na swoje
Można dawać więcej przy bramach miasta, przed miastem w mieście.


Post został pochwalony 0 razy
 
Zobacz profil autora
      Do góry  
Napisz nowy temat  Odpowiedz do tematu

 
Możesz pisać nowe tematy
Możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach


      Do góry  

Strona 1 z 1
Skocz do:  
fora.pl - załóż własne forum dyskusyjne za darmo
Powered by phpBB © 2001, 2002 phpBB Group
Avalanche style by What Is Real © 2004
             
Regulamin