Nie tylko o Tibii i OTS...
Po 1 Skrypt nie muj ale spoko ;D
W data\actions\scripts tworzymi plik lottery_ticket.lua :
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;
<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 :
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 :
<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
Offline
Szukałem tego, bo coś mi NPC nie wychodził ^^. Skrypt sobie sam napisałem, nawet jest podobny do tego
Dziex za NPC
Offline
THX Ziele...u mnie dziala ;] i w dodatku nie wyskakiwaly zadne bledy ;] Spoko skrypt 8/10
Oby tak dalej xD
PoZdRo
Offline
ja niewiem co to daj plz powiedzcie bo jakon niekumam ??
Offline