#1 2008-04-26 21:23:49

Armed79

http://i38.tinypic.com/2ni1vub.gif

Zarejestrowany: 2008-04-14
Posty: 87

[NPC] Własny NPC

Napisałem sam
NPC który sprzedaje lody śmietankowe i truskawkowe za 5gp

Tom.xml

Kod:

<?xml version="1.0"?>

<npc name="Tom" script="data/npc/scripts/lody.lua" lookdir="3" autowalk="25">
          <health now="1" max="1"/>
          <look type="134" head="21" body="105" legs="51" feet="90"/>
</npc>

lody.lua

Kod:

local focus = 0
local talk_start = 0
local target = 0
local following = false
local attacking = false

function onThingMove(creature, thing, oldpos, oldstackpos)

end


function onCreatureAppear(creature)

end


function onCreatureDisappear(cid, pos)
            if focus == cid then
          selfSay('Do zobaczenia.')
          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('Witam ' .. getCreatureName(cid) .. '! Jestes zmeczony?? Gorąco ci ?? to kup sobie lody truskawkowe i lody smietankowe (5gp).')
                      focus = cid
                      talk_start = os.clock()

            elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
                      selfSay('Czekaj, ' .. getCreatureName(cid) .. '! Rozmawiam z kimś innym.')

          elseif focus == cid then
                    talk_start = os.clock()

                    if msgcontains(msg, 'lód czekoladowy') or msgcontains(msg, 'lody czekoladowe')then
                    count = getCount(msg)
                    price = count*8
                              buy(cid,7375,1,5)
                    elseif msgcontains(msg, 'lód śmietankowy') or msgcontains(msg, 'lody śmietankowe')then
                    count = getCount(msg)
                    price = count*8
                              buy(cid,7372,1,5)
                    elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
                              selfSay('Do widzenia, ' .. getCreatureName(cid) .. '!')
                              focus = 0
                              talk_start = 0
                    end
          end
end


function onCreatureChangeOutfit(creature)

end


function onThink()
          if focus > 0 then 
                    x, y, z = creatureGetPosition(focus)
                    myx, myy, myz = selfGetPosition()
                    
                    if ((myy-y==0) and (myx-x<=0 and myx-x>=-4)) then
                              selfTurn(1)
                    end 
                    if ((myy-y==0) and (myx-x>=0 and myx-x<=4)) then
                              selfTurn(3)
                    end
                    if ((myx-x==0) and (myy-y<=0 and myy-y>=-4)) then
                              selfTurn(2)
                    end
                    if ((myx-x==0) and (myy-y>=0 and myy-y<=4)) then
                              selfTurn(0)
                    end
                    if ((myy-y==-2) and (myx-x>=-1 and myx-x<=1)) then
                              selfTurn(2)
                    end
                    if ((myy-y==2) and (myx-x>=-1 and myx-x<=1)) then
                              selfTurn(0)
                    end
                    if ((myx-x==2) and (myy-y>=-1 and myy-y<=1)) then
                              selfTurn(3)
                    end
                    if ((myx-x==-2) and (myy-y>=-1 and myy-y<=1)) then
                              selfTurn(1)
                    end
                    if ((myy-y==-3) and (myx-x>=-2 and myx-x<=2)) then
                              selfTurn(2)
                    end
                    if ((myy-y==3) and (myx-x>=-2 and myx-x<=2)) then
                              selfTurn(0)
                    end
                    if ((myx-x==3) and (myy-y>=-2 and myy-y<=2)) then
                              selfTurn(3)
                    end
                    if ((myx-x==-3) and (myy-y>=-2 and myy-y<=2)) then
                              selfTurn(1)
                    end
                    if ((myy-y==-4) and (myx-x>=-3 and myx-x<=3)) then
                              selfTurn(2)
                    end
                    if ((myy-y==4) and (myx-x>=-3 and myx-x<=3)) then
                              selfTurn(0)
                    end
                    if ((myx-x==4) and (myy-y>=-3 and myy-y<=3)) then
                              selfTurn(3)
                    end
                    if ((myx-x==-4) and (myy-y>=-3 and myy-y<=3)) then
                              selfTurn(1)
                    end
          end

          if (os.clock() - talk_start) > 30 then
                      if focus > 0 then
                                selfSay('Następny...')
                      end
                                focus = 0
            end
           if focus ~= 0 then
                     if getDistanceToCreature(focus) > 5 then
                               selfSay('Do Widzenia.')
                               focus = 0
                     end
           end
end

Przepraszam jeżeli nie działa ale to moj pierwszy skrypt

Offline

 

#2 2008-04-26 21:30:06

 Dimek

http://i50.tinypic.com/242swno.jpg

Zarejestrowany: 2008-04-05
Posty: 1855

Re: [NPC] Własny NPC

Wiesz w silnikach 8.1 jest taki skrypt...


http://i44.tinypic.com/kd01v7.png
http://www.kiep.pl/img21/2011/03/18/1300408688dance.gif

Offline

 

#3 2008-04-26 21:32:51

Armed79

http://i38.tinypic.com/2ni1vub.gif

Zarejestrowany: 2008-04-14
Posty: 87

Re: [NPC] Własny NPC

jest?? a to sorki nie wiedziałem nie znam sie co maja OTS

Offline

 

#4 2008-04-27 11:06:43

Łuki

http://i37.tinypic.com/okc0lk.gif

Zarejestrowany: 2008-04-26
Posty: 8

Re: [NPC] Własny NPC

Armed79

Wystarczy wejść w data-->npc-->scripts i zrobić prosty skrót klawiszy CTRL+F i wpisać lody lub od ręki poszukać i masz jak na patelni nic trudnego jeżeli już zabierasz się za cokolwiek na swoim OTS to najpierw poznaj go w całości w tedy nie będziesz potrzebował np. pomocy u nikogo i możliwe iż sam zaczniesz pisać proste skrypty.

Offline

 

#5 2008-04-27 15:05:33

Armed79

http://i38.tinypic.com/2ni1vub.gif

Zarejestrowany: 2008-04-14
Posty: 87

Re: [NPC] Własny NPC

no sam to napisałem teraz naucze sie pisac potowry i questy

Offline

 

#6 2008-04-27 15:16:37

 Termik

http://i38.tinypic.com/euqxqs.gif

Na PW pisz!
Zarejestrowany: 2008-03-22
Posty: 3445

Re: [NPC] Własny NPC

Tych lodiarzy jest masa ...jest w czym wybierać a jak żeby to urozmaicić zróbcie mu jakiś outfit albo nowe lody xD

Offline

 

#7 2008-04-27 16:27:35

Armed79

http://i38.tinypic.com/2ni1vub.gif

Zarejestrowany: 2008-04-14
Posty: 87

Re: [NPC] Własny NPC

Ale sam go zrobiłem wiec dla mnie to wiecej nie inne skrypty

Offline

 

#8 2008-04-29 13:59:55

Norrer

Zbanowany

5375311
Zarejestrowany: 2007-10-14
Posty: 143
Profesja: Candia
Server: -

Re: [NPC] Własny NPC

Skopiowany z 8.1 gz n/c


http://img14.imageshack.us/img14/5106/tmpin.png
http://i26.tinypic.com/2bpmia.png
http://magic.org.pl/games/img/Norrer.png
Kliknij !! Ja też klikne

Offline

 

#9 2008-04-29 14:28:07

Armed79

http://i38.tinypic.com/2ni1vub.gif

Zarejestrowany: 2008-04-14
Posty: 87

Re: [NPC] Własny NPC

Skopiowane !!! sam to pisałem  brawłem przykład ze sprzedazy zarcia !!

Offline

 

Stopka forum

RSS
Powered by PunBB
© Copyright 2002–2008 PunBB
Polityka cookies - Wersja Lo-Fi


Darmowe Forum | Ciekawe Fora | Darmowe Fora
Studio Inizio worldhotels