DougCp

Xmas event

Dec 8th, 2016
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 17.90 KB | None | 0 0
  1. au--[[ Titles ]]--
  2. title = {
  3.     [1] = "Snowglobe",
  4.     [2] = "Reindeer",
  5.     [3] = "Santa's Bag",
  6. }
  7.  
  8. --[[ Lib ]]--
  9. math.pythag = function(x1,y1,x2,y2,range)
  10.     return ((x1-x2)^2+(y1-y2)^2<range^2)
  11. end
  12. math.percent = function(x,of,total)
  13.     return (x/of)*total
  14. end
  15.  
  16. table.random = function(t,r)
  17.     local i = math.random(#t)
  18.     if r then return t[i],i else return t[i] end
  19. end
  20. table.destroy=function(list,value)
  21.     for k,v in next,list do
  22.         if v == value then
  23.             table.remove(list,k);break
  24.         end
  25.     end
  26. end
  27.  
  28. system.looping = function(f,tk)
  29.     local s = 1000 / tk
  30.     local t = {}
  31.     for timer = 0,1000-s,s do
  32.         system.newTimer(function() t[#t+1] = system.newTimer(f,1000,true) end,1000+timer,false)
  33.     end
  34.     return t
  35. end
  36.  
  37. base64 = {}
  38. base64.base = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
  39. base64.to = function(str)
  40.     local str = {str:byte(1,#str)}
  41.     local code = {}
  42.     local bs
  43.     for i = 1,#str,3 do
  44.         bs = bit32.rshift(str[i] % 0xFD,2)
  45.         code[#code + 1] = base64.base:sub(bs + 1,bs + 1)
  46.         bs = bit32.lshift(str[i] % 0x04,4)
  47.         if (i + 1 <= #str) then
  48.             bs = bit32.bor(bs,bit32.rshift(str[i + 1] % 0xF1,4))
  49.             code[#code + 1] = base64.base:sub(bs + 1,bs + 1)
  50.             bs = bit32.lshift(str[i + 1] % 0x10,2)
  51.             if (i + 2 <= #str) then
  52.                 bs = bit32.bor(bs,bit32.rshift(str[i + 2] % 0xC1,6))
  53.                 code[#code + 1] = base64.base:sub(bs + 1,bs + 1)
  54.                 bs = str[i + 2] % 0x40
  55.                 code[#code + 1] = base64.base:sub(bs + 1,bs + 1)
  56.             else
  57.                 code[#code + 1] = base64.base:sub(bs + 1,bs + 1)
  58.                 code[#code + 1] = "="
  59.             end
  60.         else
  61.             code[#code + 1] = base64.base:sub(bs + 1, bs + 1)
  62.             code[#code + 1] = "=="
  63.         end
  64.     end
  65.     return table.concat(code)
  66. end
  67.  
  68. morse = {}
  69. morse.code = {a=".-",b="-...",c="-.-.",d="-..",e=".",f="..-.",g="--.",h="....",i="..",j=".---",k="-.-",l=".-..",m="--",n="-.",o="---",p=".--.",q="--.-",r=".-.",s="...",t="-",u="..-",v="...-",w=".--",x="-..-",y="-.--",z="--..",[1]=".----",[2]="..---",[3]="...--",[4]="....-",[5]=".....",[6]="-....",[7]="--...",[8]="---..",[9]="----.",[0]="-----"}
  70. morse.to = function(str)
  71.     str = str:lower()
  72.     str = str:gsub(" +"," / ")
  73.     for i,v in next,morse.code do
  74.         str = str:gsub(tostring(i),v.." ")
  75.     end
  76.     return str
  77. end
  78.  
  79. enigma = {}
  80. enigma.words = {
  81.     "Li4uIC4uLi4tIC0uIC0gLi4uLi0gIC8gLS0gLS0tLS0gLi4tIC4uLi4uIC4uLi0tIA==", -- s4nt4 m0u53
  82.     "LS0gLi4uLS0gLi0uIC4tLiAtLi0tICAvIC0uLS4gLi4uLiAuLS4gLi0tLS0gLi4uLi4gLSAtLSAuLi4uLSAuLi4uLiA=", -- m3rry chr15tm45
  83.     "Li4uLS0gLi0uLiAuLi0uICAvIC0tIC0tLS0tIC4uLSAuLi4uLiAuLi4tLSA=", -- 3lf m0u53
  84.     "Li4uLi4gLS4gLS0tLS0gLi0tIC0tIC4uLi4tIC0uIA==", --5n0wm4n
  85.     "LS4tLiAuLi4uIC4tLS0tIC0tIC0uIC4uLi0tIC0uLS0g", -- ch1mn3y
  86.     "Li4uLi4gLS4gLS0tLS0gLi0tICAvIC4uLS4gLi0uLiAuLi4uLSAtLi0gLi4uLS0gLi4uLi4g", -- 5n0w fl4k35
  87.    
  88. }
  89. enigma.verify = function(player,word)
  90.     if not info[player].db.titles[3] then
  91.         if info[player].db.enigma == base64.to(morse.to(word)) then
  92.             info[player].db.titles[3] = true
  93.             --system.giveEventGift(player,title[3])
  94.         end
  95.     end
  96. end
  97.  
  98. --[[ Database ]]--
  99. info = {}
  100.  
  101. serialization = {table={},string={}}
  102. serialization.table.tostring = function(t)
  103.     local str = ""
  104.     for index,value in next,t do
  105.         local prefix,tbOption = (type(value)=="string" and "_@" or type(value)=="boolean" and "_!" or type(value)=="number" and "_#" or type(value)=="table" and "_%" or ""),(type(value)~="table" and tostring(value) or "+&"..serialization.table.tostring(value):gsub(";","?").."&-")
  106.         str = str .. ':' .. tostring(index) .. prefix .. tbOption .. ";"
  107.     end
  108.     return str
  109. end
  110. serialization.string.totable = function(s)
  111.     local list = {}
  112.     for str in s:gmatch("(.-);") do
  113.         local varName,valueType,value = str:match(':(.-)_(%p)(.+)')
  114.         if varName~=nil then
  115.             varName = tonumber(varName) or varName
  116.             if valueType == "@" then
  117.                 list[varName] = tostring(value)
  118.             elseif valueType == "!" then
  119.                 list[varName] = value=="true"
  120.             elseif valueType == "#" then
  121.                 list[varName] = tonumber(value)
  122.             elseif valueType == "%" then
  123.                 list[varName] = serialization.string.totable(value:gsub("+&",""):gsub("&-",""):gsub("%?",";"))
  124.             end
  125.         end
  126.     end
  127.     return list
  128. end
  129. --[[
  130. eventPlayerDataLoaded = function(n,d)
  131.     if d ~= "" then
  132.         info[n].db = serialization.string.totable(d)
  133.     end
  134. end
  135. ]]
  136. --[[ Sets ]]--
  137. for i,f in next,{"AutoNewGame","AutoShaman","AfkDeath","DebugCommand","MinimalistMode","MortCommand"} do
  138.     tfm.exec["disable"..f]()
  139. end
  140.  
  141. local santaMessage = "<V><B>[S4NT4]</B> <R>%s!</R>\n<V><B>[S4NT4]</B> <VP>%s</VP>"
  142. local langue = {
  143.     en = "Merry Christmas",
  144.     fr = "Joyeux Noel",
  145.     br = "Feliz Natal",
  146.     es = "Feliz navidad",
  147.     tr = "Mutlu Noeller",
  148.     pl = "Wesołych Świąt",
  149.     hu = "Boldog Karácsonyt",
  150.     ro = "Craciun Fericit",
  151.     ar = "عيد ميلاد سعيد",
  152.     vk = "God Jul",
  153.     nl = "Vrolijk Kerstfeest",
  154.     id = "Selamat Natal",
  155.     de = "Fröhliche Weihnachten",
  156.     ru = "С Рождеством",
  157.     cn = "聖誕快樂",
  158.     ph = "Maligayang Pasko",
  159.     lt = "Linksmų Kalėdų",
  160.     jp = "メリークリスマス",
  161.     fi = "Hyvää Joulua",
  162.     it = "Buon Natale",
  163.     cz = "Veselé Vánoce",
  164.     hr = "Sretan Božić",
  165.     bg = "Весела Коледа",
  166.     lv = "Priecīgus Ziemassvētkus",
  167.     et = "Häid Jõule",
  168. }
  169. langue.pt = langue.br
  170. local communityMessage = langue.en
  171. for k,v in next,langue do
  172.     if k == tfm.get.room.community then
  173.         communityMessage = v
  174.         break
  175.     end
  176. end
  177.  
  178. --[[ Map ]]--
  179. system.start = false
  180. local xml = '<C><P DS="y;310" /><Z><S><S H="10" L="50" X="275" c="2" Y="165" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S L="200" X="100" H="80" Y="360" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S L="200" X="109" H="80" Y="379" T="12" P="0,0,0.3,0.2,-10,0,0,0" /><S X="391" L="230" H="80" c="3" Y="354" T="12" P="0,0,0.3,0.2,-2,0,0,0" /><S H="100" L="230" X="430" c="3" Y="411" T="12" P="0,0,0.3,0.2,-30,0,0,0" /><S H="80" L="180" X="705" c="3" Y="397" T="12" P="0,0,0.3,0.2,-2,0,0,0" /><S P="0,0,0.3,0.2,0,0,0,0" L="44" H="10" c="3" Y="361" T="13" X="237" /><S X="-5" L="10" H="3000" c="3" Y="100" T="12" P="0,0,0,0,0,0,0,0" /><S H="3000" L="10" X="805" c="3" Y="101" T="12" P="0,0,0,0,0,0,0,0" /><S L="10" X="400" H="3000" Y="-5" T="12" P="0,0,0,0,90,0,0,0" /><S L="80" H="10" X="96" Y="158" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S P="0,0,0.3,.9,0,0,0,0" L="50" X="275" c="3" Y="165" T="12" H="10" /><S L="130" X="527" H="10" Y="128" T="12" P="0,0,0.3,0.2,10,0,0,0" /><S L="90" H="10" X="632" Y="131" T="12" P="0,0,0.3,0.2,-10,0,0,0" /><S H="3000" L="10" o="23E9E9" X="805" c="2" Y="100" T="12" m="" P="0,0,0,2,0,0,0,0" /><S X="-5" L="10" o="23E9E9" H="3000" c="2" Y="100" T="12" m="" P="0,0,0,2,0,0,0,0" /><S P="0,0,0.3,0.2,-35,0,0,0" L="230" X="549" c="3" Y="467" T="12" H="100" /><S P="0,0,0.3,0.2,-55,0,0,0" L="230" H="100" c="3" Y="441" T="12" X="250" /><S L="230" X="125" H="100" Y="422" T="12" P="0,0,0.3,0.2,-30,0,0,0" /><S X="510" L="230" H="100" c="3" Y="477" T="12" P="0,0,0.3,0.2,-65,0,0,0" /><S L="50" X="91" H="50" Y="339" T="12" P="0,0,0.3,0.2,-45,0,0,0" /><S P="0,0,0.3,0.2,0,0,0,0" L="30" X="164" c="2" Y="325" T="12" H="50" /><S P="0,0,0.3,1.1,0,0,0,0" L="30" H="50" c="3" Y="325" T="12" X="164" /><S L="50" X="240" H="10" Y="158" T="12" P="0,0,0.3,0.2,0,0,0,0" /><S L="50" H="10" X="443" Y="125" T="12" P="0,0,0.3,0.2,-20,0,0,0" /><S H="80" L="220" o="23E9E9" X="393" c="1" Y="359" T="12" m="" P="0,0,0.3,0.2,-2,0,0,0" /><S L="230" o="23E9E9" X="427" H="100" Y="416" T="12" m="" P="0,0,0.3,0.2,-30,0,0,0" /><S P="0,0,0.3,0.2,-65,0,0,0" L="230" o="23E9E9" H="100" Y="481" T="12" m="" X="501" /><S P="0,0,0.3,0.2,-35,0,0,0" L="230" o="23E9E9" H="100" Y="474" T="12" m="" X="550" /><S P="0,0,0.3,0.2,-2,0,0,0" L="180" o="23E9E9" X="706" Y="404" T="12" m="" H="80" /><S P="0,0,0.3,0.2,1,0,0,0" L="230" o="23E9E9" X="314" c="2" Y="373" T="12" m="" H="100" /></S><D><P X="241" Y="507" T="51" P="0,1" /><P X="566" Y="449" T="46" P="0,0" /></D><O /></Z></C>'
  181. tfm.exec.newGame(xml)
  182.  
  183. --[[ Player ]]--
  184. system.displayBar = function(id,player,value,nvalue,color,sig,size,height)
  185.     sig = sig or ""
  186.     size = size or 100
  187.     height = height or 20
  188.  
  189.     ui.addTextArea(id,"",player,5,(height+8) * id,size + 4,height,0xC7CED2,1,1,true)
  190.     if value ~= 0 then
  191.         ui.addTextArea(id.."0","",player,6,(height+8) * id + 2,nvalue + 2,height - 4,color,color,1,true)
  192.     end
  193.     ui.addTextArea(id.."00","<B><font color='#0'>"..value..sig,player,(size-20)/2,(height+8) * id + 1,50,height,1,1,0,true)
  194. end
  195. system.updateBar = function(n,giftColor)
  196.     giftColor = giftColor or info[n].lastColor
  197.     system.displayBar(1,n,(type(info[n].db.aim)=="number" and math.floor(info[n].db.gifts[2]) .. " / "..info[n].db.aim or info[n].db.aim),math.percent(info[n].db.gifts[2],(type(info[n].db.aim)=="number" and info[n].db.aim or 10),100),0xFF0000)
  198.     system.displayBar(2,n,info[n].db.gifts[1],math.percent(info[n].db.gifts[1],50,50),giftColor,"G",50,20)
  199. end
  200.  
  201. eventNewGame = function()
  202.     if system.start then
  203.         system.exit()
  204.     else
  205.         system.start = true
  206.         tfm.exec.snow(60 * 2.5)
  207.         tfm.exec.addImage("158c1feaf90.png","?0",0,0)
  208.         tfm.exec.setGameTime(60 * 2.5)
  209.         ui.setMapName("<J>#Christmas")
  210.         ui.setShamanName("<R>S4NT4 M4U5")
  211.         for k,v in next,tfm.get.room.playerList do
  212.             info[k] = {
  213.                 db = {
  214.                     gifts = {0,0},
  215.                     aim = 5,
  216.                     titles = {false,false,false},
  217.                     enigma = table.random(enigma.words),
  218.                 }
  219.             }
  220.             --system.loadPlayerData(k)
  221.             info[k].catch = 0
  222.             info[k].duck = {0,0}
  223.             info[k].lastColor = 0xB73535
  224.  
  225.             if not v.isDead then
  226.                 system.bindKeyboard(k,32,true,true)
  227.                 system.bindKeyboard(k,3,true,true)
  228.             end
  229.  
  230.             system.updateBar(k)
  231.  
  232.             tfm.exec.chatMessage(santaMessage:format(communityMessage:upper(),"@"..info[k].db.enigma),k)
  233.         end
  234.     end
  235. end
  236.  
  237. eventPlayerDied = function(n)
  238.     if system.start then
  239.         system.bindKeyboard(n,32,true,false)
  240.         system.bindKeyboard(n,3,true,false)
  241.     end
  242. end
  243.  
  244. eventNewPlayer = function(n)
  245.     tfm.exec.addImage("158c1feaf90.png","?0",0,0,n)
  246. end
  247.  
  248. --[[ AI ]]---
  249. local despawnObjects = {}
  250.  
  251. local currentGifts = {}
  252. local gifts = {
  253.     [1] = {
  254.         [1] = "158bb1db61b",
  255.         [2] = 15000,
  256.     };
  257.     [2] = {
  258.         [1] = "158bb1c95e0",
  259.         [2] = 10000,
  260.     };
  261.     [3] = {
  262.         [1] = "158bb1cc6ec",
  263.         [2] = 6000,
  264.     };
  265.     [4] = {
  266.         [1] = "158bb1ce1aa",
  267.         [2] = 3000,
  268.     };
  269. }
  270.  
  271. local noel = {}
  272. local initx,inity = 240,140
  273. noel.x = initx
  274. noel.y = inity
  275.  
  276. noel.isEscaping = false
  277. noel.isTired = {0,false}
  278.  
  279. noel.timers = {
  280.     teleport = 0,
  281.     prize = 0
  282. }
  283.  
  284. noel.img = {
  285.     tired = {"158bb1dccb6","158bb1cf9a8","158bb1d6489","158bb1e2518"},
  286.     right = "158bb1d8069",
  287.     left = "158bb1e0daf",
  288.     flying = "158bb1d470a",
  289.     stop = "158bb1d9b67",
  290. }
  291.  
  292. noel.updateImage = function(img)
  293.     tfm.exec.removeImage(noel.imgId)
  294.     noel.imgId = tfm.exec.addImage(img..".png","#"..noel.id,-23,-32)
  295. end
  296. noel.particles = function(id)
  297.     for i = 1,5 do
  298.         tfm.exec.displayParticle(id,noel.x + math.random(-50,50),noel.y + math.random(-50,50),table.random({-.2,.2}),table.random({-.2,.2}))
  299.     end
  300. end
  301. noel.move = function(x,y)
  302.     tfm.exec.moveObject(noel.id,0,0,false,x,y,false)
  303. end
  304.  
  305. noel.nearMouse = function(range)
  306.     local player = {"",{dist=math.random(800),x=0,y=0}}
  307.     for k,v in next,tfm.get.room.playerList do
  308.         if not v.isDead then
  309.             if math.pythag(v.x,v.y,noel.x,noel.y,range) then
  310.                 local m = v.x-noel.x
  311.                 if math.abs(m) < player[2].dist then
  312.                     player = {k,{dist=m,x=v.x,y=v.y}}
  313.                 end
  314.             end
  315.         end
  316.     end
  317.     noel.isEscaping = player[1] ~= ""
  318.     return player
  319. end
  320.  
  321. noel.escape = function(id)
  322.     local player = noel.nearMouse(math.random(80,100))
  323.     local mul = (player[1] ~= "" and (player[2].dist < 0 and 1 or -1) or table.random({-1,1}))
  324.     local img = (mul < 0 and "left" or "right")
  325.     local rand = 9 - math.random(0,9)
  326.     if id == 0 or (rand < 6) then
  327.         noel.move(mul * math.random(50,80),0)
  328.         noel.updateImage(noel.img[img])
  329.     elseif id == 1 or (rand < 9) then
  330.         noel.move(mul * math.random(60,70),-80)
  331.         noel.updateImage(table.random({noel.img[img],noel.img.flying}))
  332.     elseif id == 2 or rand == 9 then
  333.         noel.move(mul * math.random(10,20),-math.random(70,100))
  334.         noel.updateImage(noel.img.flying)
  335.     end
  336. end
  337. noel.meep = function()
  338.     tfm.exec.displayParticle(20,noel.x,noel.y)
  339.     tfm.exec.explosion(noel.x,noel.y,20,50)
  340. end
  341. noel.cannon = function()
  342.     local player = noel.nearMouse(100)
  343.     if player[1] ~= "" then
  344.         local x = noel.x + (noel.x > player[2].x and -40 or 40)
  345.         local y = noel.y + (noel.y > player[2].y and -40 or 40)
  346.         local angle = math.deg(math.atan2(player[2].y-noel.y,player[2].x-noel.x)) + 90
  347.         table.insert(despawnObjects,{
  348.             [1] = tfm.exec.addShamanObject(1703,x,y,angle),
  349.             [2] = os.time() + 3000
  350.         })
  351.         local effect = function(id,sx,sy,xs,ys,e)
  352.             for i = 1,2 do
  353.                 tfm.exec.displayParticle(id[i] and id[i] or id[1],x + sx * e,y - sy * e,xs/1.5,ys/1.5)
  354.             end
  355.         end
  356.         for i = 1,20 do
  357.             effect({9,11},math.cos(i),math.sin(i),math.cos(i),-math.sin(i),22)
  358.             effect({13},math.cos(i),math.sin(i),math.sin(i),math.cos(i),19)
  359.         end
  360.     end
  361. end
  362. noel.teleport = function()
  363.     if os.time() > noel.timers.teleport then
  364.         noel.timers.teleport = os.time() + 8000
  365.         tfm.exec.displayParticle(37,noel.x,noel.y)
  366.         local x,y = math.random(10,790),math.random(50,300)
  367.         tfm.exec.moveObject(noel.id,x,y)
  368.         tfm.exec.displayParticle(37,x,y)
  369.     else
  370.         noel.escape(2)
  371.     end
  372. end
  373.  
  374. noel.gift = function()
  375.     if os.time() > noel.timers.prize then
  376.         noel.timers.prize = os.time() + 5000
  377.         noel.updateImage(noel.img.stop)
  378.         local gift = table.random({2,4,3,1})
  379.         for k,v in next,gifts do
  380.             if gift == k then
  381.                 gift = k
  382.                 break
  383.             end
  384.         end
  385.         local gen = {}
  386.         gen[1] = tfm.exec.addShamanObject(6300,noel.x,noel.y)
  387.         gen[2] = os.time() + gifts[gift][2]
  388.         gen[3] = tfm.exec.addImage(gifts[gift][1]..".png","#"..gen[1],-15,-15)
  389.         gen[4] = gift
  390.         table.insert(currentGifts,gen)
  391.     else
  392.         noel.escape(0)
  393.     end
  394. end
  395. noel.tired = function(timer)
  396.     if os.time() > noel.timers.prize then
  397.         noel.isTired[1] = os.time() + 8000
  398.     else
  399.         noel.escape(2)
  400.     end
  401. end
  402.  
  403. eventLoop = function(currentTime)
  404.     if system.start and (currentTime/1000)>4 then
  405.         if not noel.id then
  406.             noel.id = tfm.exec.addShamanObject(6300,noel.x,noel.y)
  407.             noel.updateImage(noel.img.stop)
  408.         end
  409.  
  410.         local ox,oy
  411.         if tfm.get.room.objectList[noel.id] then
  412.             ox,oy = tfm.get.room.objectList[noel.id].x,tfm.get.room.objectList[noel.id].y
  413.         else
  414.             ox,oy = noel.x,noel.y
  415.         end
  416.  
  417.         if (ox < -10 or ox > 810) or (oy > 400 or oy < -50) then
  418.             tfm.exec.removeObject(noel.id)
  419.             noel.x,noel.y = initx,inity
  420.             noel.id = nil
  421.         end
  422.  
  423.         if noel.id then
  424.             noel.x = ox
  425.             noel.y = oy
  426.         end
  427.  
  428.         for k,v in ipairs(despawnObjects) do
  429.             if os.time() > v[2] then
  430.                 tfm.exec.removeObject(v[1])
  431.             end
  432.         end
  433.         for k,v in ipairs(currentGifts) do
  434.             if os.time() > v[2] then
  435.                 tfm.exec.removeObject(v[1])
  436.                 tfm.exec.removeImage(v[3])
  437.             end
  438.         end
  439.  
  440.         if os.time() > noel.isTired[1] then
  441.             noel.particles(13)
  442.             if math.floor(currentTime/1000) % 24 == 0 then
  443.             noel.tired()
  444.             elseif math.floor(currentTime/1000) % 10 == 0 then
  445.                 noel.gift()
  446.                 noel.escape(1)
  447.             elseif math.floor(currentTime/1000) % 2 == 0 then
  448.                 local option = math.random((noel.isEscaping and 15 or 10))
  449.                 if option > 3 then
  450.                     noel.escape()
  451.                 else
  452.                     noel.updateImage(noel.img.stop)
  453.                     if (currentTime/1000)>7 and math.random(1,2) == 1 then
  454.                         if option == 3 then
  455.                             noel.cannon()
  456.                         elseif option == 2 then
  457.                             noel.teleport()
  458.                         elseif option == 1 then
  459.                             noel.meep()
  460.                         end
  461.                     end
  462.                 end
  463.             else
  464.                 noel.updateImage(noel.img.stop)
  465.             end
  466.         else
  467.             noel.particles(1)
  468.             if not noel.isTired[2] then
  469.                 noel.isTired[2] = true
  470.                 noel.timers.prize = os.time() + 5000
  471.                 local imgId = #noel.img.tired
  472.                 local animation = {}
  473.                 local numb = 1
  474.                 animation = system.looping(function()
  475.                     noel.updateImage(noel.img.tired[imgId])
  476.  
  477.                     if imgId == #noel.img.tired or imgId == 1 then
  478.                         numb = -numb
  479.                     end
  480.  
  481.                     imgId = imgId + numb
  482.  
  483.                     if (os.time()+250) > noel.isTired[1] then
  484.                         for k,v in next,animation do
  485.                             system.removeTimer(v)
  486.                         end
  487.                         noel.isTired[2] = false
  488.                     end
  489.                 end,9)
  490.             end
  491.         end
  492.     end
  493. end
  494.  
  495. eventKeyboard = function(n,k,d,x,y)
  496.     if system.start then
  497.         if os.time() > info[n].catch and k == 32 then
  498.             if os.time() < noel.isTired[1] then
  499.                 if math.pythag(x,y,noel.x,noel.y,32) then
  500.                     info[n].db.gifts[2] = (info[n].db.gifts[1]/10) + info[n].db.gifts[2]
  501.                     info[n].db.gifts[1] = 0
  502.                    
  503.                     if not info[n].db.titles[1] then
  504.                         if info[n].db.gifts[2] >= 5 then
  505.                             info[n].db.aim = 10
  506.                             info[n].db.titles[1] = true
  507.                             --system.giveEventGift(n,title[1])
  508.                         end
  509.                     end
  510.                     if not info[n].db.titles[2] then
  511.                         if info[n].db.gifts[2] >= 10 then
  512.                             info[n].db.aim = "<font letterSpacing='5'>!!!!!!"
  513.                             info[n].db.titles[2] = true
  514.                             --system.giveEventGift(n,title[2])
  515.                         end
  516.                     end
  517.  
  518.                     --system.savePlayerData(n,serialization.table.tostring(info[n].db))
  519.  
  520.                     system.updateBar(n)
  521.                 end
  522.             else
  523.                 for k,v in next,currentGifts do
  524.                     local o = tfm.get.room.objectList[v[1]]
  525.                     if o and math.pythag(x,y,o.x,o.y,25) then
  526.                         if (info[n].db.gifts[1]+v[4]) <= 50 then
  527.                             tfm.exec.removeObject(v[1])
  528.                             tfm.exec.removeImage(v[3])
  529.                             currentGifts[k][2] = 0
  530.                             info[n].db.gifts[1] = info[n].db.gifts[1] + v[4]
  531.  
  532.                             --system.savePlayerData(n,serialization.table.tostring(info[n].db))
  533.  
  534.                             system.updateBar(n,({0xB73535,0x358CB7,0x35B765,0xB7B735})[v[4]])
  535.                             break
  536.                         end
  537.                     end
  538.                 end
  539.             end
  540.             info[n].catch = os.time() + 1500
  541.         end
  542.         if k == 3 then
  543.             if y > 294 then
  544.                 if os.time() > (info[n].duck[1]+3500) then
  545.                     info[n].duck = {os.time() + 600,0}
  546.                 else
  547.                     if os.time() > info[n].duck[1] then
  548.                         info[n].duck[1] = os.time() + 600
  549.                         info[n].duck[2] = info[n].duck[2] + 1
  550.                         if info[n].duck[2] % 30 == 0 then
  551.                             --tfm.exec.giveConsumables(n,4)
  552.                         end
  553.                     end
  554.                 end
  555.             end
  556.         end
  557.     end
  558. end
  559.  
  560. eventChatMessage = function(n,c)
  561.     if system.start and c:sub(1,1) == "@" then
  562.         if os.time() > noel.isTired[1] then
  563.             if math.pythag(tfm.get.room.playerList[n].x,tfm.get.room.playerList[n].y,noel.x,noel.y,32) then
  564.                 enigma.verify(n,c)
  565.             end
  566.         end
  567.     end
  568. end
Advertisement
Add Comment
Please, Sign In to add comment