Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --ModuleBootcamp V3.1 by Allounett & Deathmatic
- --Variables
- 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"}
- queue = {}
- respawn = {}
- helpOpen = {}
- skip = {}
- bootcampDuration = 360
- -- Traductions
- lang = {}
- lang.fr = {
- 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",
- best_player = "Meilleur joueur :",
- }
- lang.en = {
- 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",
- best_player = "Best player :",
- }
- text = lang.fr
- --Set up
- for name,player in pairs(tfm.get.room.playerList) do
- tfm.exec.bindKeyboard(name,32,true)
- tfm.exec.bindKeyboard(name,72,true)
- tfm.exec.setPlayerScore(name, 0, false)
- helpOpen[name] = false
- end
- tfm.exec.disableAutoScore(true)
- tfm.exec.disableAutoShaman(true)
- tfm.exec.disableAfkDeath(true)
- tfm.exec.disableAutoTimeLeft(true)
- tfm.exec.disableAutoNewGame(true)
- tfm.exec.newGame(maps[math.random(#maps)])
- --Functions
- function help(func, playerName)
- if func=="open" then
- ui.addTextArea(1, text.help, playerName, 225, 60, 350, 275, 0x000000, 0xffffff, 0.7f, true)
- 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)
- elseif func=="close" then
- ui.removeTextArea(1, playerName)
- ui.removeTextArea(2, playerName)
- elseif func=="update" then
- ui.updateTextArea(1, text.help, playerName)
- ui.updateTextArea(2, "<font size='15'><b><i><a href='event:callbackCloseCommands'>x</a></i></b></font>", playerName)
- end
- end
- function displayHeader()
- topScore = 10
- bestPlayer = "-"
- for name,player in pairs(tfm.get.room.playerList) do
- if player.score>=topScore then
- topScore = player.score
- bestPlayer = name
- end
- end
- if tonumber(tfm.get.room.currentMap) then
- tfm.exec.setUIMapName(tfm.get.room.currentMap.." <font color='#60608F'>|</font> <N>"..text.best_player.." <VP>"..bestPlayer)
- else
- tfm.exec.setUIMapName(tfm.get.room.xmlMapInfo.author.." <BL>- "..tfm.get.room.currentMap.." <font color='#60608F'>|</font> <N>"..text.best_player.." <VP>"..bestPlayer)
- end
- end
- function setCheckPoint(playerName)
- if tfm.get.room.playerList[playerName].hasCheese then
- respawn[playerName].withCheese = true
- end
- respawn[playerName].spawn = false
- respawn[playerName].x = tfm.get.room.playerList[playerName].x
- respawn[playerName].y = tfm.get.room.playerList[playerName].y
- end
- function tpCheckpoint(playerName)
- if not respawn[playerName].spawn then
- respawn[playerName].hasUse = true
- tfm.exec.movePlayer(playerName, respawn[playerName].x, respawn[playerName].y, false, 0, 0, false)
- if respawn[playerName].withCheese then
- tfm.exec.giveCheese(playerName)
- end
- else
- respawn[playerName].hasUse = false
- end
- end
- --Cmd stuff
- for i,cmd in ipairs({"language", "set", "checkpoint", "clear", "help", "next", "queue", "kill", "time", "deftime"}) do
- system.disableChatCommandDisplay(cmd)
- end
- --Cmd
- function eventChatCommand(playerName, message)
- --Split the message
- local args = {}
- for arg in message:gmatch("[^%s]+") do
- table.insert(args,arg:lower())
- end
- --Cmd
- if args[1]=="language" and args[2] then
- if args[2]=="fr" then
- text = lang.fr
- elseif args[2]=="en" then
- text = lang.en
- end
- displayHeader()
- help("update")
- end
- if args[1]=="set" then
- setCheckPoint(playerName)
- end
- if args[1]=="checkpoint" then
- tpCheckpoint(playerName)
- end
- if args[1]=="clear" then
- respawn[playerName].withCheese = false
- respawn[playerName].spawn = true
- end
- if args[1]=="next" then
- for i,name in pairs(skip) do
- if playerName==name then
- return
- end
- end
- table.insert(skip, playerName)
- players = 0
- for name,player in pairs(tfm.get.room.playerList) do
- players = players+1
- end
- if #skip>=math.floor(players/2) then
- eventLoop(0,0,true)
- end
- end
- if args[1]=="queue" and tonumber(args[2]) then
- for i,map in ipairs(queue) do
- if args[2]==map.code or playerName==map.name then
- return
- end
- end
- table.insert(queue, {code = args[2], name = playerName})
- end
- if args[1]=="kill" then
- tfm.exec.killPlayer(playerName)
- end
- if args[1]=="time" and tonumber(args[2]) then
- tfm.exec.setGameTime(args[2])
- end
- if args[1]=="deftime" and tonumber(args[2]) then
- bootcampDuration = args[2]
- end
- if args[1]=="help" then
- if not helpOpen[playerName] then
- helpOpen[playerName] = true
- help("open", playerName)
- elseif helpOpen[playerName] then
- helpOpen[playerName] = false
- help("close", playerName)
- end
- end
- end
- --CallBack
- function eventTextAreaCallback(textAreaId, playerName, callback)
- if callback=="callbackCloseCommands" then
- help("close", playerName)
- end
- end
- --Game
- function eventLoop(currentTime, timeRemaining, next)
- if timeRemaining<=0 then
- if #queue>=1 then
- if next then
- tfm.exec.setGameTime(4)
- end
- tfm.exec.newGame(queue[1].code)
- table.remove(queue, 1)
- else
- tfm.exec.newGame(maps[math.random(#maps)])
- end
- end
- displayHeader()
- end
- function eventNewGame()
- skip = {}
- leader = 0
- displayHeader()
- tfm.exec.setGameTime(bootcampDuration)
- for name,player in pairs(tfm.get.room.playerList) do
- respawn[name] = {spawn = true, x = 0, y = 0, hasUse = false, withCheese = false}
- end
- end
- --KeyBoard stuff
- function eventKeyboard(playerName, keyCode)
- if keyCode==32 then
- setCheckPoint(playerName)
- elseif keyCode==72 then
- eventChatCommand(playerName, "help")
- end
- end
- --New player
- function eventNewPlayer(playerName)
- tfm.exec.bindKeyboard(playerName,32,true)
- tfm.exec.bindKeyboard(playerName,72,true)
- helpOpen[playerName] = false
- respawn[playerName] = {spawn = true, x = 0, y = 0, hasUse = false, withCheese = false}
- tfm.exec.respawnPlayer(playerName)
- end
- --Player die
- function eventPlayerDied(playerName)
- tfm.exec.respawnPlayer(playerName)
- tpCheckpoint(playerName)
- end
- --Player won
- function eventPlayerWon(playerName)
- leader = leader+1
- if not respawn[playerName].hasUse and leader==1 then
- tfm.exec.setPlayerScore(playerName, 16, true)
- elseif not respawn[playerName].hasUse and leader==2 then
- tfm.exec.setPlayerScore(playerName, 14, true)
- elseif not respawn[playerName].hasUse and leader==3 then
- tfm.exec.setPlayerScore(playerName, 12, true)
- elseif not respawn[playerName].hasUse then
- tfm.exec.setPlayerScore(playerName, 10, true)
- end
- respawn[playerName].withCheese = false
- respawn[playerName].hasUse = false
- respawn[playerName].spawn = true
- tfm.exec.respawnPlayer(playerName)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement