| vilagie 
 
 
 Dołączył: 22 Mar 2006
 Posty: 25
 Przeczytał: 0 tematów
 
 Ostrzeżeń: 0/5
 
 
 | 
            
                |  Wysłany: Śro 18:48, 22 Mar 2006    Temat postu: Sfinks zadajacy pytania |  |  
                | 
 |  
                | Wiec prezentuje wam sfinksa, jest to npc ktory zadaje zagatki i gdy przejdziemy przez caly test teleporuje nas w wybrane miejsce, gdy juz przejdziemy caly test za kazdym kolejnym razem mozemy zostac teleportowani, wystarczy powiedziec odpowiedz na ostatniem pytanie ale gdy ktos nie przeszedl jeszcze testu i udzieli odpowiedz na ostatnie pytanie sfinks mu jej nie uzna . Wchodzmy do folderu data/npc dodajemy plik Sfinks.xml a w nim: 
 Kod:
 <?xml version="1.0"?>
 
 <npc name="Sfinks" script="data/npc/scripts/pytania.lua" access="3" lookdir="1">
 <health now="1" max="1"/>
 <look type="41" head="20" body="30" legs="40" feet="50" corpse="4005"/>
 </npc>Potem w data/npc/scripts tworzymy plik o nazwie pytania.lua i wklejamy:
 
 Kod:
 -- Sfinks by Nilan
 
 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('GRATULACJE UKONCZYLES TEST! NASTEPNYM RAZEM WYSTARCZY ZE POWIESZ MI ODPOWIEDZ NA OSTATNIE PYTANIE A ZNOW TELEPORTUJE CIE!')
 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('Witaj, ' .. creatureGetName(cid) .. '! Jezeli odpowiesz na moje pytania przeniose cie do wslanialego miejsca! Powiedz tylko "zadanie".')
 focus = cid
 talk_start = os.clock()
 end
 
 if string.find(msg, '(%a*)hi(%a*)') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
 selfSay('Grrrr, ' .. creatureGetName(cid) .. ' mie widzisz ze rozmawiam?')
 end
 if msgcontains(msg, 'zadanie') and focus == cid then
 selfSay('Pytanie1')
 talk_start = os.clock()
 end
 
 if msgcontains(msg, 'odpowiedz1') and focus == cid then
 talk_start = os.clock()
 
 setPlayerStorageValue(cid,1000,1)
 
 selfSay('Brawo dobrze! Nastepne pytanie brzmi.')
 selfSay('Pytanie2')
 
 end
 
 if msgcontains(msg, 'odpowiedz2') and focus == cid then
 talk_start = os.clock()
 queststatus = getPlayerStorageValue(cid,1000)
 
 if queststatus == -1 then
 selfSay('Pierw odpowiedz na poprzednie pytanie.')
 else
 selfSay('Pytanie 3.')
 setPlayerStorageValue(cid,1001,1)
 end
 end
 
 if msgcontains(msg, 'odpowiedz3') and focus == cid then
 talk_start = os.clock()
 queststatus = getPlayerStorageValue(cid,1001)
 
 if queststatus == -1 then
 selfSay('Pierw odpowiedz na poprzednie pytanie.')
 else
 selfSay('/send ' .. creatureGetName(cid) .. ', 215 200 7')
 selfSay('Zapamnietaj ta odpowiedz bym mogl cie teleportowac odrazu innym razem!')
 setPlayerStorageValue(cid,1002,1)
 end
 end
 
 
 
 if string.find(msg, '(%a*)bye(%a*)') and focus == cid and getDistanceToCreature(cid) < 4 then
 selfSay('Nara sprobuj potem!')
 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('Nie bede wiecej czekał, sprobuj jeszcze raz!')
 end
 focus = 0
 end
 if focus ~= 0 then
 if getDistanceToCreature(focus) > 5 then
 selfSay('Sprobuj potem!')
 focus = 0
 end
 end
 end
 pytanie1, pytanie2, pytanie3 - wtych miejscach wpisujemy wlasne pytania
 odpowiedz1, odpowiedz2, odpowiedz3 - tutaj wpisujemy wlasna odpowiedz
 Chyba kazdy rozumie ze odpowiedz1 to odpowiedz do pytania1 a odpowiedz2 do pytania2 itd. DO npc trzeba powiedziec hi a potem zadanie.
 @edit:
 Zapomnialem dodac ze w:
 selfSay('/send ' .. creatureGetName(cid) .. ', 215 200 7')
 Zamiast 215 pozycje X
 Zamiast 200 pozycje Y
 Zamiast 7 pozycje Z
 
 Post został pochwalony 0 razy
 |  |