Mam nadzieje ze komus sie przyda . w data/npc/scripts tworzymy lotek.lua ------------------------------------------------------------------------------------------------------------------------------ Code:
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) -- greeting phrase if string.find(msg, '(%a*)hi(%a*)') and focus == 0 and string.len(msg) == 2 and getDistanceToCreature(cid) < 3 then selfSay('Hello ' .. creatureGetName(cid) .. '! I lottery tickets for 1k each.\nPlease say "ticket".\nFor Help say "help"!') focus = cid selfLook(cid) talk_start = os.clock() elseif focus == cid then talk_start = os.clock() if msgcontains(msg, 'help') then selfSay('You must buy lottery ticket and go to lotter machine for look you win.') elseif msgcontains(msg, 'ticket') then buy(cid,2318,1,1000) elseif msgcontains(msg, 'second addon') then itemstatus = DoRemoveItem(cid,2215,1) if itemstatus == -1 then selfSay('Sorry you dont have win addon item.') else addon(cid,2) focus = 0 talk_start = 0 end elseif msgcontains(msg, 'first addon') then itemstatus = DoRemoveItem(cid,2216,1) if itemstatus == -1 then selfSay('Sorry you dont have win addon item.') else addon(cid,1) focus = 0 talk_start = 0 end elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then selfSay('Good bye, ' .. creatureGetName(cid) .. '!') focus = 0 talk_start = 0 end end end function onCreatureChangeOutfit(creature) end function onThink() if focus == 0 then selfWalk(4) 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) > 3 then selfSay('Good bye then.') focus = 0 end end end data/npc/ tworzymy plik: lottery.xml Kod: <?xml version="1.0"?> <npc name="Lottery" script="data/npc/scripts/lotek.lua" access="3"> <look type="134" head="19" body="114" legs="94" feet="94"/> </npc> terwaz w data/actions/scripts tworzymy plik lotek.lua :> Kod: function onUse(cid, item, frompos, item2, topos) if item.itemid == 2318 then randomeczek = math.random(500,2000) if randomeczek >= 500 and randomeczek <= 537 then doPlayerAddItem(cid,2160,50) doPlayerSendCancel(cid,"You Win 500k.") doSendMagicEffect(topos,12) elseif randomeczek >= 538 and randomeczek <= 539 then doPlayerAddItem(cid,2216,1) doPlayerSendCancel(cid,"You Win a First Addon! go to lottery npc and give this item.") doSendMagicEffect(topos,12) elseif randomeczek >= 540 and randomeczek <= 541 then doPlayerAddItem(cid,2215,1) doPlayerSendCancel(cid,"You Win a Second Addon! go to lottery npc and give this item.") doSendMagicEffect(topos,12) elseif randomeczek >= 542 and randomeczek <= 601 then doPlayerAddItem(cid,2160,25) doPlayerSendCancel(cid,"You Win 250k.") elseif randomeczek >= 602 and randomeczek <= 750 then doPlayerAddItem(cid,2160,12) doPlayerAddItem(cid,2152,50) doPlayerSendCancel(cid,"You Win 125k.") elseif randomeczek >= 751 and randomeczek <= 901 then doPlayerAddItem(cid,2160,7) doPlayerAddItem(cid,2152,50) doPlayerSendCancel(cid,"You Win 75k.") elseif randomeczek >= 902 and randomeczek <= 1152 then doPlayerAddItem(cid,2160,3) doPlayerSendCancel(cid,"You Win 30k.") elseif randomeczek >= 1153 and randomeczek <= 1294 then doPlayerAddItem(cid,2160,1) doPlayerAddItem(cid,2152,50) doPlayerSendCancel(cid,"You Win 15k.") elseif randomeczek >= 1295 and randomeczek <= 1500 then doPlayerAddItem(cid,2160,1) doPlayerSendCancel(cid,"You Win 10k.") elseif randomeczek >= 1501 and randomeczek <= 1701 then doPlayerAddItem(cid,2152,2) doPlayerSendCancel(cid,"You Win 2k.") elseif randomeczek >= 1702 and randomeczek <= 2000 then doPlayerSendCancel(cid,"You lost.") end if item.type > 1 then doChangeTypeItem(item.uid,2134) else doRemoveItem(item.uid,1) end end return 1 end ------------------------------------------------------------------------------------------------------------------------------ I w data/actions/actions.xml dopisujemy linijkę: ====================================================================== Code: <action itemid="2318" script="lotek.lua" /> ------------------------------------------------------------------------------------------------------------------------------
Mam nadzieje, ze pomoglem. Jezeli pomoglem daj plusa na www.tibia11.pun.pl !
|