Forum nie tylko o Tibii i OTS...

Nie tylko o Tibii i OTS...


#1 2008-05-15 21:32:55

Ziele

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

6868784
Zarejestrowany: 2008-03-26
Posty: 462

[8.1][Actions/Npc] Lottery Ticket !!! Za itemki

Po 1 Skrypt nie muj ale spoko ;D

W data\actions\scripts tworzymi plik lottery_ticket.lua :

Kod:

function onUse(cid, item, frompos, item2, topos)

ticket = math.random(1,11)
pos = getPlayerPosition(cid)

if ticket == 1 then
doSendMagicEffect(pos,27)
doSendAnimatedText(frompos, "You lose.", 89)
doPlayerAddItem(cid,5956,1) --lose
doRemoveItem(item.uid,1)

elseif ticket == 2 then
doSendMagicEffect(pos,27)
doSendAnimatedText(frompos, "You lose.", 89)
doPlayerAddItem(cid,5956,1) --lose
doRemoveItem(item.uid,1)

elseif ticket == 3 then
doSendMagicEffect(pos,27)
doSendAnimatedText(frompos, "You lose.", 89)
doPlayerAddItem(cid,5956,1) --lose
doRemoveItem(item.uid,1)

elseif ticket == 4 then
doSendMagicEffect(pos,27)
doSendAnimatedText(frompos, "You lose.", 89)
doPlayerAddItem(cid,5956,1) --lose
doRemoveItem(item.uid,1)

elseif ticket == 5 then
doSendMagicEffect(pos,27)
doSendAnimatedText(frompos, "You lose.", 89)
doPlayerAddItem(cid,5956,1) --lose
doRemoveItem(item.uid,1)

elseif ticket == 6 then
doSendMagicEffect(pos,27)
doSendAnimatedText(frompos, "You lose.", 89)
doPlayerAddItem(cid,5956,1) --lose
doRemoveItem(item.uid,1)

elseif ticket == 7 then
doSendMagicEffect(pos,27)
doSendAnimatedText(frompos, "You lose.", 89)
doPlayerAddItem(cid,5956,1) --lose
doRemoveItem(item.uid,1)

elseif ticket == 8 then
doSendMagicEffect(pos,27)
doSendAnimatedText(frompos, "You lose.", 89)
doPlayerAddItem(cid,5956,1) --lose
doRemoveItem(item.uid,1)

elseif ticket == 9 then
doSendMagicEffect(pos,27)
doSendAnimatedText(frompos, "You lose.", 89)
doPlayerAddItem(cid,5956,1) --lose
doRemoveItem(item.uid,1)

elseif ticket == 10 then
doSendMagicEffect(pos,27)
doSendAnimatedText(frompos, "You lose.", 89)
doPlayerAddItem(cid,5956,1) --lose
doRemoveItem(item.uid,1)

elseif ticket == 11 then
doSendMagicEffect(pos,27)
doSendAnimatedText(frompos, "You win.", 89)
doPlayerAddItem(cid,5958,1) --win
doRemoveItem(item.uid,1)

end

return 1
end

Do \data\actions\actions.xml dodajemy;

Kod:

<action itemid="5957" script="lottery_ticket.lua" />

2.Teraz Skrypt na NPC który wymieni nam 100 pustych viali za Lottery ticket.

W \data\npc\scripts  tworzymy plik ticket.lua :

Kod:

local focus = 0
local talk_start = 0
local target = 0
local following = false
local attacking = false
local havent_item = 'You don\'t have so many this item.'
        addon_need_premium = 'Sorry, you need a premium account to get items.'
        addon_have_already = 'Sorry, you already have this items.'
        addon_have_not_items = 'Sorry, you don\'t have these items.'
        addon_give = 'Here you are.'
        player_gold = getPlayerItemCount(cid,2148)
        player_plat = getPlayerItemCount(cid,2152)*100
        player_crys = getPlayerItemCount(cid,2160)*10000
        player_money = player_gold + player_plat + player_crys


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('Witaj, ' .. getCreatureName(cid) .. '! Jesli chcesz uzyskac pomoc wpisz "pomoc".')
          focus = cid
          talk_start = os.clock()

      elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
          selfSay('Zaczekaj, ' .. getCreatureName(cid) .. '! Porozmawiam z toba za minute.')

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

        if msgcontains(msg, 'pomoc') then
        selfSay('Mozesz u mnie wymienic 100 viali za Lottery Ticket".')

            elseif msgcontains(msg, 'vial') then
            if getPlayerItemCount(cid,2006) >= 100 then
                selfSay('Chcesz mi dac 100 viali?')
                talk_state = 1
            else
                selfSay('Potrzebuje 100 viali, zeby dac ci Lottert Ticket. Przyjdz kiedy bedziesz je mial.')
                talk_state = 0
            end

            elseif msgcontains(msg, 'tak') and talk_state == 1 then
            talk_state = 0
            if getPlayerItemCount(cid,2006) >= 100 then
            if doPlayerRemoveItem(cid,2006, 100) == TRUE then
            doPlayerAddItem(cid, 5957, 1)
                        selfSay('Prosze o to twoj kupon.')
            end
            else
                selfSay(havent_item)
            end

elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
            selfSay('Narazie, ' .. 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('Next Please...')
          end
              focus = 0
      end
     if focus ~= 0 then
         if getDistanceToCreature(focus) > 5 then
             selfSay('Good bye then.')
             focus = 0
         end
     end
end

W \data\npc  tworzymy plik Martin.xml :

Kod:

<npc name="Martin" script="data/npc/scripts/ticket.lua" autowalk="25" floorchange="0" access="5" level="1" maglevel="1">
    <health now="150" max="150"/>
    <look type="273" head="0" body="0" legs="0" feet="0" addons="3"/>
    <parameters>
        <parameter key="message_greet" value="Witaj |PLAYERNAME|. Dam ci Lottery Ticket za 100 viali." />
        <parameter key="message_needmoremoney" value="Nie masz viali przy sobie." />
        
    </parameters>
</npc>

UWAGA!!!

1. NPC nalezy postawic za pomocą MapEditor
2. Skrypt moze wyświetlać w konsoli OTS błedy ale wszystko dziala w 100%

Pozdro all


^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^.^
http://www.pokeplushies.com/images/adoptables/771098.gif
Nakarmisz Mnie ???
www.cs-myp.xt.pl <<<<---- zapraszamy do rejestracjii !!
www.games4you.y0.pl <<<< --------- Również zapraszamy !!!

Offline

 

#2 2008-05-15 21:50:34

piternet

http://i36.tinypic.com/28i01e0.gif

Zarejestrowany: 2008-01-12
Posty: 251

Re: [8.1][Actions/Npc] Lottery Ticket !!! Za itemki

Szukałem tego, bo coś mi NPC nie wychodził ^^. Skrypt sobie sam napisałem, nawet jest podobny do tego
Dziex za NPC


"Some are good for fighting, others for dying.......... You need both, I think."
http://img380.imageshack.us/img380/315/usersy8.png
http://i14.photobucket.com/albums/a309/Dexter-tm/soadfan7ve.gif
http://img99.imageshack.us/img99/7167/springfankopiadq0.gif
18 maja, godz. 20:23 --> mój 200 post!

Offline

 

#3 2008-05-15 21:55:20

 Seeker

http://i49.tinypic.com/2whmhds.jpg

4133650
Skąd: Tu i Tam...
Zarejestrowany: 2008-02-29
Posty: 1243
Nick: Heannak
Profesja: Honera
Server: 39~
WWW

Re: [8.1][Actions/Npc] Lottery Ticket !!! Za itemki

nom przyznam nawet god miales cos takiego sam se zrobilem ale to nie tak latwo


http://pretoriaots.pl/signature.php?character=Seeker&image=4
http://s2.tibiafun.y0.pl/char.php?c=Naplecior
http://www.pokeplushies.com/images/adoptables/690903.gif

Offline

 

#4 2008-05-22 18:01:09

~Shikamaru~

http://i37.tinypic.com/2dqpohz.gif

Zarejestrowany: 2008-05-22
Posty: 23

Re: [8.1][Actions/Npc] Lottery Ticket !!! Za itemki

THX Ziele...u mnie dziala ;] i w dodatku nie wyskakiwaly zadne bledy ;] Spoko skrypt 8/10

Oby tak dalej xD

PoZdRo


xD....Opisu Nie Ma....xD

Offline

 

#5 2008-05-23 08:41:17

Issak

http://i37.tinypic.com/2dqpohz.gif

Zarejestrowany: 2008-05-11
Posty: 26

Re: [8.1][Actions/Npc] Lottery Ticket !!! Za itemki

Thx all dziala 9/10 ;]


http://r3.fodey.com/1aac40d99df714347a5db26cac46ab4d0.1.gif

Offline

 

#6 2008-05-31 09:40:36

Kapi000

http://i38.tinypic.com/19pb0n.gif

Zarejestrowany: 2008-05-23
Posty: 19
Nick: Liker Jedd
Profesja: Obsidia
Server: 25

Re: [8.1][Actions/Npc] Lottery Ticket !!! Za itemki

ja niewiem co to daj plz powiedzcie bo jakon niekumam ??

Offline

 

Stopka forum

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


Darmowe Forum | Ciekawe Fora | Darmowe Fora
www.costam.pun.pl www.ligipilkarskie.pun.pl www.bleachfani.pun.pl www.radiotopmusic.pun.pl www.teenager-hogwart.pun.pl