Zerveorus

MICE.IO BY:MIIICLAROO

Feb 17th, 2017
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 10.96 KB | None | 0 0
  1. powersData = {
  2.             "<font color='#1300FF' ><a href='event:snow'>snow",
  3.             "<font color='#1300FF' ><a href='event:double'>double",
  4.             "<font color='#1300FF' ><a href='event:strong'>strong",
  5.             "<font color='#1300FF' ><a href='event:arrow'>arrow",
  6.             "<font color='#1300FF' ><a href='event:speed'>speed",
  7.             "<font color='#1300FF' ><a href='event:delay'>delay",
  8.             "<font color='#1300FF' ><a href='event:box'>box",
  9.             "<font color='#1300FF' ><a href='event:table'>table",
  10.             "<font color='#1300FF' ><a href='event:back'>back"
  11. }
  12. text = {
  13.     welcome = "<font color='#F00500'>welcome</font><font color='#FFFFFF'> to <font color='#1300FF'>Mice.io",
  14.     help ={
  15.             "<br><br><br><b><font color='#FFFFFF'>MiniGame developed<br> by :</font> <J>Miiiclaroo</J>",
  16.             "<br><b>Objective:</b><br><font color='#FFFFFF'>Collect the points around the map to get powers",
  17.             "<br><br><b>Controls: </b><br><font color='#FFFFFF'>space : shot!<br>E or S (Down key): collect points",
  18.             "<br><b>Powers:</b><br>Speed : Give your mouse a boost<br>Delay : Your shots are more faster<br>Double : Give you an extra shot(forward)<br>back : give you an backward shot",
  19.             "<br><b>Guns:</b><br>Snow : (my favorite) A snowball<br>Cupid arrow : The name says it <br>Table : mini-table killer<br>Box : The name says it (x2) "
  20.             }
  21. }
  22. --points data
  23. local pointId = 10000000
  24. local pointTime = 0
  25. local pointT = false
  26. local points = {}
  27. local pointsOnMap = 0
  28. local maxPoints = 30
  29.  
  30. --mice data
  31. local miceId = 0
  32. local mice = {}
  33. local isFacingLeft={}
  34. local fireTS={}
  35. local admin="Miiiclaroo#0000"
  36.  
  37. --others
  38. toDespawn={}
  39.  
  40. function main()
  41. tfm.exec.disableAutoShaman()
  42. tfm.exec.disableAutoScore ()
  43. tfm.exec.disableAutoNewGame()
  44. tfm.exec.disableAfkDeath()
  45. tfm.exec.snow(2,50)
  46. system.disableChatCommandDisplay ("help")
  47. end
  48.  
  49. function eventNewGame()
  50.     for n in pairs(tfm.get.room.playerList)do
  51.         tfm.exec.setPlayerScore (n,0,false)
  52.         mice[n].points=0
  53.         close(n)
  54.         restartData(n)
  55.     end
  56. end
  57.  
  58. function eventNewPlayer(name)
  59.     system.bindKeyboard(name,113,true,true)
  60.     system.bindKeyboard(name,69,true,true)
  61.     system.bindKeyboard(name,32,true,true)
  62.     system.bindKeyboard(name,2,true,true)
  63.     system.bindKeyboard(name,0,true,true)
  64.     system.bindKeyboard(name,3,true,true)
  65. miceId = miceId +1
  66. if not mice[name] then
  67.     mice[name] = {
  68.             id = miceId,
  69.             points = 1,
  70.             force = 1,
  71.             angle = 0,
  72.             f = 20,
  73.             gun = 0,
  74.             x=0,
  75.             shots=1,
  76.             speed = 0,
  77.             FDelay= 3,
  78.             delay=2,
  79.             reload = false,
  80.             back = false,
  81.             respawn = 9,
  82.             dead = false,
  83.             welcome = true,
  84.             page = 1
  85. }
  86. end
  87. fireTS[name] = 0
  88. tfm.exec.respawnPlayer(name)
  89. ui.addTextArea(mice[name].id+1500,"<p align='center'><font size = '37'>"..text.welcome,name,200,150,400,50,0x61A277,0xF00500,0.5,true)
  90. ui.addTextArea(mice[name].id+500,"<p align= 'center'><a href='event:close'>X",name,580,120,20,20,0xF00500,0x61A277,0.5,true)
  91. end
  92.  
  93. function eventKeyboard(name,key,down,px,py)
  94. if mice[name] then
  95. local mouse = mice[name]
  96. local x,f
  97. if key == 0 and not isFacingLeft[name] then
  98.     mouse.x,mouse.force = -30,-mice[name].f
  99.     isFacingLeft[name] = true
  100.     mice[name].angle = 180
  101. elseif key == 0 then
  102.     tfm.exec.movePlayer(name,0,0,false,-mice[name].speed,0,true)
  103. elseif key == 2 and isFacingLeft[name]then
  104.     mouse.x,mouse.force = 30,mice[name].f
  105.     isFacingLeft[name] = false
  106.     mice[name].angle = 0
  107. elseif key == 2 then
  108.     tfm.exec.movePlayer(name,0,0,false,mice[name].speed,0,true)
  109. end
  110. if key == 69 or key == 3 then
  111.     for i in pairs (points) do
  112.         if px > points[i][2]-20 and px < points[i][2]+20 then
  113.             if py > points[i][3]-20 and py < points[i][3]+20 then
  114.                 ui.removeTextArea(points[i][1])
  115.                 points[i]={0,-100,-100}
  116.                 tfm.exec.setPlayerScore (name,1,true)
  117.                 mice[name].points = mice[name].points +1
  118.                 pointsOnMap = pointsOnMap - 1
  119.                 level(name)
  120.                 break
  121.             end
  122.         end
  123.     end
  124. end
  125. if key == 32 and not mice[name].reload and not mice[name].back then
  126. fireTS[name] = os.time()
  127.     for i = 1,mouse.shots do
  128.         id = tfm.exec.addShamanObject(mouse.gun,px+mouse.x,py,mouse.angle,mouse.force)
  129.         table.insert(toDespawn,{id,os.time()})
  130.     end
  131.     mice[name].reload=true
  132.  
  133. end
  134. if key == 32 and not mice[name].reload and mice[name].back then
  135.         fireTS[name] = os.time()
  136.     for i = 1,mouse.shots do
  137.         id = tfm.exec.addShamanObject(mouse.gun,px+mouse.x,py,mouse.angle,mouse.force)
  138.         table.insert(toDespawn,{id,os.time()})
  139.     end
  140.         ad = tfm.exec.addShamanObject(mouse.gun,px+(-mouse.x),py,-mouse.angle,-mouse.force)
  141.         mice[name].reload=true
  142.         table.insert(toDespawn,{ad,os.time()})
  143.  
  144. end
  145. if key == 113 and name==admin then
  146.     tfm.exec.newGame('<C><P aie="" L="1600" H="800" /><Z><S><S L="1600" X="800" H="20" Y="790" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="50" H="715" X="1575" Y="399" T="9" P="0,0,,,,0,0,0" /><S L="50" X="800" H="156" Y="702" T="9" P="0,0,,,,0,0,0" /><S L="600" X="400" H="25" Y="180" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="600" H="25" X="1200" Y="180" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="50" X="1201" H="156" Y="90" T="9" P="0,0,,,,0,0,0" /><S L="50" H="156" X="400" Y="90" T="9" P="0,0,,,,0,0,0" /><S L="600" X="1200" H="25" Y="156" T="9" P="0,0,,,,0,0,0" /><S L="600" H="25" X="400" Y="156" T="9" P="0,0,,,,0,0,0" /><S L="1600" H="30" X="800" Y="765" T="9" P="0,0,,,,0,0,0" /><S L="50" H="156" X="1200" Y="702" T="9" P="0,0,,,,0,0,0" /><S L="50" H="156" X="400" Y="702" T="9" P="0,0,,,,0,0,0" /><S L="50" X="25" H="715" Y="399" T="9" P="0,0,,,,0,0,0" /><S L="90" H="25" X="800" Y="425" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="139" H="51" X="550" Y="360" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="139" X="250" H="51" Y="360" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="139" X="1050" H="51" Y="361" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="139" H="51" X="1350" Y="361" T="0" P="0,0,0.3,0.2,0,0,0,0" /><S L="48" H="122" X="1200" Y="416" T="9" P="0,0,,,,0,0,0" /><S L="48" X="690" H="122" Y="416" T="9" P="0,0,,,,0,0,0" /><S L="48" X="910" H="122" Y="416" T="9" P="0,0,,,,0,0,0" /><S L="48" X="400" H="122" Y="416" T="9" P="0,0,,,,0,0,0" /></S><D><DS Y="400" X="800" /></D><O /></Z></C>')
  147. end
  148. end
  149. end
  150.  
  151. for n in pairs (tfm.get.room.playerList) do
  152.     eventNewPlayer(n)
  153. end
  154.  
  155. function eventLoop(t,tr)
  156. if pointsOnMap < maxPoints then
  157.     pointTime = pointTime+1
  158. if pointTime == 8 then
  159.     pointTime=0
  160.     makePoint()
  161.     makePoint()
  162. end
  163. end
  164.     for i,o in ipairs(toDespawn) do
  165.         if os.time()> o[2]+2000 then
  166.              tfm.exec.removeObject (o[1])
  167.                 table.remove (toDespawn, i)
  168.         end
  169.     end
  170.  
  171. for name in pairs(tfm.get.room.playerList)do
  172. if mice[name]then
  173. if mice[name].dead then
  174.     mice[name].respawn = mice[name].respawn-1
  175.     if mice[name].respawn == 0 then
  176.         tfm.exec.respawnPlayer(name)
  177.         mice[name].respawn = 9
  178.         mice[name].dead = false
  179.     end
  180. end
  181.     if mice[name].reload then
  182.         mice[name].FDelay = mice[name].FDelay -1
  183.         if mice[name].FDelay == 0 then
  184.             mice[name].FDelay = mice[name].delay
  185.             mice[name].reload=false
  186.         end
  187.     end
  188. end
  189. end
  190. end
  191.  
  192. function makePoint()
  193. local psx = math.random(1600)
  194. local psy = math.random(50,770)
  195. local id
  196.     ui.addTextArea(pointId,"<font color='#FFFFFF'><font size ='11'>+1",nil,psx,psy,20,20,0x6A7495,0xFFFFF,0.5)
  197.     id = {pointId,psx,psy}
  198.     table.insert(points,id)
  199.     pointId = pointId+1
  200.     pointsOnMap = pointsOnMap+1
  201. end
  202.  
  203. function restartData(name)
  204.     tfm.exec.setPlayerScore (name,0,false)
  205.     mice[name].points = 0
  206.     mice[name].force = 0
  207.     mice[name].angle = 0
  208.     mice[name].f = 20
  209.     mice[name].gun = 0
  210.     mice[name].x=0
  211.     mice[name].shots=1
  212.     mice[name].speed = 0
  213.     mice[name].delay = 3
  214.     mice[name].back = false
  215. close(name)
  216. end
  217.  
  218. function eventPlayerDied(name)
  219. if mice[name] then
  220. mice[name].dead = true
  221. restartData(name)
  222. end
  223. end
  224.  
  225. function level(name)
  226.     if mice[name].points == 2 then
  227.         showPowers(name)
  228.     elseif mice[name].points == 4 then
  229.         showPowers(name)
  230.     elseif mice[name].points == 6 then
  231.         showPowers(name)
  232.     elseif mice[name].points == 8 then
  233.         showPowers(name)
  234.     elseif mice[name].points == 12 then
  235.         showPowers(name)
  236.     elseif mice[name].points == 16 then
  237.         showPowers(name)
  238.     elseif mice[name].points == 20 then
  239.         showPowers(name)
  240.     elseif mice[name].points == 24 then
  241.         showPowers(name)
  242.     elseif mice[name].points == 28 then
  243.         showPowers(name)
  244.     elseif mice[name].points == 34 then
  245.         showPowers(name)
  246.     elseif mice[name].points == 40 then
  247.         showPowers(name)
  248.     elseif mice[name].points == 45 then
  249.         showPowers(name)
  250.     elseif mice[name].points == 50  then
  251.         showPowers(name)
  252.     elseif mice[name].points == 56 then
  253.         showPowers(name)   
  254. elseif mice[name].points == 62 then
  255.         showPowers(name)
  256. elseif mice[name].points == 69 then
  257.         showPowers(name)
  258. elseif mice[name].points == 78 then
  259.         showPowers(name)
  260. elseif mice[name].points == 89 then
  261.         showPowers(name)
  262.     end
  263. end
  264.  
  265. function showPowers(name)
  266.     ui.addTextArea(mice[name].id,""..powersData[math.random(#powersData)].."",name,275,350,50,25,0xFFFFFF,0,0.5,true)
  267.     ui.addTextArea(mice[name].id+100,""..powersData[math.random(#powersData)].."",name,375,350,50,25,0xFFFFFF,0,0.5,true)
  268.     ui.addTextArea(mice[name].id+200,""..powersData[math.random(#powersData)].."",name,475,350,50,25,0xFFFFFF,0,0.5,true)
  269. end
  270. function close(name)
  271.         ui.removeTextArea(mice[name].id)
  272.         ui.removeTextArea(mice[name].id+100)
  273.         ui.removeTextArea(mice[name].id+200)
  274.  
  275. end
  276.  
  277. function eventTextAreaCallback(id,name,cb)
  278.     if cb == "strong" then
  279.         mice[name].f = mice[name].f +2
  280. close(name)
  281.     elseif cb == "arrow" then
  282.         mice[name].gun = 35
  283. close(name)
  284.     elseif cb == "snow" then
  285.         mice[name].gun = 34
  286. close(name)
  287.     elseif cb == "double" then
  288.         if mice[name].shots>= 4 then return end
  289.         mice[name].shots=mice[name].shots+1
  290. close(name)
  291.     elseif cb == "speed" then
  292.         if mice[name].speed >= 20 then return end
  293.         mice[name].speed = mice[name].speed+5
  294.         mice[name].x = mice[name].x +10
  295. close(name)
  296.     elseif cb == "delay" then
  297.         if mice[name].delay <= 1 then return end
  298.         mice[name].delay = mice[name].delay-1
  299. close(name)
  300.     elseif cb == "box" then
  301.         mice[name].gun = 1
  302. close(name)
  303.     elseif cb == "table" then
  304.         mice[name].gun = 60
  305. close(name)
  306.     elseif cb == "back" then
  307.         if mice[name].back  then return end
  308.         mice[name].back=true
  309. close(name)
  310.     end
  311. if cb == "close" then
  312.     ui.removeTextArea(mice[name].id+500)
  313.     ui.removeTextArea(mice[name].id+1000)
  314.     ui.removeTextArea(mice[name].id+1500)
  315.     ui.removeTextArea(mice[name].id+2000)
  316.     mice[name].page =1
  317. elseif cb == "next" then
  318. if mice[name].page < 5 then
  319.     mice[name].page = mice[name].page+1
  320. end
  321.     ui.updateTextArea (mice[name].id+1500,"<p align='center'><font size = '12'>"..text.help[mice[name].page],name)
  322. end
  323. end
  324.  
  325. function eventPlayerRespawn(name)
  326.     showPowers(name)
  327. end
  328.  
  329. function eventChatCommand(name,command)
  330. print(name)
  331.     if command == "help" then
  332.         ui.addTextArea(mice[name].id+1500,"<p align='center'><font size = '12'>"..text.help[1],name,300,90,150,200,0x61A277,0xF00500,0.5,true)
  333.         ui.addTextArea(mice[name].id+500,"<p align= 'center'><a href='event:close'>X",name,460,90,20,20,0x61A277,0xF00500,0.5,true)
  334.         ui.addTextArea(mice[name].id+2000,"<a href='event:next'><font color='#FFFFFF'>next",name,370,297,0,0,0x61A277,0xF00500,0.5,true)
  335.     end
  336. end
  337.  
  338. function eventPlayerLeft (name)
  339.     mice[name]= nil
  340. end
  341. main()
Advertisement
Add Comment
Please, Sign In to add comment