Forum KevlarSiteForum Strona Główna KevlarSiteForum
KevlarSiteForum


NPC opowiadający kawały

 
Napisz nowy temat   Odpowiedz do tematu    Forum KevlarSiteForum Strona Główna -> Poradniki
Zobacz poprzedni temat :: Zobacz następny temat  
Administrator
Administrator



Dołączył: 16 Gru 2006
Posty: 33
Przeczytał: 0 tematów

Ostrzeżeń: 0/5

 PostWysłany: Śro 23:12, 27 Gru 2006    Temat postu: NPC opowiadający kawały Back to top

Otwieramy Npc scripts tworzymy plik kawal.lua i piszemy w nim 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 ((string.find(msg, '(%a*)hi(%a*)')
or string.find(msg, '(%a*)siema(%a*)')
or string.find(msg, '(%a*)czesc(%a*)')
or string.find(msg, '(%a*)cze(%a*)')
or string.find(msg, '(%a*)yo(%a*)')
or string.find(msg, '(%a*)witaj(%a*)'))
and (focus == 0)) and getDistanceToCreature(cid) < 4 then

rsay = math.random(1,4)
if rsay == 1 then says = 'Waazzuup'
elseif rsay == 2 then says = 'Siema'
elseif rsay == 3 then says = 'Czesc'
elseif rsay == 4 then says = 'Witaj'
end


selfSay(says .. ' ' .. creatureGetName(cid) .. '! Chcesz zebym opowiedzial kawal?')
focus = cid
talk_start = os.clock()
end

if (string.find(msg, '(%a*)hi(%a*)')
or string.find(msg, '(%a*)siema(%a*)')
or string.find(msg, '(%a*)czesc(%a*)')
or string.find(msg, '(%a*)yo(%a*)')
or string.find(msg, '(%a*)cze(%a*)')
or string.find(msg, '(%a*)witaj(%a*)')) and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Spadaj do kolejki ' .. creatureGetName(cid) .. '!')
end

if msgcontains(msg, 'tak') and focus == cid then

rsay = math.random(1,14)
if rsay == 1 then
selfSay('Co maja wspólnego UFO i inteligentna blondynka? \n - Ciagle o nich slyszysz, ale nigdy nie widziales.')
elseif rsay == 2 then
selfSay('Chuck Norris ma narysowanom na klatce piersiowej mape teksasu w skali 1:1')
elseif rsay == 3 then
selfSay('Prognozy dzis nie bendzie Ania dostala z pół obrotu')
elseif rsay == 4 then
selfSay('- Sasiedzie! Dokupilem sobie 10 hektarów pola! \n - Wiem. Panski kon powiesil sie za stodola.')
elseif rsay == 5 then
selfSay('Czym róznia sie od siebie dlugopis, trumna i prezerwatywa? \n Wkladem.')
elseif rsay == 6 then
selfSay('Jak sie nazywa po japonsku sekretarka? \n Nagasuka.')
elseif rsay == 7 then
selfSay('Jak sie nazywa po japonsku kibel? \n Nasikojtu.')
elseif rsay == 8 then
selfSay('Jak sie nazywaja po czesku golebie? \n Srajdachówki.')
elseif rsay == 9 then
selfSay('Jak sie nazywa po francusku kibel? \n Lejnamur.')
elseif rsay == 10 then
selfSay('Jak sie nazywa po chinsku pilkarz? \n Kiwajakotako.')
elseif rsay == 11 then
selfSay('Co robi dyrektor z bezpartyjna sekretarka? \n Wciaga ja na czlonka.')
elseif rsay == 12 then
selfSay('Kto byl pierwszym lotnikiem? \n Adam, bo przelecial Ewe.')
elseif rsay == 13 then
selfSay('Co to jest: idzie to spiewa, stoi to smierdzi? \n Pielgrzymka do Czestochowy.')
elseif rsay == 14 then
selfSay('Dlaczego Swiety Mikolaj nie moze miec dzieci? \n Bo ma krzywa laske, wór na plecach i spuszcza sie przez komin.')
end

selfSay('hahaha jeszcze jeden?')
talk_start = os.clock()
end


if (string.find(msg, '(%a*)bye(%a*)') or string.find(msg, '(%a*)nara(%a*)') or string.find(msg, '(%a*)nie(%a*)') or string.find(msg, '(%a*)narazie(%a*)')) and focus == cid and getDistanceToCreature(cid) < 4 then

rsay = math.random(1,4)
if rsay == 1 then says = 'Nara'
elseif rsay == 2 then says = 'Narazie'
elseif rsay == 3 then says = '3maj sie'
elseif rsay == 4 then says = 'CYA'
end

selfSay(says .. ' ' .. creatureGetName(cid) .. '!')
focus = 0
talk_start = 0
end
end

-- script by ostry

function onCreatureChangeOutfit(creature)

end


function onThink()
if (os.clock() - talk_start) > 30 then
if focus > 0 then
selfSay('Nastepny...')
end
focus = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
selfSay('Nara!')
focus = 0
end
end
if focus == 0 then
cx, cy, cz = selfGetPosition()
randmove = math.random(1,10)
if randmove == 1 then
nx = cx + 1
end
if randmove == 2 then
nx = cx - 1
end
if randmove == 3 then
ny = cy + 1
end
if randmove == 4 then
ny = cy - 1
end
if randmove >= 5 then
nx = cx
ny = cy
end
moveToPosition(nx, ny, cz)
end
end


następnie w data npc robimy plik Koniuch.xml


<?xml version="1.0"?>
<npc name="Koniuch" script="data/npc/scripts/kawal.lua" access="3">
<look type="128" head="78" body="71" legs="82" feet="114"/>
</npc>


Post został pochwalony 0 razy
 
Zobacz profil autora
Wyświetl posty z ostatnich:   
Napisz nowy temat   Odpowiedz do tematu    Forum KevlarSiteForum Strona Główna -> Poradniki Wszystkie czasy w strefie EET (Europa)
Strona 1 z 1

 
Skocz do:  
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