Advertisement
Allounett_Deathmatic

Bootcamp V3.1 [FR]

Nov 20th, 2013
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --ModuleBootcamp V3.1 by Allounett & Deathmatic
  2.  
  3. --Variables
  4. maps = {"@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"}
  5.  
  6. queue = {}
  7. respawn = {}
  8. helpOpen  = {}
  9. skip = {}
  10.  
  11. bootcampDuration = 360
  12.  
  13. -- Traductions
  14. lang = {}
  15.  
  16. lang.fr = {
  17.   help = "<N><p align='center'><font size='35' >Aide</font></p><BL><b><u>Commandes :</u></b><br /><br /><J> !help :<N> Affiche l'aide<br /><J> !kill :<N> Mourir instantanément<br /><J> !next :<N> Vote pour le changement de la map<br /><J> !checkpoint :<N> Téléporte jusqu'a votre checkpoint<br /><J> !set :<N> Set votre checkpoint<br /><J> !clear :<N> Clear votre checkpoint<br /><J> !language <R>[en/fr] <J>:<N> Change la langue<br /><J> !queue <R>[map] <J>:<N> Ajoute la map a la queue<br /><J> !time <R>[time] <J>:<N> Set le temps de la partie en cours<br /><J> !deftime <R>[time] <J>:<N> Set le temps par défaut des maps<br /><br /><BL><b><u>Touches :</u></b><br /><br /><J> [H] :<N> Affiche l'aide<br /><J> [Espace] :<N> Set votre checkpoint",
  18.   best_player = "Meilleur joueur :",
  19. }
  20.  
  21. lang.en = {
  22.   help = "<N><p align='center'><font size='35' >Help</font></p><BL><b><u>Commands :</u></b><br /><br /><J> !help :<N> Show the help<br /><J> !kill :<N> Die instantly<br /><J> !next :<N> Vote to switch the map<br /><J> !checkpoint :<N> Teleports you to your checkpoint<br /><J> !set :<N> Set your checkpoint<br /><J> !clear :<N> Clear your checkpoint<br /><J> !language <R>[en/fr] <J>:<N> Change the language<br /><J> !queue <R>[map] <J>:<N> Add the map to the queue<br /><J> !time <R>[time] <J>:<N> Set the time of the map<br /><J> !deftime <R>[time] <J>:<N> Set the default time for the maps<br /><br /><BL><b><u>Hotkeys :</u></b><br /><br /><J> [H] :<N> Show the help<br /><J> [Espace] :<N> Set your checkpoint",
  23.   best_player = "Best player :",
  24. }
  25. text = lang.fr
  26.  
  27. --Set up
  28. for name,player in pairs(tfm.get.room.playerList) do
  29.     tfm.exec.bindKeyboard(name,32,true)
  30.     tfm.exec.bindKeyboard(name,72,true)
  31.     tfm.exec.setPlayerScore(name, 0, false)
  32.     helpOpen[name] = false
  33. end
  34. tfm.exec.disableAutoScore(true)
  35. tfm.exec.disableAutoShaman(true)
  36. tfm.exec.disableAfkDeath(true)
  37. tfm.exec.disableAutoTimeLeft(true)
  38. tfm.exec.disableAutoNewGame(true)
  39. tfm.exec.newGame(maps[math.random(#maps)])
  40.  
  41. --Functions
  42. function help(func, playerName)
  43.   if func=="open" then
  44.     ui.addTextArea(1, text.help, playerName, 225, 60, 350, 275, 0x000000, 0xffffff, 0.7f, true)
  45.     ui.addTextArea(2, "<font size='15'><b><i><a href='event:callbackCloseCommands'>x</a></i></b></font>", playerName, 229, 65, 20, 30, 0x000000, 0xffffff, 0f, true)
  46.   elseif func=="close" then
  47.     ui.removeTextArea(1, playerName)
  48.     ui.removeTextArea(2, playerName)
  49.   elseif func=="update" then
  50.     ui.updateTextArea(1, text.help, playerName)
  51.     ui.updateTextArea(2, "<font size='15'><b><i><a href='event:callbackCloseCommands'>x</a></i></b></font>", playerName)
  52.   end
  53. end
  54.  
  55. function displayHeader()
  56.   topScore = 10
  57.   bestPlayer = "-"
  58.   for name,player in pairs(tfm.get.room.playerList) do
  59.     if player.score>=topScore then
  60.       topScore = player.score
  61.       bestPlayer = name
  62.     end
  63.   end
  64.   if tonumber(tfm.get.room.currentMap) then
  65.     tfm.exec.setUIMapName(tfm.get.room.currentMap.." <font color='#60608F'>|</font>   <N>"..text.best_player.." <VP>"..bestPlayer)
  66.   else
  67.     tfm.exec.setUIMapName(tfm.get.room.xmlMapInfo.author.." <BL>- "..tfm.get.room.currentMap.." <font color='#60608F'>|</font>   <N>"..text.best_player.." <VP>"..bestPlayer)
  68.   end
  69. end
  70.                                                                                                        
  71. function setCheckPoint(playerName)
  72.   if tfm.get.room.playerList[playerName].hasCheese then
  73.     respawn[playerName].withCheese = true
  74.   end
  75.   respawn[playerName].spawn = false
  76.   respawn[playerName].x = tfm.get.room.playerList[playerName].x
  77.   respawn[playerName].y = tfm.get.room.playerList[playerName].y
  78. end
  79.  
  80. function tpCheckpoint(playerName)
  81.   if not respawn[playerName].spawn then
  82.     respawn[playerName].hasUse = true
  83.     tfm.exec.movePlayer(playerName, respawn[playerName].x, respawn[playerName].y, false, 0, 0, false)
  84.     if respawn[playerName].withCheese then
  85.       tfm.exec.giveCheese(playerName)
  86.     end
  87.   else
  88.     respawn[playerName].hasUse = false
  89.   end
  90. end
  91.  
  92. --Cmd stuff
  93. for i,cmd in ipairs({"language", "set", "checkpoint", "clear", "help", "next", "queue", "kill", "time", "deftime"}) do
  94.   system.disableChatCommandDisplay(cmd)
  95. end
  96.  
  97. --Cmd
  98. function eventChatCommand(playerName, message)
  99.   --Split the message
  100.   local args = {}
  101.     for arg in message:gmatch("[^%s]+") do
  102.       table.insert(args,arg:lower())
  103.     end
  104.  
  105.   --Cmd
  106.   if args[1]=="language" and args[2] then
  107.     if args[2]=="fr" then
  108.       text = lang.fr
  109.     elseif args[2]=="en" then
  110.       text = lang.en
  111.     end
  112.     displayHeader()
  113.     help("update")
  114.   end
  115.   if args[1]=="set" then
  116.     setCheckPoint(playerName)
  117.   end
  118.   if args[1]=="checkpoint" then
  119.     tpCheckpoint(playerName)
  120.   end
  121.   if args[1]=="clear" then
  122.     respawn[playerName].withCheese = false
  123.     respawn[playerName].spawn = true
  124.   end
  125.   if args[1]=="next" then
  126.     for i,name in pairs(skip) do
  127.       if playerName==name then
  128.         return
  129.       end
  130.     end
  131.     table.insert(skip, playerName)
  132.     players = 0
  133.     for name,player in pairs(tfm.get.room.playerList) do
  134.       players = players+1
  135.     end
  136.     if #skip>=math.floor(players/2) then
  137.       eventLoop(0,0,true)
  138.     end
  139.   end
  140.   if args[1]=="queue" and tonumber(args[2]) then
  141.     for i,map in ipairs(queue) do
  142.       if args[2]==map.code or playerName==map.name then
  143.         return
  144.       end
  145.     end
  146.     table.insert(queue, {code = args[2], name = playerName})
  147.   end
  148.   if args[1]=="kill" then
  149.     tfm.exec.killPlayer(playerName)
  150.   end
  151.   if args[1]=="time" and tonumber(args[2]) then
  152.       tfm.exec.setGameTime(args[2])
  153.   end
  154.   if args[1]=="deftime" and tonumber(args[2]) then
  155.       bootcampDuration = args[2]
  156.   end
  157.   if args[1]=="help" then
  158.     if not helpOpen[playerName] then
  159.       helpOpen[playerName] = true
  160.       help("open", playerName)
  161.     elseif helpOpen[playerName] then
  162.       helpOpen[playerName] = false
  163.       help("close", playerName)
  164.     end
  165.   end
  166. end
  167.  
  168. --CallBack
  169. function eventTextAreaCallback(textAreaId, playerName, callback)
  170.   if callback=="callbackCloseCommands" then
  171.     help("close", playerName)
  172.   end
  173. end
  174.  
  175. --Game
  176. function eventLoop(currentTime, timeRemaining, next)
  177.   if timeRemaining<=0 then
  178.     if #queue>=1 then
  179.       if next then
  180.         tfm.exec.setGameTime(4)
  181.       end
  182.       tfm.exec.newGame(queue[1].code)
  183.       table.remove(queue, 1)
  184.     else
  185.       tfm.exec.newGame(maps[math.random(#maps)])
  186.     end
  187.   end
  188.   displayHeader()
  189. end
  190.  
  191. function eventNewGame()
  192.   skip = {}
  193.   leader = 0
  194.   displayHeader()
  195.   tfm.exec.setGameTime(bootcampDuration)
  196.   for name,player in pairs(tfm.get.room.playerList) do
  197.     respawn[name] = {spawn = true, x = 0, y = 0, hasUse = false, withCheese = false}
  198.   end
  199. end
  200.  
  201. --KeyBoard stuff
  202. function eventKeyboard(playerName, keyCode)
  203.   if keyCode==32 then
  204.     setCheckPoint(playerName)
  205.   elseif keyCode==72 then
  206.     eventChatCommand(playerName, "help")
  207.   end
  208. end
  209.  
  210. --New player
  211. function eventNewPlayer(playerName)
  212.   tfm.exec.bindKeyboard(playerName,32,true)
  213.   tfm.exec.bindKeyboard(playerName,72,true)
  214.   helpOpen[playerName] = false
  215.   respawn[playerName] = {spawn = true, x = 0, y = 0, hasUse = false, withCheese = false}
  216.   tfm.exec.respawnPlayer(playerName)
  217. end
  218.  
  219. --Player die
  220. function eventPlayerDied(playerName)
  221.   tfm.exec.respawnPlayer(playerName)
  222.   tpCheckpoint(playerName)
  223. end
  224.  
  225. --Player won
  226. function eventPlayerWon(playerName)
  227.   leader = leader+1
  228.   if not respawn[playerName].hasUse and leader==1 then
  229.     tfm.exec.setPlayerScore(playerName, 16, true)
  230.   elseif not respawn[playerName].hasUse and leader==2 then
  231.     tfm.exec.setPlayerScore(playerName, 14, true)
  232.   elseif not respawn[playerName].hasUse and leader==3 then
  233.     tfm.exec.setPlayerScore(playerName, 12, true)
  234.   elseif not respawn[playerName].hasUse then
  235.     tfm.exec.setPlayerScore(playerName, 10, true)
  236.   end
  237.   respawn[playerName].withCheese = false
  238.   respawn[playerName].hasUse = false
  239.   respawn[playerName].spawn = true
  240.   tfm.exec.respawnPlayer(playerName)
  241. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement