Bolodefchoco_LUAXML

[Script] Balls

Aug 9th, 2018
456
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.09 KB | None | 0 0
  1. table.random = function(tbl)
  2.     return tbl[math.random(#tbl)]
  3. end
  4.  
  5. local getRandomPlayer = function()
  6.     local players = { }
  7.     for k, v in next, tfm.get.room.playerList do
  8.         if not v.isDead then
  9.             players[#players + 1] = k
  10.         end
  11.     end
  12.     return table.random(players)
  13. end
  14.  
  15. local target_timer, target = os.time()
  16. eventNewGame = function()
  17.     if tfm.get.room.uniquePlayers == 1 then
  18.         tfm.exec.chatMessage("<ROSE>This game needs at least two players.")
  19.         return
  20.     end
  21.    
  22.     if target then
  23.         system.bindKeyboard(target, 32, true, false)
  24.     end
  25.  
  26.     target = getRandomPlayer()
  27.     ui.setShamanName(target)
  28.    
  29.     system.bindKeyboard(target, 32, true, true)
  30. end
  31.  
  32. local balls = { "165220ae31c.png", "165220afb1a.png", "165220b1300.png", "165220b2adc.png", "165220b429a.png" }
  33.  
  34. local objects = { }
  35.  
  36. local getRandomObject = function()
  37.     local o = table.random(objects)
  38.     return o and tfm.get.room.objectList[o[1]]
  39. end
  40.  
  41. eventKeyboard = function(playerName, key, d, x, y)
  42.     if playerName == target then
  43.         if os.time() > target_timer then
  44.             target_timer = os.time() + 1000
  45.             if not tfm.get.room.playerList[playerName].isDead then
  46.                 tfm.exec.killPlayer(playerName)
  47.                 for i = 1, 6 do
  48.                     objects[i] = {
  49.                         [1] = tfm.exec.addShamanObject(6, x + math.random(-5, 5), y, math.random(360))
  50.                     }
  51.                     objects[i][2] = tfm.exec.addImage(table.random(balls), "#" .. objects[i][1], -15, -15)
  52.                 end
  53.             else
  54.                 local obj = getRandomObject()
  55.                 if obj then
  56.                     local x, y = obj.x, obj.y
  57.                    
  58.                     for i = 1, 6 do
  59.                         tfm.exec.removeImage(objects[i][2])
  60.                         tfm.exec.removeObject(objects[i][1])
  61.                     end
  62.                     objects = { }
  63.                    
  64.                     tfm.exec.respawnPlayer(playerName)
  65.                     tfm.exec.movePlayer(playerName, x, y)
  66.                 end
  67.             end
  68.         end
  69.     end
  70. end
  71.  
  72. eventLoop = function(current, remaining, ignore)
  73.     if ignore or remaining <= 500 then
  74.         tfm.exec.newGame("#7")
  75.     end
  76. end
  77.  
  78. eventNewPlayer = function()
  79.     if tfm.get.room.uniquePlayers == 2 then
  80.         eventLoop(nil, nil, true)
  81.     end
  82. end
  83.  
  84. eventLoop(nil, nil, true)
  85. tfm.exec.disableAutoNewGame()
  86. tfm.exec.disableAutoTimeLeft()
  87. tfm.exec.disableAutoShaman()
Advertisement
Add Comment
Please, Sign In to add comment