Advertisement
Guest User

[Mini-game] The ballons¹

a guest
Mar 25th, 2015
403
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. -----The ballons
  2.  
  3. system.bindMouse("Hpassos", true);
  4.  
  5. function eventMouse(playerName, xMouse, yMouse)
  6. tfm.exec.addShamanObject(28, xMouse, yMouse, 0, 0, 0, false);
  7. end
  8.  
  9. ranking={};
  10.  
  11. function estaNaTabela(player)
  12. for i = #ranking,1,-1 do
  13. if ranking == player then
  14. return true;
  15. end
  16. end
  17. return false;
  18. end
  19.  
  20. function verRanking(player)
  21. for i = #ranking,1,-1 do
  22. table.remove(ranking,i)
  23. end
  24. for i = 0,3 do
  25. local score = -1;
  26. local pl = nil;
  27. for p,v in pairs(tfm.get.room.playerList) do
  28. if v.score > score and not estaNaTabela(p) then
  29. score=v.score;
  30. pl=p;
  31. end
  32. end
  33. table.insert(ranking,pl)
  34. end
  35. for i = #ranking,1,-1 do
  36. print(ranking)
  37. end
  38. end
  39.  
  40. verRanking()
  41. tfm.exec.disableAutoNewGame(true);
  42. mapas={"@5016375", "@5016389"}
  43.  
  44. function nextRound()
  45. tfm.exec.newGame(mapas[math.random(#mapas)]);
  46. end
  47.  
  48. function eventNewGame()
  49. vivo=0
  50. for name,player in pairs(tfm.get.room.playerList) do
  51. vivo=vivo+1
  52. end
  53. end
  54.  
  55. function eventPlayerDied(name)
  56. vivo=vivo-1
  57. end
  58.  
  59. function eventPlayerWon(name)
  60. vivo=vivo-1
  61. end
  62.  
  63. function eventLoop(tempoPassado, tempoFaltando)
  64. if vivo == 0 or tempoFaltando < 1000 then
  65. nextRound();
  66. end
  67. end
  68.  
  69. nextRound();
  70. red={}
  71. blue={}
  72. function makeTeams()
  73. local playerList={}
  74. for name,player in pairs(tfm.get.room.playerList) do
  75. table.insert(playerList,name)
  76. end
  77. for i=1,#playerList,1 do
  78. local index=math.random(#playerList)
  79. local name=playerList[index]
  80. if i%2==0 then
  81. table.insert(red,name)
  82. else
  83. table.insert(blue,name)
  84. end
  85. table.remove(playerList,index)
  86. end
  87. end
  88.  
  89. makeTeams()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement