Advertisement
Dudugz-Contistente

Untitled

Sep 1st, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.10 KB | None | 0 0
  1. local _B = {
  2. x = 40,
  3. y = 20,
  4. w = 132,
  5. h = 132,
  6. speed = 13,
  7. }
  8. local _D = {
  9. x = {},
  10. y = {},
  11. }
  12. local _S = {}
  13.  
  14. function eventNewPlayer(name)
  15.  
  16. _S[name] = {
  17. immortality = {time=3000,clock=os.time()}
  18. }
  19. end
  20. table.foreach(tfm.get.room.playerList, eventNewPlayer)
  21.  
  22. function eventPlayerRespawn(name)
  23. _S[name].immortality = {time=3000,clock=os.time()}
  24. end
  25.  
  26. function update(t)
  27. if t == 'start' then
  28. tfm.exec.addPhysicObject(1, _B.x, _B.y, {
  29. type = 12,
  30. width = _B.w,
  31. height = _B.h,
  32. color = 0x000000,
  33. })
  34. elseif t == 'move' then
  35. if #_D.x > 0 and #_D.y > 0 then
  36. if _B.x < _D.x[1] or _B.x > _D.x[1] and _B.y < _D.y[1] or _B.y > _D.y[1] then
  37. _B.x = math.random(10,790)
  38. _B.y = math.random(20,360)
  39. end
  40. end
  41. ui.addTextArea(0, "<p align='center'><font size='20'><bl><b>Pac-Man", nil, _B.x-_B.w/2+10, _B.y-_B.h/2+35, _B.w, _B.h, nil, nil, 50, true)
  42. tfm.exec.addPhysicObject(1, _B.x, _B.y, {
  43. type = 12,
  44. width = _B.w,
  45. height = _B.h,
  46. color = 0x000000,
  47. })
  48. end
  49. end
  50.  
  51. function eventLoop(et, rt)
  52. _D.x = {}
  53. _D.y = {}
  54.  
  55. ui.addTextArea(0, "<p align='center'><font size='20'><bl><b>Pac-Man", nil, _B.x-_B.w/2+10, _B.y-_B.h/2+35, _B.w, _B.h, nil, nil, 50, true)
  56.  
  57. for k,v in next,tfm.get.room.playerList do
  58. if not v.isDead then
  59. table.insert(_D.x, math.random(10,790))
  60. table.insert(_D.y, math.random(20,360))
  61. end
  62. if not v.isDead and _B.x + _B.w/2+25 >= v.x and _B.x - _B.w/2-25 <= v.x and _B.y + _B.h/2+25 >= v.y and _B.y - _B.h/2-25 <= v.y then
  63. if _S[k].immortality.clock <= os.time()-_S[k].immortality.time then
  64. tfm.exec.killPlayer(k)
  65. end
  66. end
  67. end
  68. table.sort(_D.x, function(a,b)
  69. return (a - _B.x) > (b - _B.x)
  70. end)
  71. table.sort(_D.y, function(a,b)
  72. return (a - _B.y) > (b - _B.y)
  73. end)
  74. update('move')
  75.  
  76. local et, rt = (et/1000), (rt/1000)
  77.  
  78. if rt <= 0 then
  79. tfm.exec.newGame(mapas[math.random(#mapas)],nil)
  80. end
  81. end
  82.  
  83. update('start')
  84. p={}
  85. function eventNewPlayer(name)
  86. p[name]={
  87. tempo = os.time()
  88. }
  89. system.bindKeyboard(name,32,true,true)
  90. end
  91.  
  92. for all in pairs(tfm.get.room.playerList) do
  93. eventNewPlayer(all)
  94. end
  95.  
  96. function eventKeyboard(name,key,down,x,y)
  97. if key == 32 and p[name].tempo < os.time()-1200 then
  98. tfm.exec.movePlayer(name, 0, 0, false, 0, -60, true)
  99. p[name].tempo = os.time();
  100. end
  101. end
  102.  
  103. function eventNewGame()
  104. _B.x = 40
  105. _B.y = 20
  106.  
  107. tfm.exec.setUIMapName("<b><r>Block<bv>Black")
  108. end
  109.  
  110. function eventPlayerDied(name)
  111. local a = 0
  112.  
  113. for k,v in next,tfm.get.room.playerList do
  114. if not v.isDead then
  115. a = a + 1
  116. end
  117. end
  118.  
  119. if a < 1 then
  120. tfm.exec.newGame(mapas[math.random(#mapas)],nil)
  121. end
  122. end
  123.  
  124. tfm.exec.disableAutoShaman()
  125. tfm.exec.disableAutoNewGame()
  126. mapas = {"@7152091","@7173018","@7204773","@7206484","@7200714","@7245483","@7242570","@7242433","@7220692","@7250092","@7231239","@7230247"}
  127. tfm.exec.newGame(mapas[math.random(#mapas)],nil)
  128.  
  129. function eventChatCommand(n,m)
  130. if(m:sub(0,3) == "msg") then
  131. if n == "Uhzinhooo" then
  132. tfm.exec.chatMessage("<VP><b>• [Uhzinhooo]</b> "..m:sub(5).."",nil) end end end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement