Advertisement
Guest User

Minigame FullBall

a guest
Jul 25th, 2018
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.09 KB | None | 0 0
  1. -- variables important
  2. DataPlayer = {} -- store player data
  3. deleteObjectShaman = {} -- Delete objects
  4. Maps = {7472843,7472873,7472870,7472895} -- Map list
  5. LivePlayers = 0 -- Store live players
  6. RoomPlayers = 0 -- Store players in room
  7. --Disable some automatic things.
  8. for _, s in next, {'AutoTimeLeft', 'PhysicalConsumables', 'AfkDeath', 'AutoShaman', 'AutoNewGame'} do
  9. tfm.exec['disable' .. s]()
  10. end
  11. -- Starts when a player enters the room
  12. -- Help, Profile and shop
  13. ui.addTextArea(201, "<p align='center'><a href='event:profile'><B><R>P</B></a></p>", name, 680, 375, 29, 19, 0x313a4a, 0x313a4a, 1, true)
  14. ui.addTextArea(202, "<p align='center'><a href='event:shop'><B><T>S</B></a></p>", name, 722, 375, 29, 19, 0x313a4a, 0x313a4a, 1, true)
  15. ui.addTextArea(203, "<p align='center'><a href='event:help'><B><J>H</B></a></p>", name, 764, 375, 29, 19, 0x313a4a, 0x313a4a, 1, true)
  16. function eventNewPlayer(name)
  17. RoomPlayers = RoomPlayers + 1
  18. DataPlayer[name] = { -- Saves player data / Generates data when a player enters the room
  19. ball_Name = "", -- Name of the ball currently used by the player
  20. ball_Appearance = 6, -- Current appearance of the ball
  21. level = 0, -- Level player
  22. player_Experience = 0, -- Amount of experience gained at the end of a match
  23. }
  24. settingsKeyboard(name) -- Settings keyboard player
  25. end
  26. -- Loop in game
  27. function eventLoop(current,remaining)
  28. for _,obj in ipairs(deleteObjectShaman) do
  29. if obj.time < os.time()-15000 then
  30. tfm.exec.removeObject(obj.id)
  31. table.remove(deleteObjectShaman,_)
  32. end
  33. end
  34. if LivePlayers == 0 or remaining <= 0 then -- If the number of live players = 0 or time = 0
  35. tfm.exec.newGame(Maps[math.random(#Maps)]) -- Execute a new game
  36. end
  37. end
  38. -- When player die
  39. function eventPlayerDied(name)
  40. LivePlayers = LivePlayers - 1 -- The variable receives its own value - 1
  41. tfm.exec.chatMessage("Ops! You died :(",name) -- Sends a message to the player when he dies
  42. end
  43. -- Player won
  44. function eventPlayerWon(name) -- The event happens when a player enters the hole.
  45. DataPlayer[name].player_Experience = DataPlayer[name].player_Experience + 15
  46. tfm.exec.chatMessage("Good job, you won.",name)
  47. LivePlayers = LivePlayers - 1
  48. end
  49. -- Starts event new game
  50. function eventNewGame()
  51. LivePlayers = 0 -- The variable returns to 0
  52. for name in pairs(tfm.get.room.playerList) do -- All players
  53. LivePlayers = LivePlayers + 1 -- Adds one more to the variable
  54. end
  55. tfm.exec.setGameTime(150) -- Set the playing time
  56. ui.setMapName("<VP>#FullBall")
  57. end
  58. -- appearance of the ball
  59. function appearanceBall(name)
  60. if DataPlayer[name].level <= 20 then
  61. DataPlayer[name].ball_Appearance = 6
  62. DataPlayer[name].ball_Name = "Beach ball"
  63. elseif DataPlayer[name].level >= 21 and DataPlayer[name].level < 30 then
  64. DataPlayer[name].ball_Appearance = 601
  65. DataPlayer[name].ball_Name = "Poke ball"
  66. elseif DataPlayer[name].level >= 29 then
  67. DataPlayer[name].ball_Appearance = 602
  68. DataPlayer[name].ball_Name = "Skull ball"
  69. end
  70. end
  71. -- Keyboard settings
  72. function settingsKeyboard(name)
  73. if k == 32 and tfm.get.room.playerList[name].isFacingRight == true and info[name].time < os.time()-1500 then
  74. info[name].time = os.time()
  75. tfm.exec.movePlayer(name,0,0,true,100,0,false)
  76. elseif k == 32 and tfm.get.room.playerList[name].isFacingRight == false and info[name].time < os.time()-1500 then
  77. info[name].time = os.time()
  78. tfm.exec.movePlayer(name,0,0,true,-100,0,false)
  79. end
  80. local facingLeft = {} -- Create a table facing left
  81. for name in pairs(tfm.get.room.playerList) do
  82. for _,key in pairs{0,2,3} do system.bindKeyboard(name, key, true)
  83. end
  84. end
  85. function eventKeyboard(name, key, down, x, y)
  86. if key == 0 or key == 2 then
  87. facingLeft[name] = key == 0
  88. elseif key == 3 then
  89. if facingLeft[name] then -- If the player is facing left
  90. obj_id = tfm.exec.addShamanObject(DataPlayer[name].ball_Appearance, x - 8, y - 5, 0, 20)
  91. appearanceBall(name) -- Update appearance ball
  92. else -- If no
  93. obj_id = tfm.exec.addShamanObject(DataPlayer[name].ball_Appearance, x + 8, y - 5, 0, 20)
  94. appearanceBall(name) -- Update appearance ball
  95. end
  96. table.insert(deleteObjectShaman,{id=obj_id,time=os.time()}) -- Remove the shamans objects
  97. end
  98. end
  99. end
  100. -- TextAreas
  101. function eventTextAreaCallback(t,name,link)
  102. if link == [[profile]] then
  103. ui.addTextArea(10, "", name, 266, 116, 267, 143, 0x313a4a, 0x314a4a, 1, true)
  104. ui.addTextArea(11, "<font size='20'><b><BV>XP</font>", name, 266, 117, 79, 26, 0x324650, 0x000000, 0, true)
  105. ui.addTextArea(12, "<font size='14'><b>"..DataPlayer[name].player_Experience.."/100<font>", name, 268, 148, 86, 24, 0x314a4a, 0x313a4a, 1, true)
  106. ui.addTextArea(13, "<font size='20'><b><pt>Level</font>", name, 364, 117, 79, 26, 0x324650, 0x000000, 0, true)
  107. ui.addTextArea(14, "<font size='14'><b>"..DataPlayer[name].level.."<font>", name, 367, 148, 86, 24, 0x314a4a, 0x313a4a, 1, true)
  108. ui.addTextArea(15, "<font size='20'><b><CEP>Ball</font>", name, 269, 185, 79, 26, 0x324650, 0x000000, 0, true)
  109. ui.addTextArea(16, "<font size='14'><b>"..DataPlayer[name].ball_Name.."<font>", name, 268, 216, 86, 24, 0x314a4a, 0x313a4a, 1, true)
  110. ui.addTextArea(17, "<font size='15'><a href='event:closeprofile'><b><R>X</R></a>", name, 512, 117, 21, 27, 0x324650, 0x000000, 0, true)
  111. elseif link == [[closeprofile]] then
  112. for i = 10,17 do --
  113. ui.removeTextArea(i,name)
  114. end
  115. elseif link == [[shop]] then
  116. ui.addTextArea(50, "<font size='20'></font>", name, 244, 113, 311, 173, 0x313a4a, 0x313a4a, 1, true)
  117. ui.addTextArea(51, "<font size='15'><a href='event:closeshop'><b><R>X</R></a>", name, 532, 115, 21, 27, 0x324650, 0x000000, 0, true)
  118. elseif link == [[closeshop]] then
  119. for i = 50,51 do --
  120. ui.removeTextArea(i,name)
  121. end
  122. elseif link == [[help]] then
  123. tfm.exec.chatMessage("<ROSE>Fill the room with as many balls as you can.\n• Level 0-20 Beach Ball\n• Level 21-30 Pokeball\n• Level +30 Skull Ball",name)
  124. end
  125. end
  126. table.foreach(tfm.get.room.playerList,eventNewPlayer)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement