Advertisement
Guest User

El Ahorcado

a guest
Nov 25th, 2013
1,797
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. tfm.exec.disableAfkDeath(true)
  2. tfm.exec.disableAutoShaman(true)
  3. tfm.exec.disableAutoNewGame(true)
  4. tfm.exec.disableAutoScore(true)
  5. tfm.exec.disableAutoTimeLeft(true)
  6.  
  7. chars = {"&","é","~","\"","{","|","è","`","_","à","@","]","+","=","}","¨","ë","ä","ü","ö","£","<",">","0","1","2","3","4","5","6","7","8","9"}
  8.  
  9. lang = {}
  10.  
  11. lang.fr = {
  12.   ask_word = "Définir le mot à trouver",
  13.   choose_word = "Choisissez un mot : (entre 2 et 12 caractères inclus, aucun accent)",
  14.   more_players = "Vous devez être au moins <font color='#FF0000'>2</font> joueurs pour jouer au pendu.",
  15.   next_turn_1 = "Le prochain tour débutera dans ",
  16.   next_turn_2 = " seconde(s).",
  17.   turn_of_1 = "C'est le tour de ",
  18.   turn_of_2 = " ! ",
  19.   patientez = "Patientez pendant qu'il choisir son mot...",
  20.   word_found = "Le mot a été trouvé !",
  21.   word_not_found = "Pas de chance ! Le mot était ",
  22.   time_out = "Temps écoulé !",
  23.   pass_turn = "Le maître du jeu a passé son tour !",
  24.   quit = "Le maître du jeu a quitté !"
  25. }
  26.  
  27. lang.es = {
  28.   ask_word = "Elige una palabra a buscar!",
  29.   choose_word = "Elige una palabra (entre 2 y 12 carácteres)",
  30.   more_players = "Deben haber por lo menos <font color='#FF0000'>2</font> usuarios para jugar al Ahorcado.",
  31.   next_turn_1 = "Siguiente turno en ",
  32.   next_turn_2 = " segundos(s)",
  33.   turn_of_1 = "¡ ",
  34.   turn_of_2 = " te toca ! ",
  35.   patientez = "Esperemos mientras él elige una palabra!",
  36.   word_found = "La palabra fue encontrada !",
  37.   word_not_found = "Mala suerte :( la palabra era ",
  38.   time_out = "Se acabó el tiempo !",
  39.   pass_turn = "El jugador ^ ha saltado su turno !",
  40.   quit = "El jugador ^ se ha ido ): ."
  41. }
  42.  
  43. lang.en = {
  44.   ask_word = "Define the word to find",
  45.   choose_word = "Choose a word : (between 2 and 12 characters)",
  46.   more_players = "You have to be at least <font color='#FF0000'>2</font> players to play Hangman.",
  47.   next_turn_1 = "Next turn in ",
  48.   next_turn_2 = " second(s).",
  49.   turn_of_1 = "It's ",
  50.   turn_of_2 = "'s turn ! ",
  51.   patientez = "Wait while he's choosing a word...",
  52.   word_found = "The word was found !",
  53.   word_not_found = "No luck! The word was ",
  54.   time_out = "Time out !",
  55.   pass_turn = "The game master has passed his turn !",
  56.   quit = "The game master has quit."
  57. }
  58.  
  59. text = lang.es
  60.  
  61. players = {}
  62. master = ""
  63.  
  64. letters = {}
  65. invertLetters = {}
  66.  
  67. word = ""
  68. hasDefinedWord = false
  69.  
  70. timer = 0
  71. bestPlayer = ""
  72. pendu_level = 0
  73.  
  74. beginReset = false
  75. hasToReset = false
  76. resetTimer = 0
  77.  
  78. isTimeOut = false
  79. hasWon = false
  80. hasLost = false
  81. hasSkipped = false
  82. hasQuit = false
  83.  
  84. lettersEntered = {}
  85.  
  86. id = {}
  87.  
  88. id["ask_word_main"] = 1
  89. id["ask_word_button"] = 2
  90. id["ask_word_popup"] = 3
  91. id["pendu"] = 4
  92. id["reset_timer"] = 5
  93. id["reset_timer_label"] = 6
  94. id["turn"] = 7
  95. id["turn_label"] = 8
  96. id["one_player"] = 9
  97. id["one_player_label"] = 10
  98.  
  99. function eventNewGame()
  100.   updatePlayersList()
  101.  
  102.   ui.removeTextArea(id["one_player"])
  103.   ui.removeTextArea(id["one_player_label"])
  104.  
  105.   letters = {}
  106.   invertLetters = {}
  107.   word = ""
  108.   hasDefinedWord = false
  109.   timer = 0
  110.  
  111.   if getNbPlayers() > 1 then
  112.     master = randomPlayer()
  113.     tfm.exec.movePlayer(master, 400, 90, false, 0, 0, false)
  114.    
  115.     askWord()
  116.     drawPendu()
  117.   else
  118.     removeAll()
  119.    
  120.     ui.addTextArea(id["one_player"], "", nil, 5, 110, 790, 25, 0xC0C0C0, 0x595959, 1f)
  121.     ui.addTextArea(id["one_player_label"], "<p align='center'><BL><font color='#000000'>"..text.more_players.."</font></p>", nil, 25, 115, 750, 30, 0xC0C0C0, 0xC0C0C0, 0f)
  122.    
  123.     drawWord()
  124.     drawPendu()
  125.   end
  126. end
  127.  
  128. function eventPlayerDied(playerName)
  129.   tfm.exec.respawnPlayer(playerName)
  130. end
  131.  
  132. function eventNewPlayer(playerName)
  133.   table.insert(players, playerName)
  134.  
  135.   if getNbPlayers() == 2 then
  136.     tfm.exec.newGame("@4488917")
  137.   else
  138.     tfm.exec.respawnPlayer(playerName)
  139.     drawWord()
  140.     drawPendu()
  141.   end
  142. end
  143.  
  144. function eventPlayerLeft(playerName)
  145.   local toRemove = 0
  146.  
  147.   for i,p in pairs(players) do
  148.     if p==playerName then
  149.       toRemove = i
  150.     end
  151.   end
  152.  
  153.   table.remove(players, toRemove)
  154.  
  155.   if getNbPlayers() == 1 then
  156.     tfm.exec.newGame("@4488917")
  157.   else
  158.     if playerName==master then
  159.       hasQuit = true
  160.       reset()
  161.     end
  162.   end
  163. end
  164.  
  165. function eventLoop(currentTime, timeRemaining)
  166.   timer = timer + 0.5
  167.   if beginReset then
  168.     ui.removeTextArea(id["ask_word_main"])
  169.     ui.removeTextArea(id["ask_word_button"])
  170.    
  171.     resetTimer = resetTimer + 0.5
  172.    
  173.     ui.addTextArea(id["reset_timer"], "", nil, 5, 110, 790, 25, 0xC0C0C0, 0x595959, 1f)
  174.     if isTimeOut then ui.addTextArea(id["reset_timer_label"], "<p align='center'><BL>"..text.time_out.." <font color='#000000'>"..text.next_turn_1.."<font color='#FF0000'>"..math.floor(10 - resetTimer).."</font>"..text.next_turn_2.."</font></p>", nil, 25, 115, 750, 30, 0xC0C0C0, 0xC0C0C0, 0f) end
  175.     if hasWon then ui.addTextArea(id["reset_timer_label"], "<p align='center'><BL>"..text.word_found.." <font color='#000000'>"..text.next_turn_1.."<font color='#FF0000'>"..math.floor(10 - resetTimer).."</font>"..text.next_turn_2.."</font></p>", nil, 25, 115, 750, 30, 0xC0C0C0, 0xC0C0C0, 0f) end
  176.     if hasLost then ui.addTextArea(id["reset_timer_label"], "<p align='center'><font color='#000000'>"..text.word_not_found.."</font><BL>"..word:gsub("^%l", string.upper).."<font color='#000000'> ! "..text.next_turn_1.."<font color='#FF0000'>"..math.floor(10 - resetTimer).."</font>"..text.next_turn_2.."</font></p>", nil, 25, 115, 750, 30, 0xC0C0C0, 0xC0C0C0, 0f) end
  177.     if hasSkiped then ui.addTextArea(id["reset_timer_label"], "<p align='center'><BL>"..text.pass_turn.."<font color='#000000'> "..text.next_turn_1.."<font color='#FF0000'>"..math.floor(10 - resetTimer).."</font>"..text.next_turn_2.."</font></p>", nil, 25, 115, 750, 30, 0xC0C0C0, 0xC0C0C0, 0f) end
  178.     if hasQuit then ui.addTextArea(id["reset_timer_label"], "<p align='center'><BL>"..text.quit.."<font color='#000000'> "..text.next_turn_1.."<font color='#FF0000'>"..math.floor(10 - resetTimer).."</font>"..text.next_turn_2.."</font></p>", nil, 25, 115, 750, 30, 0xC0C0C0, 0xC0C0C0, 0f) end
  179.   end
  180.  
  181.   checkBestPlayer()
  182.  
  183.   if timer==25 and not hasDefinedWord and getNbPlayers() > 1 then
  184.     isTimeOut = true
  185.     reset()
  186.   end
  187.  
  188.   if resetTimer==10 then
  189.     isTimeOut = false
  190.     hasWon = false
  191.     hasLost = false
  192.     hasSkiped = false
  193.     hasQuit = false
  194.    
  195.     hasToReset = true
  196.    
  197.     reset()
  198.   end
  199. end
  200.  
  201. function eventChatCommand(playerName, message)
  202.   local args = {}
  203.  
  204.   for arg in message:gmatch("[^%s]+") do
  205.     table.insert(args, arg:lower())
  206.   end
  207.  
  208.   if not hasLost and not hasSkiped and not hasQuit and args[1] ~= nil then
  209.     if args[1]==word and playerName ~= master and not hasWon then
  210.       local score = 0
  211.      
  212.       for _,letter in pairs(letters) do
  213.         if letter=="_" then score = score + 1 end
  214.       end
  215.      
  216.       tfm.exec.setPlayerScore(playerName, score, true)
  217.      
  218.       local i = 1
  219.      
  220.       while i <= word:len() do
  221.         if letters[i]~="_" then
  222.           invertLetters[i] = letters[i]
  223.           letters[i] = "_"
  224.         end
  225.        
  226.         i = i + 1
  227.       end
  228.  
  229.       drawWord()
  230.       hasWon = true
  231.       reset()
  232.     end
  233.    
  234.     if args[1]=="skip" and playerName==master and not hasWon and not hasLost and not isTimeOut then
  235.       hasSkiped = true
  236.       reset()
  237.     end
  238.    
  239.     if args[1]:len()==1 and hasDefinedWord and args[1]~= "_" and args[1]~="-" and args[1]~="'" and playerName ~= master then
  240.       local isEntered = false
  241.      
  242.       for _,letter in pairs(lettersEntered) do
  243.         if letter==args[1] then
  244.           isEntered = true
  245.         end
  246.       end
  247.      
  248.       if not isEntered then
  249.         local score = 0
  250.         local idsToRemove = {}
  251.         local isFalse = true
  252.        
  253.         table.insert(lettersEntered, args[1])
  254.        
  255.         for id,letter in pairs(letters) do
  256.           if letter==args[1] then
  257.             table.insert(idsToRemove, id)
  258.             isFalse = false
  259.           end
  260.         end
  261.        
  262.         for _,idToRemove in pairs(idsToRemove) do
  263.           invertLetters[idToRemove] = letters[idToRemove]
  264.           letters[idToRemove] = "_"
  265.         end
  266.        
  267.         score = #idsToRemove
  268.        
  269.         if isFalse then
  270.           if tfm.get.room.playerList[playerName].score > 0 then score = -1 end
  271.           pendu_level = pendu_level + 1
  272.         end
  273.        
  274.         tfm.exec.setPlayerScore(playerName, score, true)
  275.        
  276.         drawWord()
  277.         drawPendu()
  278.       end
  279.     end
  280.   end
  281. end
  282.  
  283. function eventTextAreaCallback(textAreaId, playerName, callback)
  284.   if callback=="callbackAskWord" then
  285.     ui.addPopup(id["ask_word_popup"], 2, text.choose_word, master, 300, 175, 200)
  286.   end
  287. end
  288.  
  289. function eventPopupAnswer(popupId, playerName, answer)
  290.   if popupId==id["ask_word_popup"] and not isTimeOut and master==playerName then
  291.     local choosedWord = tostring(answer)
  292.    
  293.     if checkWord(choosedWord) then
  294.       defineWord(choosedWord)
  295.       hasDefinedWord = true
  296.      
  297.       askWord()
  298.      
  299.       ui.removeTextArea(id["turn"])
  300.       ui.removeTextArea(id["turn_label"])
  301.     end
  302.   end
  303. end
  304.  
  305. function askWord()
  306.   ui.removeTextArea(id["reset_timer"])
  307.   ui.removeTextArea(id["reset_timer_label"])
  308.   ui.removeTextArea(id["ask_word_main"])
  309.   ui.removeTextArea(id["ask_word_button"])
  310.  
  311.   if not hasDefinedWord then
  312.     ui.addTextArea(id["ask_word_main"], "", master, 5, 110, 790, 35, 0xC0C0C0, 0x595959, 1f)
  313.     ui.addTextArea(id["ask_word_button"], "<p align='center'><a href='event:callbackAskWord'>"..text.ask_word.."</a></p>", master, 300, 120, 190, 16, 0x595959, 0x595959, 1f)
  314.    
  315.     for p,_ in pairs(tfm.get.room.playerList) do
  316.       if p~=master then
  317.         ui.addTextArea(id["turn"], "", p, 5, 110, 790, 25, 0xC0C0C0, 0x595959, 1f)
  318.         ui.addTextArea(id["turn_label"], "<p align='center'><font color='#000000'>"..text.turn_of_1.."</font><BL>"..master.."<font color='#000000'>"..text.turn_of_2..text.patientez.."</font></p>", p, 25, 115, 750, 30, 0xC0C0C0, 0xC0C0C0, 0f)
  319.       end
  320.     end
  321.   end
  322. end
  323.  
  324. function defineWord(new_word)
  325.   word = string.lower(string.gsub(new_word, " ", "-"))
  326.  
  327.   letters = {}
  328.  
  329.   local i = 36
  330.  
  331.   while i < 50 do
  332.     ui.removeTextArea(i)
  333.     i = i + 1
  334.   end
  335.  
  336.   for letter in new_word:gmatch"." do
  337.     if letter==" " or letter=="-" then
  338.       table.insert(invertLetters, "-")
  339.       table.insert(letters, "_")
  340.     elseif letter=="'" then
  341.       table.insert(invertLetters, "'")
  342.       table.insert(letters, "_")
  343.     else
  344.       table.insert(letters, letter:lower())
  345.       table.insert(invertLetters, "_")
  346.     end
  347.   end
  348.  
  349.   drawWord()
  350.   drawPendu()
  351. end
  352.  
  353. function drawWord()
  354.   local textId = 36
  355.   local i = 1
  356.   local ancreX = 40
  357.  
  358.   if #word==0 then
  359.     local i = 36
  360.  
  361.     while i < 50 do
  362.       ui.removeTextArea(i)
  363.       i = i + 1
  364.     end
  365.   else
  366.     while i <= word:len() do
  367.       ui.addTextArea(textId, "<p align='center'><font size='40' color='#000000'>"..invertLetters[i]:upper().."</font></p>", nil, ancreX, 150, 40, 60, 0xC0C0C0, 0xC0C0C0, 1f)
  368.       ancreX = ancreX + 60
  369.       textId = textId + 1
  370.       i = i + 1
  371.     end
  372.    
  373.     local finished = true
  374.     local j = 1
  375.    
  376.     while j <= word:len() do
  377.       if invertLetters[j]=="_" then finished = false end
  378.       j = j + 1
  379.     end
  380.    
  381.     if finished then
  382.       hasWon = true
  383.       reset()
  384.     end
  385.   end
  386. end
  387.  
  388. function drawPendu()
  389.   local pendu = ""
  390.  
  391.   if pendu_level==1 then
  392.     pendu = pendu.."<br /><br /><br /><br /><br /><br /><br /><br /><br /> _________"
  393.    
  394.   elseif pendu_level==2 then
  395.     pendu = pendu.."<br />"
  396.     pendu = pendu.."        |<br />"
  397.     pendu = pendu.."        |<br />"
  398.     pendu = pendu.."        |<br />"
  399.     pendu = pendu.."        |<br />"
  400.     pendu = pendu.."        |<br />"
  401.     pendu = pendu.."        |<br />"
  402.     pendu = pendu.."        |<br />"
  403.     pendu = pendu.."        |<br />"
  404.     pendu = pendu.." ____|____"
  405.    
  406.   elseif pendu_level==3 then
  407.     pendu = pendu.."        __________.__<br />"
  408.     pendu = pendu.."        |<br />"
  409.     pendu = pendu.."        |<br />"
  410.     pendu = pendu.."        |<br />"
  411.     pendu = pendu.."        |<br />"
  412.     pendu = pendu.."        |<br />"
  413.     pendu = pendu.."        |<br />"
  414.     pendu = pendu.."        |<br />"
  415.     pendu = pendu.."        |<br />"
  416.     pendu = pendu.." ____|____"
  417.    
  418.   elseif pendu_level==4 then
  419.     pendu = pendu.."        __________.__<br />"
  420.     pendu = pendu.."        |  /<br />"
  421.     pendu = pendu.."        |/<br />"
  422.     pendu = pendu.."        |<br />"
  423.     pendu = pendu.."        |<br />"
  424.     pendu = pendu.."        |<br />"
  425.     pendu = pendu.."        |<br />"
  426.     pendu = pendu.."        |<br />"
  427.     pendu = pendu.."        |<br />"
  428.     pendu = pendu.." ____|____"
  429.    
  430.   elseif pendu_level==5 then
  431.     pendu = pendu.."        __________.__<br />"
  432.     pendu = pendu.."        |  /      |<br />"
  433.     pendu = pendu.."        |/<br />"
  434.     pendu = pendu.."        |<br />"
  435.     pendu = pendu.."        |<br />"
  436.     pendu = pendu.."        |<br />"
  437.     pendu = pendu.."        |<br />"
  438.     pendu = pendu.."        |<br />"
  439.     pendu = pendu.."        |<br />"
  440.     pendu = pendu.." ____|____"
  441.    
  442.   elseif pendu_level==6 then
  443.     pendu = pendu.."        __________.__<br />"
  444.     pendu = pendu.."        |  /      |<br />"
  445.     pendu = pendu.."        |/        O<br />"
  446.     pendu = pendu.."        |<br />"
  447.     pendu = pendu.."        |<br />"
  448.     pendu = pendu.."        |<br />"
  449.     pendu = pendu.."        |<br />"
  450.     pendu = pendu.."        |<br />"
  451.     pendu = pendu.."        |<br />"
  452.     pendu = pendu.." ____|____"
  453.    
  454.   elseif pendu_level==7 then
  455.     pendu = pendu.."        __________.__<br />"
  456.     pendu = pendu.."        |  /      |<br />"
  457.     pendu = pendu.."        |/        O<br />"
  458.     pendu = pendu.."        |        /|<br />"
  459.     pendu = pendu.."        |<br />"
  460.     pendu = pendu.."        |<br />"
  461.     pendu = pendu.."        |<br />"
  462.     pendu = pendu.."        |<br />"
  463.     pendu = pendu.."        |<br />"
  464.     pendu = pendu.." ____|____"
  465.    
  466.   elseif pendu_level==8 then
  467.     pendu = pendu.."        __________.__<br />"
  468.     pendu = pendu.."        |  /      |<br />"
  469.     pendu = pendu.."        |/        O<br />"
  470.     pendu = pendu.."        |        /|\<br />"
  471.     pendu = pendu.."        |<br />"
  472.     pendu = pendu.."        |<br />"
  473.     pendu = pendu.."        |<br />"
  474.     pendu = pendu.."        |<br />"
  475.     pendu = pendu.."        |<br />"
  476.     pendu = pendu.." ____|____"
  477.    
  478.   elseif pendu_level==9 then
  479.     pendu = pendu.."        __________.__<br />"
  480.     pendu = pendu.."        |  /      |<br />"
  481.     pendu = pendu.."        |/        O<br />"
  482.     pendu = pendu.."        |        /|\\<br />"
  483.     pendu = pendu.."        |         |<br />"
  484.     pendu = pendu.."        |<br />"
  485.     pendu = pendu.."        |<br />"
  486.     pendu = pendu.."        |<br />"
  487.     pendu = pendu.."        |<br />"
  488.     pendu = pendu.." ____|____"
  489.    
  490.   elseif pendu_level==10 then
  491.     pendu = pendu.."        __________.__<br />"
  492.     pendu = pendu.."        |  /      |<br />"
  493.     pendu = pendu.."        |/        O<br />"
  494.     pendu = pendu.."        |        /|\\<br />"
  495.     pendu = pendu.."        |         |<br />"
  496.     pendu = pendu.."        |        /<br />"
  497.     pendu = pendu.."        |<br />"
  498.     pendu = pendu.."        |<br />"
  499.     pendu = pendu.."        |<br />"
  500.     pendu = pendu.." ____|____"
  501.  
  502.   elseif pendu_level==11 then
  503.     pendu = pendu.."        __________.__<br />"
  504.     pendu = pendu.."        |  /         |  <br />"
  505.     pendu = pendu.."        |/           O  <br />"
  506.     pendu = pendu.."        |           /|\\ <br />"
  507.     pendu = pendu.."        |            |  <br />"
  508.     pendu = pendu.."        |           / \\ <br />"
  509.     pendu = pendu.."        |               <br />"
  510.     pendu = pendu.."        |               <br />"
  511.     pendu = pendu.."        |               <br />"
  512.     pendu = pendu.." ____|____"
  513.    
  514.     hasLost = true
  515.     reset()
  516.   end
  517.  
  518.   ui.addTextArea(id["pendu"], pendu, nil, 323, 235, 135, 138, 0x010101, 0xFFFFFF, 0.5f)
  519. end
  520.  
  521. function reset()
  522.   beginReset = true
  523.  
  524.   if hasToReset then
  525.     if getNbPlayers() < 2 then
  526.       tfm.exec.newGame("@4488917")
  527.     else
  528.       letters = {}
  529.       invertLetters = {}
  530.       word = ""
  531.       hasDefinedWord = false
  532.       pendu_level = 0
  533.       beginReset = false
  534.       hasToReset = false
  535.       resetTimer = 0
  536.       lettersEntered = {}
  537.      
  538.       drawWord()
  539.       drawPendu()
  540.      
  541.       local randX = math.random(799)
  542.       tfm.exec.movePlayer(master, randX, 385, false, 0, 0, false)
  543.      
  544.       local oldMaster = master
  545.      
  546.       if getNbPlayers()~=1 then
  547.         if bestPlayer==oldMaster then
  548.           while master==oldMaster do
  549.             master = randomPlayer()
  550.           end
  551.         else
  552.           master = bestPlayer
  553.         end
  554.       else
  555.         master = bestPlayer
  556.       end
  557.      
  558.       randX = math.random(799)
  559.      
  560.       tfm.exec.movePlayer(master, randX, 90, false, 0, 0, false)
  561.       tfm.exec.setPlayerScore(master, 0, false)
  562.      
  563.       timer = 0
  564.      
  565.       askWord()
  566.     end
  567.   end
  568. end
  569.  
  570. function removeAll()
  571.   ui.removeTextArea(id["ask_word_main"])
  572.   ui.removeTextArea(id["ask_word_button"])
  573.   ui.removeTextArea(id["ask_word_popup"])
  574.   ui.removeTextArea(id["pendu"])
  575.   ui.removeTextArea(id["reset_timer"])
  576.   ui.removeTextArea(id["reset_timer_label"])
  577.   ui.removeTextArea(id["turn"])
  578.   ui.removeTextArea(id["turn_label"])
  579.   ui.removeTextArea(id["one_player"])
  580.   ui.removeTextArea(id["one_player_label"])
  581. end
  582.  
  583. function checkWord(word_arg)
  584.   if word_arg:len() >= 2 and word_arg:len() <= 12 then
  585.     for _,c in pairs(chars) do
  586.       if string.match(word_arg, c) then
  587.         return false
  588.       end
  589.     end
  590.    
  591.     return true
  592.   else
  593.     return false
  594.   end
  595. end
  596.  
  597. function checkBestPlayer()
  598.   topScore = 0
  599.   bestPlayer = randomPlayer()
  600.  
  601.   for name,player in pairs(tfm.get.room.playerList) do
  602.     if player.score >= topScore then
  603.       topScore = player.score
  604.       bestPlayer = name
  605.     end
  606.   end
  607. end
  608.  
  609. function getNbPlayers()
  610.   return #players
  611. end
  612.  
  613. function updatePlayersList()
  614.   players = {}
  615.  
  616.   for p,_ in pairs(tfm.get.room.playerList) do
  617.     table.insert(players, p)
  618.   end
  619. end
  620.  
  621. function randomPlayer()
  622.   return players[math.random(1,#players)]
  623. end
  624.  
  625. for name,player in pairs(tfm.get.room.playerList) do
  626.   tfm.exec.setPlayerScore(name, 0, false)
  627. end
  628.  
  629. updatePlayersList()
  630. bestPlayer = randomPlayer()
  631. tfm.exec.newGame("@4488917")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement