Advertisement
Deathmatic

TribeHouseManager v1.5.1

Oct 6th, 2013
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 17.30 KB | None | 0 0
  1. fly = false
  2. chamane = false
  3. vampire = false
  4. bootcamp = false
  5. survivor = false
  6. quizz = false
  7.  
  8. -- Liste des commandes
  9. commands = {"stop", "time", "color", "kill", "ch", "respawn", "meep", "help", "bc", "next"}
  10. -- Liste des cartes bootcamp pouvant être jouées (en attendant de pouvoir jouer une carte aléatoire d'une rotation)
  11. bootcampMaps = {"@1427980", "@161434", "@216173", "@172621", "@500000", "@3908151", "@512887","@374995", "@306365", "@155606", "@333002", "@172547", "@3734998", "@1737914", "@2989803", "@3136410", "@438449", "@976944", "@1595965", "@1636814", "@2009003", "@3804078", "@3768117", "@3799357", "@3278138", "@3311534", "@3779861", "@3576303", "@3780618", "@2789121", "@2811229", "@3659983", "@3759157", "@597804", "@2998268", "@2132250", "@3745158", "@3338283", "@3062939", "@3137929", "@3560999", "@3182487", "@3725142", "@3012311", "@3493456", "@343456", "@208056", "@881158", "@492399", "@268915", "@505619", "@397469", "@729863", "@184648", "@156720", "@541693"}
  12. -- Liste des cartes survivor pouvant être jouées (en attendant de pouvoir jouer une carte aléatoire d'une rotation)
  13. survivorMaps = {"@3540608","@492283","@1026249","@1545834","@1659906","@1659906","@3295213","@3699989","@741041","@489470","@395246","@292672","@306106","@3584123","@1522692","@3107377","@2387888","@3685564","@787131","@2408376","@3670885","@3620709","@3584826","@3587860","@3549404","@481676","@3550350","@3480467"}
  14. -- Durée d'un bootcamp (défaut: 6min soit 360 secondes)
  15. bootcampDuration = 360
  16.  
  17. tfm.exec.disableAfkDeath(true)
  18.  
  19. tfm.exec.newGame()
  20.  
  21. function eventNewPlayer(playerName)
  22.   displayCredits(playerName)
  23.  
  24.     tfm.exec.bindKeyboard(playerName, 79, true)
  25.     tfm.exec.bindKeyboard(playerName, 80, true)
  26.  
  27.     tfm.exec.respawnPlayer(playerName)
  28.  
  29.     if fly==true then
  30.         tfm.exec.bindKeyboard(playerName,32,true)
  31.     end
  32.  
  33.     if chamane==true then
  34.         tfm.exec.setShaman(playerName)
  35.     end
  36. end
  37.  
  38. function eventPlayerDied(playerName)
  39.   if bootcamp==true then
  40.     tfm.exec.respawnPlayer(playerName)
  41.   end
  42.  
  43.   if chamane==true then
  44.     tfm.exec.setShaman(playerName)
  45.     tfm.exec.respawnPlayer(playerName)
  46.   end
  47.  
  48.   if survivor==true then
  49.     tfm.exec.setPlayerScore(playerName, 1, true)
  50.    
  51.     if tfm.get.room.playerList[playerName].isShaman==true then
  52.       tfm.exec.setPlayerScore(p, 0, false)
  53.       tfm.exec.newGame(survivorMaps[math.random(#survivorMaps)])
  54.      
  55.       for p,_ in pairs(tfm.get.room.playerList) do
  56.         if tfm.get.room.playerList[p].isShaman==false then
  57.           if tfm.get.room.playerList[p].isDead==false then
  58.             tfm.exec.setPlayerScore(p, math.random(3) + 15, true)
  59.           end
  60.         end
  61.       end
  62.  
  63.     else
  64.       survivorShaman = ""
  65.       nbSurv = 0
  66.       for p,_ in pairs(tfm.get.room.playerList) do
  67.         if tfm.get.room.playerList[p].isShaman==false then
  68.           if tfm.get.room.playerList[p].isDead==false then
  69.             nbSurv = nbSurv + 1
  70.           end
  71.         else
  72.           survivorShaman = p
  73.         end
  74.       end
  75.      
  76.       if nbSurv <= 1 then
  77.         tfm.exec.setPlayerScore(survivorShaman, 0, false)
  78.         tfm.exec.newGame(survivorMaps[math.random(#survivorMaps)])
  79.         for p,_ in pairs(tfm.get.room.playerList) do
  80.           if tfm.get.room.playerList[p].isShaman==false then
  81.             if tfm.get.room.playerList[p].isDead==false then
  82.               tfm.exec.setPlayerScore(p, math.random(3) + 15, true)
  83.             end
  84.         end
  85.       end
  86.       end
  87.     end
  88.   end
  89. end
  90.  
  91. function eventPlayerWon(playerWon)
  92.   if bootcamp==true then
  93.     tfm.exec.respawnPlayer(playerWon)
  94.     tfm.exec.setPlayerScore(playerWon, 20, true)
  95.   end
  96. end
  97.  
  98. function eventNewGame()
  99.   displayCredits(nil)
  100.  
  101.     for p,_ in pairs(tfm.get.room.playerList) do
  102.         tfm.exec.bindKeyboard(p,79,true)
  103.         tfm.exec.bindKeyboard(p,80,true)
  104.  
  105.         if fly==true then
  106.             tfm.exec.bindKeyboard(p,32,true)
  107.         end
  108.  
  109.         if chamane==true then
  110.             tfm.exec.setShaman(p)
  111.         end
  112.     end
  113.  
  114.   if vampire==true then
  115.         hasVampired = false
  116.     tfm.exec.setUIMapName("<font color='#BABD2F'>Mini-jeu :</font> <font color='#C2C2DA'>Vampire</font>")
  117.     end
  118.  
  119.   if fly==true then
  120.     tfm.exec.setUIMapName("<font color='#BABD2F'>Mini-jeu :</font> <font color='#C2C2DA'>Fly</font>")
  121.   end
  122.  
  123.     if chamane==true then
  124.         tfm.exec.setUIShamanName("Tout le monde !")
  125.     tfm.exec.setUIMapName("<font color='#BABD2F'>Mini-jeu :</font> <font color='#C2C2DA'>Chamane</font>")
  126.     end
  127.  
  128.   if bootcamp==true then
  129.     tfm.exec.setUIMapName("<font color='#BABD2F'>Mini-jeu :</font> <font color='#C2C2DA'>Bootcamp</font>")
  130.   end
  131.  
  132.   if survivor==true then
  133.     tfm.exec.setUIMapName("<font color='#BABD2F'>Mini-jeu :</font> <font color='#C2C2DA'>Survivor</font>")
  134.   end
  135. end
  136.  
  137. function eventKeyboard(playerName, keyCode, True, x, y)
  138.     if keyCode==79 then
  139.     displayGestionnaire(false, playerName)
  140.     end
  141.  
  142.     if keyCode==80 then
  143.         ui.addPopup(1, 2, "Entrez le code de la map que vous voulez jouer :", playerName, 300, 150, 200)
  144.     end
  145.  
  146.     if fly==true then
  147.         if keyCode==32 then
  148.             tfm.exec.movePlayer(playerName, playerName.x, playerName.y, false, 0, -50, off)
  149.         end
  150.     end
  151. end
  152.  
  153. function eventPopupAnswer(popupId, playerName, answer)
  154.     if popupId==1 then
  155.     if answer~="" then
  156.       activate()
  157.       tfm.exec.newGame(answer)
  158.     end
  159.   end
  160. end
  161.  
  162. hasVampired = false
  163.  
  164. function eventLoop(currentTime, timeRemaining)
  165.     if vampire==true then
  166.         if hasVampired==false then
  167.             if timeRemaining<=105000 then
  168.                 tfm.exec.setVampirePlayer(randomPlayer())
  169.                 hasVampired = true
  170.             end
  171.         end
  172.     end
  173.  
  174.   if bootcamp==true then
  175.     if timeRemaining<=0 then
  176.       tfm.exec.newGame(bootcampMaps[math.random(#bootcampMaps)])
  177.       tfm.exec.setGameTime(bootcampDuration)  
  178.     end
  179.   end
  180.  
  181.   if survivor==true then
  182.     if timeRemaining<=0 then
  183.       for p,_ in pairs(tfm.get.room.playerList) do
  184.         if tfm.get.room.playerList[p].isShaman==false then
  185.           tfm.exec.setPlayerScore(p, math.random(3) + 15, true)
  186.         else
  187.           tfm.exec.setPlayerScore(p, 0, false)
  188.         end
  189.       end
  190.      
  191.       tfm.exec.newGame(survivorMaps[math.random(#survivorMaps)])
  192.     end
  193.   end
  194. end
  195.  
  196. function eventChatCommand(playerName, message)
  197.     if message=="stop" then
  198.     activate()
  199.         tfm.exec.newGame()
  200.     end
  201.    
  202.   if message=="next" then
  203.     if bootcamp==true then
  204.       tfm.exec.disableAutoScore(true)
  205.       tfm.exec.disableAutoShaman(true)
  206.       tfm.exec.disableAfkDeath(true)
  207.       tfm.exec.disableAutoTimeLeft(true)
  208.       tfm.exec.disableAutoNewGame(true)
  209.       tfm.exec.newGame(bootcampMaps[math.random(#bootcampMaps)])
  210.       tfm.exec.setGameTime(bootcampDuration)
  211.     end
  212.   end
  213.  
  214.   if message:sub(0, 2)=="bc" then
  215.     if bootcamp==true then
  216.       tfm.exec.disableAutoScore(true)
  217.       tfm.exec.disableAutoShaman(true)
  218.       tfm.exec.disableAfkDeath(true)
  219.       tfm.exec.disableAutoTimeLeft(true)
  220.       tfm.exec.disableAutoNewGame(true)
  221.       tfm.exec.newGame(message:sub(4))
  222.       tfm.exec.setGameTime(bootcampDuration)
  223.     end
  224.   end
  225.  
  226.     if message:sub(0,4)=="time" then
  227.         tfm.exec.setGameTime(message:sub(6))
  228.     end
  229.    
  230.     if message:sub(0,5)=="color" then
  231.         if string.len(message) > 6 then
  232.             tfm.exec.setNameColor(playerName, "0x"..message:sub(7).."")
  233.         end
  234.     end
  235.  
  236.     if message=="kill" then
  237.         tfm.exec.killPlayer(playerName)
  238.     end
  239.  
  240.     if message=="ch" then
  241.         tfm.exec.setPlayerScore(playerName, 9001, add)
  242.     end
  243.  
  244.     if message=="respawn" then
  245.         if chamane==true then
  246.             tfm.exec.setShaman(playerName)
  247.         end
  248.         if survivor==false then
  249.       tfm.exec.respawnPlayer(playerName)
  250.     end
  251.     end
  252.  
  253.     if message=="meep" then
  254.         tfm.exec.giveMeep(playerName)
  255.     end
  256.  
  257.     if message=="help" then
  258.         displayHelp(false, playerName)
  259.     end
  260. end
  261.  
  262. function eventTextAreaCallback(textAreaId, playerName, callback)
  263.     if callback=="callbackClose" then
  264.         displayHelp(true, playerName)
  265.    
  266.     elseif callback=="callbackCommands" then
  267.     displayHelp(true, playerName)
  268.         displayCommands(false, playerName)
  269.    
  270.     elseif callback=="callbackCloseCommands" then
  271.         displayCommands(true, playerName)
  272.    
  273.     elseif callback=="callbackAccueilCommands" then
  274.         displayCommands(true, playerName)
  275.         displayHelp(false, playerName)
  276.    
  277.     elseif callback=="callbackMinijeux" then
  278.         displayHelp(true, playerName)
  279.     displayMinijeux(false, playerName)
  280.    
  281.     elseif callback=="callbackCloseMinijeux" then
  282.         displayMinijeux(true, playerName)
  283.    
  284.     elseif callback=="callbackAccueilMinijeux" then
  285.         displayMinijeux(true, playerName)
  286.     displayHelp(false, playerName)
  287.    
  288.   elseif callback=="callbackCloseGestionnaire" then
  289.     displayGestionnaire(true, playerName)
  290.    
  291.   elseif callback=="callbackBootcamp" then
  292.     displayGestionnaire(true, playerName)
  293.     activate("bootcamp")
  294.    
  295.   elseif callback=="callbackChamane" then
  296.     displayGestionnaire(true, playerName)
  297.     activate("chamane")
  298.    
  299.   elseif callback=="callbackFly" then
  300.     displayGestionnaire(true, playerName)
  301.     activate("fly")
  302.    
  303.   elseif callback=="callbackVampire" then
  304.     displayGestionnaire(true, playerName)
  305.     activate("vampire")
  306.    
  307.   elseif callback=="callbackSurvivor" then
  308.     displayGestionnaire(true, playerName)
  309.     activate("survivor")
  310.  
  311.   elseif callback=="callbackStop" then
  312.     displayGestionnaire(true, playerName)
  313.     activate(nil)
  314.   end
  315. end
  316.  
  317. function displayHelp(doClose, playerName)
  318.   if doClose==true then
  319.     ui.removeTextArea(3, playerName)
  320.         ui.removeTextArea(4, playerName)
  321.         ui.removeTextArea(5, playerName)
  322.         ui.removeTextArea(6, playerName)
  323.   else
  324.     ui.addTextArea(3, "<p align='center'><font color='#C2C2DA' size='35' >Aide</font></p><br /><b>  Appuyez sur O pour lancer le gestionnaire de modules<br />  Appuyez sur P pour jouer une carte<br /></b>  <font size='13'><br />  Quelle catégorie souhaiteriez-vous consulter ?</font>", playerName, 200, 100, 400, 200, 0x324650, 0x6A8FA2, 1f)
  325.         ui.addTextArea(4, "<font size='15'><a href='event:callbackClose'>x</a></font>", playerName, 206, 105, 20, 30, 0x324650, 0x324650, 1f)
  326.         ui.addTextArea(5, "<p align='center'><a href='event:callbackCommands'>Commandes</a></p>", playerName, 275, 250, 100, 20, 0x3C5064, 0x3C5064, f1)
  327.         ui.addTextArea(6, "<p align='center'><a href='event:callbackMinijeux'>Mini-jeux</a></p>", playerName, 425, 250, 100, 20, 0x3C5064, 0x3C5064, f1)
  328.   end
  329. end
  330.  
  331. function displayCommands(doClose, playerName)
  332.   if doClose==true then
  333.     ui.removeTextArea(7, playerName)
  334.         ui.removeTextArea(8, playerName)
  335.         ui.removeTextArea(9, playerName)
  336.   else
  337.     ui.addTextArea(7, "<p align='center'><font color='C2C2DA' size='35' >Commandes</font></p><br /><b> !help :</b> Affiche l'aide<br /><b> !stop :</b> Interrompt le mini-jeu en cours<br /><b> !kill :</b> Mourir instantanément<br /><b> !respawn :</b> Réapparaître instantanément<br /><b> !ch :</b> Vous serez chamane lors de la prochaine partie<br /><b> !meep :</b> Vous serez pourvu du pouvoir de meep<br /><b> !time [secondes] :</b> Modifie le temps de la partie en cours<br /><b> !color [code héxadécimal] :</b> Change la couleur de votre pseudo<br /><b> !next :</b> (mini-jeu bootcamp) Change de carte<br /><b> !bc [@code] :</b> (mini-jeu bootcamp) Joue une carte en bootcamp", playerName, 200, 90, 400, 220, 0x324650, 0x6A8FA2, 1f)
  338.         ui.addTextArea(8, "<font size='15'><a href='event:callbackCloseCommands'>x</a></font>", playerName, 206, 105, 20, 30, 0x324650, 0x324650, 1f)
  339.         ui.addTextArea(9, "<font size='15'><a href='event:callbackAccueilCommands'>←</a></font>", playerName, 570, 105, 20, 30, 0x324650, 0x324650, 1f)
  340.   end
  341. end
  342.  
  343. function displayMinijeux(doClose, playerName)
  344.   if doClose==true then
  345.     ui.removeTextArea(10, playerName)
  346.         ui.removeTextArea(11, playerName)
  347.         ui.removeTextArea(12, playerName)
  348.   else
  349.     ui.addTextArea(10, "<p align='center'><font color='C2C2DA' size='35' >Mini-jeux</font></p><br /><font color='#BABD2F'> • fly :</font> Volez autant que vous le pouvez !<br /><font color='#BABD2F'> • chamane :</font> Tout le monde  béneficie des pouvoirs de chamane.<br /><font color='#BABD2F'> • vampire :</font> Évitez le vampire !<br /><font color='#BABD2F'> • bootcamp :</font> Un système intelligent d'entraînement au bootcamp.", playerName, 200, 100, 400, 200, 0x324650, 0x6A8FA2, 1f)
  350.         ui.addTextArea(11, "<font size='15'><a href='event:callbackCloseMinijeux'>x</a></font>", playerName, 206, 105, 20, 30, 0x324650, 0x324650, 1f)
  351.         ui.addTextArea(12, "<font size='15'><a href='event:callbackAccueilMinijeux'>←</a></font>", playerName, 570, 105, 20, 30, 0x324650, 0x324650, 1f)
  352.   end
  353. end
  354.  
  355. function displayGestionnaire(doClose, playerName)
  356.   if doClose==true then
  357.     ui.removeTextArea(13, playerName)
  358.     ui.removeTextArea(14, playerName)
  359.     ui.removeTextArea(15, playerName)
  360.     ui.removeTextArea(16, playerName)
  361.     ui.removeTextArea(17, playerName)
  362.     ui.removeTextArea(18, playerName)
  363.     ui.removeTextArea(19, playerName)
  364.     ui.removeTextArea(20, playerName)
  365.     if bootcamp==true or chamane==true or vampire==true or fly==true or survivor==true or quizz==true then
  366.       ui.removeTextArea(21, playerName)
  367.     end
  368.   else
  369.     if bootcamp==true or chamane==true or vampire==true or fly==true or survivor==true or quizz==true then
  370.       ui.addTextArea(13, "<p align='center'><font color='#C2C2DA' size='25' >Gestionnaire de mini-jeux</font><br><br>Veuillez selectionner le mini-jeu désiré :", playerName, 200, 100, 400, 235, 0x324650, 0x6A8FA2, 1f)
  371.     else
  372.       ui.addTextArea(13, "<p align='center'><font color='#C2C2DA' size='25' >Gestionnaire de mini-jeux</font><br><br>Veuillez selectionner le mini-jeu désiré :", playerName, 200, 100, 400, 200, 0x324650, 0x6A8FA2, 1f)
  373.     end
  374.     ui.addTextArea(14, "<font size='15'><a href='event:callbackCloseGestionnaire'>x</a></font>", playerName, 205, 105, 20, 30, 0x324650, 0x324650, 1f)
  375.     ui.addTextArea(15, "<p align='center'><a href='event:callbackBootcamp'>Bootcamp</a></p>", playerName, 225, 200, 100, 20, 0x3C5064, 0x3C5064, f1)
  376.     ui.addTextArea(16, "<p align='center'><a href='event:callbackChamane'>Chamane</a></p>", playerName, 225, 250, 100, 20, 0x3C5064, 0x3C5064, f1)
  377.     ui.addTextArea(17, "<p align='center'><a href='event:callbackVampire'>Vampire</a></p>", playerName, 350, 200, 100, 20, 0x3C5064, 0x3C5064, f1)
  378.     ui.addTextArea(18, "<p align='center'><a href='event:callbackFly'>Fly</a></p>", playerName, 350, 250, 100, 20, 0x3C5064, 0x3C5064, f1)
  379.     ui.addTextArea(19, "<p align='center'><a href='event:callbackSurvivor'>Survivor</a></p>", playerName, 475, 200, 100, 20, 0x3C5064, 0x3C5064, f1)
  380.     ui.addTextArea(20, "<p align='center'><a href='event:callbackCommingsoon'>Coming soon...</a></p>", playerName, 475, 250, 100, 20, 0x3C5064, 0x3C5064, f1)
  381.    
  382.     if bootcamp==true or chamane==true or vampire==true or fly==true or survivor==true or quizz==true then
  383.       ui.addTextArea(21, "<p align='center'><a href='event:callbackStop'>Arrêter le mini-jeu en cours</a></p>", playerName, 225, 300, 350, 20, 0x3C5064, 0x3C5064, f1)
  384.     end
  385.   end
  386. end
  387.  
  388. function displayCredits(playerName)
  389.   ui.addTextArea(2, "Module par Deathmatic & Allounett", NIL, 5, 375, 400, 20, 0x6A7495, 0x6A7495, 0f)
  390. end
  391.  
  392. function activate(target)
  393.   if target=="bootcamp" then
  394.     fly = false
  395.     chamane = false
  396.     vampire = false
  397.     survivor = false
  398.     quizz = false    
  399.      
  400.     bootcamp = true
  401.      
  402.     tfm.exec.disableAutoScore(true)
  403.     tfm.exec.disableAutoShaman(true)
  404.     tfm.exec.disableAutoTimeLeft(true)
  405.     tfm.exec.disableAutoNewGame(true)
  406.     tfm.exec.disableAfkDeath(true)
  407.     tfm.exec.newGame(bootcampMaps[math.random(#bootcampMaps)])
  408.     tfm.exec.setGameTime(bootcampDuration)
  409.  
  410.   elseif target=="chamane" then
  411.     fly = false
  412.         vampire = false
  413.     bootcamp = false
  414.     survivor = false
  415.     quizz = false
  416.  
  417.         chamane = true
  418.  
  419.         tfm.exec.disableAutoShaman(true)
  420.     tfm.exec.disableAutoNewGame(true)
  421.     tfm.exec.disableAfkDeath(true)
  422.     tfm.exec.newGame(tfm.get.room.currentMap)
  423.    
  424.   elseif target=="fly" then
  425.     chamane = false
  426.         vampire = false
  427.     bootcamp = false
  428.     survivor = false
  429.     quizz = false
  430.  
  431.         fly = true
  432.  
  433.     tfm.exec.disableAutoShaman(true)
  434.     tfm.exec.disableAutoNewGame(true)
  435.     tfm.exec.disableAfkDeath(true)    
  436.         tfm.exec.newGame(tfm.get.room.currentMap)
  437.    
  438.    
  439.   elseif target=="vampire" then
  440.     fly = false
  441.     chamane = false
  442.     bootcamp = false
  443.     survivor = false
  444.     quizz = false
  445.  
  446.     vampire = true
  447.  
  448.     tfm.exec.disableAutoShaman(true)
  449.     tfm.exec.disableAutoNewGame(true)
  450.     tfm.exec.disableAfkDeath(true)
  451.  
  452.     tfm.exec.newGame(tfm.get.room.currentMap)
  453.  
  454.   elseif target=="survivor" then
  455.     fly = false
  456.     chamane = false
  457.     bootcamp = false
  458.     vampire = false
  459.     quizz = false
  460.  
  461.     survivor = true
  462.    
  463.     tfm.exec.disableAutoScore(true)
  464.     tfm.exec.disableAutoNewGame(true)
  465.     tfm.exec.disableAutoShaman(false)
  466.     tfm.exec.disableAfkDeath(false)
  467.     tfm.exec.newGame(survivorMaps[math.random(#survivorMaps)])
  468.  
  469.   else
  470.     vampire = false
  471.     chamane = false
  472.     fly = false
  473.     bootcamp = false
  474.     survivor = false
  475.     quizz = false
  476.     tfm.exec.disableAfkDeath(false)
  477.     tfm.exec.disableAutoShaman(false)
  478.     tfm.exec.disableAutoNewGame(false)
  479.     tfm.exec.disableAutoScore(false)
  480.     tfm.exec.disableAutoTimeLeft(false)
  481.     tfm.exec.newGame()
  482.   end
  483. end
  484.  
  485. function randomPlayer()
  486.   k = 1
  487.  
  488.   for p,_ in pairs(tfm.get.room.playerList) do
  489.     table[k] = p
  490.     k = k + 1
  491.   end
  492.  
  493.   random = math.random(k)
  494.   return table[random]
  495.  end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement