Advertisement
Math_TM

DeathWar V1.3.2

Apr 2nd, 2017
860
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 49.94 KB | None | 0 0
  1. --[[              Module created by Athesdrake              ]]--
  2. --[[        http://atelier801.com/topic?f=6&t=852348        ]]--
  3.  
  4. limite = 10
  5. function main()
  6.     --vars:
  7.         start = false
  8.         setup = true
  9.         lobby = true
  10.         joinQuit = true
  11.         uwin = true
  12.         fireworks = false
  13.         format = string.format
  14.         currentMap = "@0"
  15.         nextMap = "normal"
  16.         version = "1.3.2"
  17.         C = "center"
  18.         L = "left"
  19.         R = "right"
  20.     --ids:
  21.         idTeam = 100
  22.         id_scoreboard = 5
  23.         idTitle = 6
  24.         idHelp = 7
  25.         idPause = 8
  26.         idTimer = 9
  27.         idWinner = 10
  28.         idOffChange = 11
  29.         idLang = 12
  30.         idInfo = 13
  31.     --tables:
  32.         players = {}
  33.         pause = {p = false, vote={nbr=0, oui=0, non=0}}
  34.         vote = {current=false}
  35.         record = {}
  36.         aft = {}
  37.         nextRecord = true
  38.         lastRecord = false
  39.         --maps:
  40.             maps = {"@4795468", "@4773530", "@4741240", "@4741230", "@4741187", "@4741121", "@4734142", "@4734088", "@4733964", "@4589495", "@4386849", "@3899992", "@3661362", "@3654127", "@3598126", "@3425866", "@3387205", "@3377082", "@3326933", "@3274133", "@3271109", "@3255179", "@3242667", "@3242517", "@3237641", "@3228893", "@3219038", "@3210915", "@3192515", "@2614830", "@2336509", "@2262150", "@2242196", "@2221226", "@2173893", "@2155997", "@2147778", "@2135605", "@2135145", "@2119852", "@2119800", "@2117839", "@2105100", "@2103061", "@2068587", "@2059382", "@2054347", "@2050554", "@2040205", "@2004074", "@1997222", "@1985670", "@1979178", "@1967362", "@1966987", "@1943308", "@1904053", "@1900275", "@1897581", "@1897390", "@1879154", "@1846255", "@1829042", "@1825269", "@1705433", "@1682014", "@1675013", "@1643446", "@1533678", "@1531279", "@1408028", "@1314982", "@1312845", "@1311136", "@1288489", "@1286824", "@965024", "@589708", "@559644", "@559634", "@541917", "@4741135", "@1922239", "@1659906"}
  41.             --last list{'@5032645', '@5028790', '@5028785', '@5028742', '@5028732', '@5028724', '@5028719', '@5028718', '@5028713', '@5028712', '@5028710', '@5028708', '@5028706', '@5028703', '@5028698', '@4795468', '@4788935', '@4773530', '@4741240', '@4741230', '@4741210', '@4741187', '@4741180', '@4741135', '@4741121', '@4734196', '@4734142', '@4734088', '@4734030', '@4733964', '@4589495', '@4482813', '@4469762', '@4464477', '@4462420', '@4428376', '@4419442', '@4392183', '@4386849', '@4383742', '@4383258', '@4374762', '@4131862', '@3899992', '@3827437', '@3798599', '@3661362', '@3654127', '@3598126', '@3577308', '@3532350', '@3497786', '@3479878', '@3446890', '@3425866', '@3387205', '@3377082', '@3326933', '@3282267', '@3274133', '@3271109', '@3255179', '@3242667', '@3242517', '@3237641', '@3228893', '@3219038', '@3210915', '@3192515', '@2867351', '@2633322', '@2614830', '@2386206', '@2336509', '@2262150', '@2242196', '@2226913', '@2222125', '@2221623', '@2221226', '@2218853', '@2217944', '@2186266', '@2173893', '@2155997', '@2147778', '@2145870', '@2135605', '@2135145', '@2130154', '@2124484', '@2119852', '@2119800', '@2117839', '@2105100', '@2103061', '@2068587', '@2059382', '@2054347', '@2050554', '@2040205', '@2024135', '@2004074', '@1997222', '@1985670', '@1979178', '@1967497', '@1967362', '@1966987', '@1960602', '@1953765', '@1943308', '@1922239', '@1904053', '@1901780', '@1900275', '@1897960', '@1897581', '@1897390', '@1879801', '@1879154', '@1870360', '@1846255', '@1840913', '@1829042', '@1825269', '@1824622', '@1794409', '@1790994', '@1768083', '@1766854', '@1757177', '@1745896', '@1741100', '@1738707', '@1737915', '@1705433', '@1700322', '@1700119', '@1699880', '@1682014', '@1675316', '@1675013', '@1659906', '@1643446', '@1624034', '@1616785', '@1601580', '@1596270', '@1582146', '@1563534', '@1545219', '@1533678', '@1531402', '@1531320', '@1531316', '@1531295', '@1531279', '@1408028', '@1351237', '@1349878', '@1348152', '@1343986', '@1318248', '@1314982', '@1312845', '@1311136', '@1298164', '@1296949', '@1288489', '@1286824', '@1276664', '@1255983', '@1057753', '@965024', '@910078', '@873428', '@869836', '@770600', '@644588', '@623770', '@589800', '@589708', '@559644', '@559634', '@541917'}
  42.             --198 maps → 84 maps
  43.             lobby_map = [[<C><P F="7" /><Z><S><S P="0,0,0,,0,0,0,0" L="10" o="324650" H="400" Y="200" T="12" X="-5" /><S P="0,0,0.3,0.2,,0,0,0" L="820" o="324650" H="10" Y="-5" T="12" X="400" /><S P="0,0,0,,0,0,0,0" L="10" o="324650" H="400" Y="200" T="12" X="805" /><S P="0,0,0.3,0.2,,0,0,0" L="820" o="324650" H="10" Y="405" T="12" X="400" /><S P="0,0,0.3,0.2,,0,0,0" L="800" o="324650" H="10" Y="145" T="12" X="400" /><S L="51" o="222222" c="4" X="710" H="10" Y="83" T="13" P="0,0,0.3,0.2,,0,0,0" /><S c="4" P="0,0,0.3,0.2,,0,0,0" L="49" o="292929" H="10" Y="83" T="13" X="710" /><S P="0,0,0.3,0.2,,0,0,0" L="39" o="1b1b1b" c="4" X="708" Y="91" T="13" H="10" /><S P="0,0,0.3,0.2,,0,0,0" L="40" c="4" o="292929" X="711" Y="86" T="13" H="10" /><S P="0,0,0.3,0.2,,0,0,0" L="12" o="4a5257" c="4" X="737" Y="57" T="13" H="10" /><S L="60" c="4" o="5c676d" X="710" H="10" Y="83" T="12" P="0,0,0.3,0.2,,0,0,0" /><S L="30" o="5c676d" c="4" X="725" H="10" Y="72" T="12" P="0,0,0.3,0.2,40,0,0,0" /><S P="0,0,0.3,0.2,-40,0,0,0" L="30" o="5c676d" c="4" H="10" Y="94" T="12" X="725" /><S P="0,0,0.3,0.2,,0,0,0" L="10" o="4a5257" c="4" X="710" Y="44" T="13" H="10" /><S P="0,0,0.3,0.2,,0,0,0" L="51" o="222222" c="4" H="10" Y="83" T="13" X="92" /><S L="49" c="4" o="292929" H="10" X="92" Y="83" T="13" P="0,0,0.3,0.2,,0,0,0" /><S L="39" o="1b1b1b" c="4" X="96" H="10" Y="90" T="13" P="0,0,0.3,0.2,,0,0,0" /><S L="40" c="4" o="292929" X="93" H="10" Y="85" T="13" P="0,0,0.3,0.2,,0,0,0" /><S L="12" o="4a5257" c="4" X="64" H="10" Y="57" T="13" P="0,0,0.3,0.2,,0,0,0" /><S P="0,0,0.3,0.2,,0,0,0" L="60" o="5c676d" c="4" H="10" Y="83" T="12" X="92" /><S P="0,0,0.3,0.2,140,0,0,0" L="30" o="5c676d" c="4" H="10" Y="72" T="12" X="77" /><S L="30" o="5c676d" c="4" H="10" X="77" Y="93" T="12" P="0,0,0.3,0.2,-140,0,0,0" /><S L="10" o="4a5257" c="4" X="92" H="10" Y="43" T="13" P="0,0,0.3,0.2,,0,0,0" /></S><D><DS Y="83" X="399" /></D><O /></Z></C>]]
  44.         --fin maps
  45.         teams = {}
  46.         todespawn = {}
  47.         T = {
  48.             fr = {
  49.                 scoreboard = "%s<font size='%d'><u><b>%s</b></u></font>\t\t%s points\t\t%s victoires<font face='Lucida Console'><r>\n   n. joueur           victoires     survies\n</r>",
  50.                 offset = "Ton offset a bien été changé en X:%d Y:%d.",
  51.                 accept = " Acceptes-tu ? </fc><vp><a href='event:%s$oui'>Oui</a></vp> | <r><a href='event:%s$non'>Non</a><r/>",
  52.                 help_txt = "Bienvenue dans DeathWar,\nCe module consiste à avoir des équipes ( 5 maximum ) qui s'affrontent. Chaque équipe peut contenir 10 joueurs maximum.\nUn chef par équipe sera désigné pour mettre de l'ordre. Il aura la possibilité de faire certaines <a href='event:$call$help$n$N1'><u><vp>!commande</vp></u></a>.\n\nUne fois que toutes les équipes sont prêtes, le combat commence !\n\nSignalez-moi les bugs que vous rencontrez par messages sur le forum! Décrivez le bug avec autant de détails que possible, avec un screen si possible.\n\n<p align='right'>Module imaginé par <bv>Sourixl</bv>, créé par <n2>Athesdrake</n2>.</p>\n\n\n<vi>Version</vi> <rose>%s</rose>",
  53.                 win_close = "Fermer cette fenêtre",
  54.                 team = {
  55.                     color = "Choisis la couleur de ton équipe.",
  56.                     done = "Prêts",
  57.                     quit = "Quitter",
  58.                     join = "Rejoindre",
  59.                     win = "%s a gagné !"
  60.                 },
  61.                 commands = {
  62.                     pause = {
  63.                         ask = "<j>%s</j><fc> veut faire une pause.",
  64.                         set = "La pause arrive à la prochaine map !",
  65.                     },
  66.                     nc_last = {
  67.                         ask = "<j>%s</j><fc> veut annuler le point précédant.",
  68.                         set = "Le dernier point a été annulé !",
  69.                     },
  70.                     nc_next = {
  71.                         ask = "<j>%s</j><fc> veut annuler le prochain point.",
  72.                         set = "Le prochain point ne comptera pas !",
  73.                     },
  74.                     skip = {
  75.                         ask = "<j>%s</j><fc> veut passer la map.",
  76.                         set = "Passons à la prochaine map !",
  77.                     },
  78.                     untilwin = {
  79.                         ask = "<j>%s</j><fc> veut mettre un temps illimité à cette partie.",
  80.                         set = "Le temps de cette partie est infini !",
  81.                     },
  82.                 },
  83.                 HELP = {
  84.                     title={txt="Liste des commandes", color=nil, bcolor=nil, size=nil, align=C, u=true, b=true, i=false},
  85.                     p = {
  86.                         {txt="Pour les chefs d'équipes:", u=true,
  87.                             content = {
  88.                                 {cmd="help",                  description="Affiche de l'aide."},
  89.                                 {cmd="commands",              description="Affiche la liste des commandes."},
  90.                                 {cmd="color",                 description="Changer la couleur de son équipe."},
  91.                                 {cmd="name",  arg={"nom"},    description="Changer le nom de son équipe."},
  92.                                 {cmd="ban",   arg={"joueur"}, description="Bannir une personne de son équipe."},
  93.                                 {cmd="unban", arg={"joueur"}, description="Dé-bannir une personne de son équipe."},
  94.                                 {cmd="done",                  description="Une fois que l'équipe est prête."},
  95.                                 {cmd="pause",                 description="Faire un vote pour une pause de maximum 5min."},
  96.                                 {cmd="skip",                  description="Mets la map suivante."},
  97.                                 {cmd="untilwin",              description="La map est jouée jusqu'à la victoire d'une équipe."},
  98.                                 {cmd="nc",    arg={"type"},   description="Deux types différents:\n\t\t\t\t\t\t\t\t- 'last' qui annule le point précédant.\n\t\t\t\t\t\t\t\t- 'next' qui annule le prochain point."},
  99.                                 --{cmd="<r>changement</r>", arg={"j1", "j2", f={"j", "fc"}}, description="Permet de remplacer une <j>personne de votre équipe</j> par un <fc>spectateur</fc>."},
  100.                             }
  101.                         },
  102.                         {txt="Pour les joueurs:", u=true,
  103.                             content = {
  104.                                 {cmd="off",    arg={"x", "y"}, description="Changer son offset."},
  105.                                 {cmd="offset", arg={"x", "y"}, description="Similaire à !off."},
  106.                                 {cmd="help",                   description="Montre de l'aide."},
  107.                                 {cmd="command",                description="Montre toutes les commandes."},
  108.                                 {cmd="cmd",                    description="Similaire à !command."},
  109.                             }
  110.                         }
  111.                     }
  112.                 }
  113.             },
  114.             en = {
  115.                 scoreboard = "%s<font size='%d'><u><b>%s</b></u></font>\t\t%s points\t\t%s victories<font face='Lucida Console'><r>\n   n. player           victories     survives\n</r>",
  116.                 offset = "Your offset has been changed into X:%s Y:%s.",
  117.                 accept = " Do you accept ? </fc><vp><a href='event:%s$oui'>Yes</a></vp> | <r><a href='event:%s$non'>No</a><r/>",
  118.                 help_txt = "Welcome to DeathWar,\nThis module consist to be in a confrontation between others teams ( 5 maximum ). Each team can had a maximum of 10 players.\nThe player who create a team is its leader, all leaders make order. They have the possibility to make some <a href='event:$call$help$n$N1'><u><vp>!commands</vp></u></a>.\n\nWhen all teams are ready, the fight can begin !\n\nReport me all the bugs you meet on the forum! Describe the bug and if possible, give me a screenshot.\n\n<p align='right'>Module conceived by <bv>Sourixl</bv>, created by <n2>Athesdrake</n2>.</p>\n\n\n<vi>Version</vi> <rose>%s</rose>",
  119.                 win_close = "Close",
  120.                 team = {
  121.                     color = "Choose your team's color.",
  122.                     done = "Ready",
  123.                     quit = "Quit",
  124.                     join = "Join",
  125.                     win = "%s has won !"
  126.                 },
  127.                 commands = {
  128.                     pause = {
  129.                         ask = "<j>%s</j><fc> wants to make a break.",
  130.                         set = "Let's make a break !"
  131.                     },
  132.                     nc_last = {
  133.                         ask = "<j>%s</j><fc> wants to delete the previous point.",
  134.                         set = "The last point has been deleted !",
  135.                     },
  136.                     nc_next = {
  137.                         ask = "<j>%s</j><fc> wants to cancel the next point.",
  138.                         set = "The next point won't count !",
  139.                     },
  140.                     skip = {
  141.                         ask = "<j>%s</j><fc> wants to skip this map.",
  142.                         set = "Let's move on the next map !",
  143.                     },
  144.                     untilwin = {
  145.                         ask = "<j>%s</j><fc> wants to set the time to infinite for this map.",
  146.                         set = "The game's time is infinite !",
  147.                     },
  148.                 },
  149.                 HELP = {
  150.                     title={txt="Commands list", color=nil, bcolor=nil, size=nil, align=C, u=true, b=true, i=false},
  151.                     p = {
  152.                         {txt="For the leaders:", u=true,
  153.                             content = {
  154.                                 {cmd="help",                  description="Shows the help."},
  155.                                 {cmd="commands",              description="Shows the commands list."},
  156.                                 {cmd="color",                 description="Change your team's color."},
  157.                                 {cmd="name",  arg={"name"},   description="Change your name's team."},
  158.                                 {cmd="ban",   arg={"player"}, description="Ban a player from your team."},
  159.                                 {cmd="unban", arg={"player"}, description="Unban a player from your team."},
  160.                                 {cmd="done",                  description="To inform the others teams that you're ready. You can't do any team commands while you're 'done'."},
  161.                                 {cmd="pause",                 description="Make a break of 5 min max."},
  162.                                 {cmd="skip",                  description="Skip the map."},
  163.                                 {cmd="untilwin",              description="The current map is played until one team win."},
  164.                                 {cmd="nc",    arg={"type"},   description="Two different types:\n\t\t\t\t\t\t\t\t- 'last' cancel the previous point.\n\t\t\t\t\t\t\t\t- 'next' cancel the next point."},
  165.                             }
  166.                         },
  167.                         {txt="For all:", u=true,
  168.                             content = {
  169.                                 {cmd="off",    arg={"x", "y"}, description="Change your offset."},
  170.                                 {cmd="offset", arg={"x", "y"}, description="Similar to !off."},
  171.                                 {cmd="lang",  arg={"lang"},    description="Change the language of the module."},
  172.                                 {cmd="help",                   description="Shows help."},
  173.                                 {cmd="command",                description="Shows all the commands."},
  174.                                 {cmd="cmd",                    description="Similar to !command."},
  175.                             }
  176.                         }
  177.                     }
  178.                 }
  179.             },
  180.             tr = {
  181.                 scoreboard = "%s<font size='%d'><u><b>%s</b></u></font>\t\t%s puan\t\t%s zaferler<font face='Lucida Console'><r>\n   n. Oyuncular         zaferler     hayatta kalmalar\n</r>",
  182.                 offset =     "Ofsetiniz X:%s Y:%s olarak değiştirildi.",
  183.                 accept =     " Kabul ediyor musun? </fc><vp><a href='event:%s$oui'>Evet</a></vp> | <r><a href='event:%s$non'>Hayır</a><r/>",
  184.                 help_txt =   "DeathWar'a hoş geldin! \nBu modül diğer takımlarla çatışma halinde bulunmaktan ibarettir (en fazla beş). Her takımda en fazla on oyuncu olabilir. \nTakımı kuran ilk oyuncu takım lideri olur. Tüm liderler emirler verebilir. Liderler bazı <a href='event:$call$help$n$N1'><u><vp>!commands</vp></u></a> yapma imkanına sahiptir.\n\nTüm takımlar hazır olduğunda, savaş başlayabilir!\n\nKarşılaştığınız hataları forum üzerinden bana bildirin! Eğer mümkünse hatayı açıklayın, bana ekran görüntüsü yollayın.\n\n<p align='right'><bv>Sourixl</bv> tarafından tasarlanmış, <n2>Athesdrake</n2> tarafından oluşturulmuştur. \n<vp>Honorabilis</vp> tarafından Türkçeleştirilmiştir.</p>\n\n\n<vi>Sürüm:</vi> <rose>%s</rose>",
  185.                 win_close =  "Kapat",
  186.                 team = {
  187.                     color = "Takımının rengini seç.",
  188.                     done =  "Hazır",
  189.                     quit =  "Çık",
  190.                     join =  "Katıl",
  191.                     win =   "%s kazandı!"
  192.                 },
  193.                 commands = {
  194.                     pause = {
  195.                         ask = "<j>%s</j><fc> mola istiyor.",
  196.                         set = "Hadi, mola verelim!"
  197.                     },
  198.                     nc_last = {
  199.                         ask = "<j>%s</j><fc> bir önceki puanı yok saymak istiyor.",
  200.                         set = "Bir önceki puan yok sayıldı!",
  201.                     },
  202.                     nc_next = {
  203.                         ask = "<j>%s</j><fc> bir sonraki puanı yok saymak istiyor.",
  204.                         set = "Bir sonraki puan yok sayılacak.",
  205.                     },
  206.                     skip = {
  207.                         ask = "<j>%s</j><fc> bu haritayı geçmek istiyor.",
  208.                         set = "Hadi, sonraki haritaya geçelim!",
  209.                     },
  210.                     untilwin = {
  211.                         ask = "<j>%s</j><fc> bu haritanın süresini sınırsız yapmak istiyor.",
  212.                         set = "Bu haritanın süresi sınırsız!",
  213.                     },
  214.                 },
  215.                 HELP = {
  216.                     title={txt="Komutlar Listesi",color=nil, bcolor=nil, size=nil, align=C, u=true, b=true, i=false},
  217.                     p = {
  218.                         {txt="Liderler için:", u=true,
  219.                             content = {
  220.                                 {cmd="help",                  description="Yardım sayfasını gösterir."},
  221.                                 {cmd="commands",              description="Komutlar listesini gösterir."},
  222.                                 {cmd="color",                 description="Takımın rengini değiştirir."},
  223.                                 {cmd="name",  arg={"isim"},   description="Takımın ismini değiştirir."},
  224.                                 {cmd="ban",   arg={"oyuncu"}, description="Takımındaki bir oyuncuyu yasaklar."},
  225.                                 {cmd="unban", arg={"oyuncu"}, description="Takımındaki bir oyuncunun yasağını kaldırır."},
  226.                                 {cmd="done",                  description="Diğer takımlara senin takımının hazır olduğunu bildirir. Hazırken hiçbir takım komutu veremezsin."},
  227.                                 {cmd="pause",                 description="En fazla beş dakikalık mola verir."},
  228.                                 {cmd="skip",                  description="Geçerli haritayı atlar."},
  229.                                 {cmd="untilwin",              description="Herhangi bir takım kazanana kadar geçerli harita oynanır."},
  230.                                 {cmd="nc",    arg={"tür"},    description="İki farklı tür:\n\t\t\t\t\t\t\t\t- 'last', bir önceki punaı yok sayar.\n\t\t\t\t\t\t\t\t- 'next', bir sonraki puanı yok sayar."},
  231.                             }
  232.                         },
  233.                         {txt="Herkes için:", u=true,
  234.                             content = {
  235.                                 {cmd="off",    arg={"x", "y"}, description="Ofsetini değiştirir."},
  236.                                 {cmd="offset", arg={"x", "y"}, description="'!off' ile aynıdır."},
  237.                                 {cmd="help",                   description="Yardım menüsünü gösterir."},
  238.                                 {cmd="command",                description="Tüm komutların listesini gösterir."},
  239.                                 {cmd="cmd",                    description="'!command' ile aynıdır."},
  240.                             }
  241.                         }
  242.                     }
  243.                 }
  244.             },
  245.         }
  246.     --sytème:
  247.         table.foreach(--disable
  248.             {
  249.                 "AutoNewGame",
  250.                 "AutoShaman",
  251.                 "AutoTimeLeft",
  252.                 "AfkDeath",
  253.                 "MortCommand",
  254.                 "DebugCommand",
  255.                 "PhysicalConsumables"
  256.             },
  257.             function(_,v)
  258.                 tfm.exec["disable"..v](true)
  259.             end
  260.             )
  261.         table.foreach({"off", "offset", "debug"}, function(_,v) system.disableChatCommandDisplay(v, true) end)
  262.         table.foreach(tfm.get.room.playerList, function(v) eventNewPlayer(v) end)
  263.         setUp()
  264. end
  265.  
  266. function eventNewPlayer(name)
  267.     local co = tfm.get.room.playerList[name].community
  268.     if not players[name] then
  269.         players[name] = {team = 0, points = 0, survies = 0, offset = {x=2, y=8}, timestamp = os.time() +3000, chef=false, down = false, lang = T[co] and co or "en", afk_time=os.time()}
  270.     elseif lobby and players[name].team~=0 then
  271.         for k, v in pairs(teams) do
  272.             if v[name] then
  273.                 v[name] = 1
  274.                 players[name].team = k
  275.             end
  276.         end
  277.         tfm.exec.respawnPlayer(name)
  278.         if teams[players[name].team].hide then teams[players[name].team].hide = false; reloadTeams(true) end
  279.         tfm.exec.movePlayer(name, teams[players[name].team].spawn, 350)
  280.     end
  281.     help(name, 0)
  282.     if tfm.get.room.currentMap=="@0" then
  283.         ui.setMapName("<j>Sourixl<g> - @7103699 | <j>V"..version.." <n2>created by Athesdrake\n")
  284.         ui.addTextArea(idTitle, "<p align='center'><font color='#CC2126' size='75' face='Bauhaus 93'>DeathWar", nil, 0, 30, 800, 150, 0x0)
  285.         reloadTeams()
  286.         tfm.exec.respawnPlayer(name)
  287.     end
  288.     table.foreach({0,1,2,3,32,76}, function(k,v) system.bindKeyboard(name, v, true, true) end)
  289. end
  290.  
  291. function eventPlayerLeft(name)
  292.     if players[name] and players[name].team~=0 then
  293.         teams[players[name].team].listPl[name] = 0
  294.         if checkTeamActivity(players[name].team) then
  295.             if lobby then
  296.                 reloadTeams(true)
  297.             else
  298.                 local count = 0
  299.                 for key, data in pairs(teams) do
  300.                     if not data.hide then
  301.                         count = count +1
  302.                     end
  303.                 end
  304.                 if count<=1 then
  305.  
  306.                 end
  307.             end
  308.         end
  309.     end
  310. end
  311.  
  312. function eventPlayerDied(name)
  313.     if lobby then tfm.exec.respawnPlayer(name)
  314.     elseif win and players[name].team~=0 then
  315.         if countPl().alive<=1 then
  316.             tfm.exec.setGameTime(5)
  317.         end
  318.         local team = leftTeam()
  319.         if team~=0 and teams[team] then
  320.             win = false
  321.             uwin = true
  322.             tfm.exec.setGameTime(5)
  323.         end
  324.     end
  325. end
  326.  
  327. function eventKeyboard(name, key, down, x, y)
  328.     local data = tfm.get.room.playerList[name]
  329.     local pl = players[name]
  330.     if key==0 then
  331.         data.isFacingRight = false
  332.         pl.isFacingRight = false
  333.     end
  334.     if key==2 then
  335.         data.isFacingRight = true
  336.         pl.isFacingRight = true
  337.     end
  338.     if (key==3 or key==32) and pl.timestamp<=os.time() and (not data.isDead) and start then
  339.         local id = tfm.exec.addShamanObject(17, x+(pl.isFacingRight and pl.offset.x or -pl.offset.x), y+pl.offset.y, pl.isFacingRight and 90 or 270)
  340.         table.insert(todespawn, {time = os.time()+1000, id = id})
  341.         pl.timestamp = os.time() +1500
  342.     end
  343.     if key==76 and #teams>0 then
  344.         if not players[name].down then
  345.             players[name].down = true
  346.             local txt = "<p align='center'><font size='30'><u>Scoreboard</u></font></p>\n"
  347.             for k,data in pairs(teams) do
  348.                 local points, size = 0, (#data.name<=35 and 20 or 12)
  349.                 table.foreach(data.listPl, function(k,v) points = points +players[k].points end)
  350.                 data.points = points
  351.                 txt = format(translate("scoreboard", name), txt, size, data.name, points, data.victory)
  352.                 table.sort(data.listPl, function(a,b) return players[data.listPl[a]].points>players[data.listPl[b]].points end)
  353.                 local key = 1
  354.                 for pl, ishere in pairs(data.listPl) do
  355.                     local pt, su = tostring(players[pl].points), tostring(players[pl].survies)
  356.                     txt = format("%s   <n>%0d. <v>%s<n><j>%s</j></n></v></n>\n", txt, key, pl..(" "):rep(21 -#pl), pt..(" "):rep(13 -#pt)..su)
  357.                     key = key +1
  358.                 end
  359.                 -- local pl, pt = "Dieutoutpuissant", "∞"
  360.                 -- txt = format("%s   <n>%0d. <v>%s<n><j>%s</j></n></v></n>\n", txt, 2, pl..(" "):rep(21 -#pl), pt..(" "):rep(13 -#pt).."0")
  361.                 txt = txt.."</font>\n\n"
  362.             end
  363.             ui.addBox(id_scoreboard, txt, name, 50, 27, 700, 350)
  364.             ui.addTextArea(id_scoreboard*100+6, "<b>"..string.char(77, 111, 100, 117, 108, 101, 32, 99, 114, 101, 97, 116, 101, 100, 32, 98, 121, 32, 65, 116, 104, 101, 115, 100, 114, 97, 107, 101), name, 57, 357, nil, nil, 0x0, 0x0, 0, true)
  365.             ui.addTextArea(id_scoreboard*100+7, "<p align='right'><b>V"..version, name, 50, 357, 697, nil, 0x0, 0x0, 0, true)
  366.         else
  367.             --77, 111, 100, 117, 108, 101, 32, 99, 114, 101, 97, 116, 101, 100, 32, 98, 121, 32, 65, 116, 104, 101, 115, 100, 114, 97, 107, 101
  368.             ui.removeBox(id_scoreboard, name)
  369.             players[name].down = false
  370.         end
  371.     end
  372. end
  373.  
  374. function eventChatCommand(name, cmd)
  375.     players[name].afk_time = os.time()
  376.     local arg = {}
  377.     for w in cmd:gmatch("%S+") do
  378.         table.insert(arg, w)
  379.     end
  380.     if arg[1]=="lang" or arg[1]=="language" then
  381.         if (not arg[2]) or arg[2]=="" then
  382.             ui.addTextArea(idLang, "<cep>The languages available are: <j>Français</j> (<v>fr</v>), <j>English</j> (<v>en</v>) and <j>Türkçe</j> (<v>tr</v>).", name, 400, 380, 395, 25, nil, nil, 1, true)
  383.         elseif T[arg[2]:lower()] then
  384.             players[name].lang = arg[2]:lower()
  385.             ui.addTextArea(idLang, format("<cep>Language set to <v>%s</v>", arg[2]:upper()), name, 670, 380, 125, 25, nil, nil, 1, true)
  386.         else
  387.             ui.addTextArea(idLang, format("<cep>The <v>%s</v> translation isn't made yet. Contact Athesdrake or Sourixl if you want to help to translate !", arg[2]), name, 400, 360, 395, 45, nil, nil, 1, true)
  388.         end
  389.         after(5, function() ui.removeTextArea(idLang, name) end)
  390.     end
  391.     if arg[1]:sub(0,7)=="command" or arg[1]=="cmd" then help(name, 1) end
  392.     if (arg[1]=="off" or arg[1]=="offset") and arg[2] and arg[2]~="" and arg[3] and arg[3]~="" then
  393.         local x, y = tonumber(arg[2]:match("%-?%d+")), tonumber(arg[3]:match("%-?%d+"))
  394.         if (not (x and y)) then
  395.             ui.addTextArea(idOffChange, "<r><b>Invalid Offset", name, 700, 380, 95, 25, nil, nil, 1, true)
  396.         else
  397.             players[name].offset.x = x<-25 and -25 or (x>25 and 25 or x)
  398.             players[name].offset.y = y<-25 and -25 or (y>25 and 25 or y)
  399.             ui.addTextArea(idOffChange, format(translate("offset", name), players[name].offset.x, players[name].offset.y), name, 500, 380, 295, 25, nil, nil, 1, true)
  400.         end
  401.         after(2, function() ui.removeTextArea(idOffChange, name) end)
  402.     elseif arg[1]=="help" then
  403.         if arg[2] and arg[2]=="cmd" then
  404.             help(name, 1)
  405.         else
  406.             help(name, 0)
  407.         end
  408.     elseif players[name].chef then
  409.         if (not start) then
  410.             if not teams[players[name].team].done then
  411.                 if arg[1]=="name" and arg[2] and arg[2]~="" then
  412.                     local txt = ""
  413.                     for i=2, #arg do
  414.                         txt = txt..arg[i].." "
  415.                     end
  416.                     txt = txt:sub(0, #txt-1)
  417.                     teams[players[name].team].name = txt:sub(0,58)
  418.                     reloadTeams()
  419.                 end
  420.                 if arg[1]=="color" then
  421.                     ui.showColorPicker(1, name, 0x1, translate("team", name).color)
  422.                 end
  423.                 if arg[1]=="ban" and arg[2] and arg[2]~="" and capitalize(arg[2])~=name then
  424.                     teams[players[name].team].ban[arg[2]:lower()] = 1
  425.                     for pl,ishere in pairs(teams[players[name].team].listPl) do
  426.                         if pl:lower()==arg[2]:lower() then
  427.                             teams[players[name].team].listPl[pl] = nil
  428.                             tfm.exec.killPlayer(capitalize(arg[2]))
  429.                             players[capitalize(arg[2])].team = 0
  430.                             reloadTeams()
  431.                             break
  432.                         end
  433.                     end
  434.                 end
  435.                 if arg[1]=="unban" and arg[2] and arg[2]~="" then
  436.                     teams[players[name].team].ban[arg[2]:lower()] = nil
  437.                 end
  438.             elseif arg[1]=="name" or arg[1]=="color" or arg[1]=="ban" or arg[1]=="unban" then
  439.                 ui.addTextArea(idInfo, format("<j>You can't do the <v>%s</v> command unless you're not '<vp>done</vp>'.", arg[1]), name, 400, 380, 395, 25, nil, nil, 1, true)
  440.                 after(5, function() ui.removeTextArea(idInfo, name) end)
  441.             end
  442.             if arg[1]=="done" then
  443.                 teams[players[name].team].done = (not teams[players[name].team].done)
  444.                 reloadTeams()
  445.                 if #teams>1 then
  446.                     local t = 0
  447.                     for k,v in pairs(teams) do if v.done then t = t +1 end end
  448.                     if t==#teams then for i=idTeam, idTeam+100 do ui.removeTextArea(i) end; tfm.exec.newGame(maps[math.random(#maps)]); pause.p = false end
  449.                 end
  450.             end
  451.         else
  452.             if arg[1]=="pause" and (not pause.p) and not vote.current then
  453.                 pause = {p = true, vote={nbr=0, oui=0}, t1=os.time() +120000}
  454.                 vote = {current=true, type="pause", nbr=1, oui=1}
  455.                 for c in roomPl() do
  456.                     if players[c].chef and c~=name then
  457.                         pause.vote.nbr = pause.vote.nbr +1
  458.                         ui.addTextArea(idPause, format(translate("commands", c).pause.ask..translate("accept", c), name, "pause", "pause"), c, 5, 375, 400, 25, nil, nil, 1, true)
  459.                     end
  460.                 end
  461.             elseif arg[1]=="nc" and arg[2] and not vote.current then
  462.                 vote = {current=true, type="nc", nbr=1, oui=1}
  463.                 if arg[2]=="last" and lastRecord then
  464.                     vote.type = vote.type.."l"
  465.                     for c in roomPl() do
  466.                         if players[c].chef and c~=name then
  467.                             vote.nbr = vote.nbr +1
  468.                             ui.addTextArea(idPause, format(translate("commands", c).nc_last.ask..translate("accept", c), name, "ncl", "ncl"), c, 5, 375, 400, 25, nil, nil, 1, true)
  469.                         end
  470.                     end
  471.                 elseif arg[2]=="next" then
  472.                     vote.type = vote.type.."n"
  473.                     for c in roomPl() do
  474.                         if players[c].chef and c~=name then
  475.                             vote.nbr = vote.nbr +1
  476.                             ui.addTextArea(idPause, format(translate("commands", c).nc_next.ask..translate("accept", c), name, "ncn", "ncn"), c, 5, 375, 400, 25, nil, nil, 1, true)
  477.                         end
  478.                     end
  479.                 end
  480.             elseif arg[1]=="skip" and not vote.current then
  481.                 vote = {current=true, type="skip", nbr=1, oui=1}
  482.                 for c in roomPl() do
  483.                     if players[c].chef and c~=name then
  484.                         vote.nbr = vote.nbr +1
  485.                         ui.addTextArea(idPause, format(translate("commands", c).skip.ask..translate("accept", c), name, "skip", "skip"), c, 5, 375, 400, 25, nil, nil, 1, true)
  486.                     end
  487.                 end
  488.             elseif arg[1]=="untilwin" and not vote.current then
  489.                 vote = {current=true, type="untilwin", nbr=1, oui=1}
  490.                 for c in roomPl() do
  491.                     if players[c].chef and c~=name then
  492.                         vote.nbr = vote.nbr +1
  493.                         ui.addTextArea(idPause, format(translate("commands", c).untilwin.ask..translate("accept", c), name, "untilwin", "untilwin"), c, 5, 375, 470, 25, nil, nil, 1, true)
  494.                     end
  495.                 end
  496.             end
  497.         end
  498.     end
  499.     if name=="Athesdrake#0000" and cmd=="debug" then
  500.         ui.addPopup(666, 2,"DEBUG", name)
  501.     end
  502. end
  503.  
  504. function eventPopupAnswer(id, name, ans)
  505.     print(format("PopupAnswer>> %s with popupId %d answers \"%s\"", name, id, ans))
  506.     if id==666 then
  507.         arg = string.split(ans)
  508.         if arg[1]=="call" then -- call a function with all the given args (eg: 'awesome_function$test$n$N35' → awesome_function('test', name, 35))
  509.             local sub = {}
  510.             for i=3, #arg do
  511.                 if arg[i]=="n" then
  512.                     table.insert(sub, name)
  513.                 elseif arg[i]:sub(0,1)=="N" then
  514.                     table.insert(sub, tonumber(arg[i]:sub(2)))
  515.                 else
  516.                     table.insert(sub, arg[i])
  517.                 end
  518.             end
  519.             _G[arg[2]](table.unpack(sub))
  520.         end
  521.     end
  522. end
  523.  
  524. function eventColorPicked(id, name, color)
  525.     if id==1 then
  526.         teams[players[name].team].color = color
  527.         reloadTeams()
  528.     end
  529. end
  530.  
  531. function eventTextAreaCallback(id, name, callback)
  532.     local arg = {}
  533.     for a in callback:gmatch("[^$]+") do
  534.         table.insert(arg, a)
  535.     end
  536.     if arg[1]=="pause" then
  537.         ui.removeTextArea(idPause, name)
  538.         if arg[2]=="non" then
  539.             ui.removeTextArea(idPause)
  540.             pause.p = false
  541.             vote = {current=false}
  542.             --ui.addTextArea("%s") PK j'ai fais ça ? je sais plus.
  543.         else
  544.             pause.vote.oui = pause.vote.oui +1
  545.             if pause.vote.oui==pause.vote.nbr then
  546.                 nextMap = "pause"
  547.                 for pl in roomPl() do
  548.                     ui.addTextArea(idPause, translate("commands", pl).pause.set, pl, 5, 375, 400, 25, nil, nil, 1, true)
  549.                 end
  550.                 after(3, function() vote = {current=false}; ui.removeTextArea(idPause) end)
  551.             end
  552.         end
  553.     end
  554.     if arg[1]=="ncl" then
  555.         ui.removeTextArea(idPause, name)
  556.         if arg[2]=="non" then
  557.             ui.removeTextArea(idPause)
  558.             vote = {current=false}
  559.         else
  560.             vote.oui = vote.oui +1
  561.             if vote.oui==vote.nbr then
  562.                 teams[record[#record].team].victory = teams[record[#record].team].victory -1
  563.                 for _,pl in pairs(record[#record].pl) do
  564.                     players[pl].survies = players[pl].survies -1
  565.                     players[pl].points = players[pl].points - (record[#record].team>1 and 1 or record[#record].team)
  566.                 end
  567.                 table.remove(record, #record)
  568.                 lastRecord = false
  569.                 for pl in roomPl() do
  570.                     ui.addTextArea(idPause, translate("commands", pl).nc_last.set, pl, 5, 375, 400, 25, nil, nil, 1, true)
  571.                 end
  572.                 after(3, function() vote = {current=false}; ui.removeTextArea(idPause) end)
  573.             end
  574.         end
  575.     end
  576.     if arg[1]=="ncn" then
  577.         ui.removeTextArea(idPause, name)
  578.         if arg[2]=="non" then
  579.             ui.removeTextArea(idPause)
  580.             vote = {current=false}
  581.         else
  582.             vote.oui = vote.oui +1
  583.             if vote.oui==vote.nbr then
  584.                 nextRecord = false
  585.                 for pl in roomPl() do
  586.                     ui.addTextArea(idPause, translate("commands", pl).nc_next.set, pl, 5, 375, 400, 25, nil, nil, 1, true)
  587.                 end
  588.                 after(3, function() vote = {current=false}; ui.removeTextArea(idPause) end)
  589.             end
  590.         end
  591.     end
  592.     if arg[1]=="skip" then
  593.         ui.removeTextArea(idPause, name)
  594.         if arg[2]=="non" then
  595.             ui.removeTextArea(idPause)
  596.             vote = {current=false}
  597.         else
  598.             vote.oui = vote.oui +1
  599.             if vote.oui==vote.nbr then
  600.                 nextMap = "normal"
  601.                 for pl in roomPl() do
  602.                     ui.addTextArea(idPause, translate("commands", pl).skip.set, pl, 5, 375, 400, 25, nil, nil, 1, true)
  603.                 end
  604.                 after(3, function() vote = {current=false}; ui.removeTextArea(idPause); newMap() end)
  605.             end
  606.         end
  607.     end
  608.     if arg[1]=="untilwin" then
  609.         ui.removeTextArea(idPause, name)
  610.         if arg[2]=="non" then
  611.             ui.removeTextArea(idPause)
  612.             vote = {current=false}
  613.         else
  614.             vote.oui = vote.oui +1
  615.             if vote.oui==vote.nbr then
  616.                 vote = {current=false}
  617.                 uwin = false
  618.                 if leftTeam()~=0 then
  619.                     uwin = true
  620.                 end
  621.                 for pl in roomPl() do
  622.                     ui.addTextArea(idPause, translate("commands", pl).untilwin.set, pl, 5, 375, 400, 25, nil, nil, 1, true)
  623.                 end
  624.                 after(3, function() vote = {current=false}; ui.removeTextArea(idPause) end)
  625.             end
  626.         end
  627.     end
  628.     if arg[1]=="team" and (not players[name].chef) then
  629.         if players[name].team~=0 then
  630.             teams[players[name].team].listPl[name] = nil
  631.         end
  632.         local sep = tonumber(arg[2])+1
  633.         if sep==6 then
  634.             sep = 5
  635.         end
  636.         players[name].team = #teams+1
  637.         players[name].chef = true
  638.         players[name].afk_time = os.time()
  639.         teams[#teams+1] = {name="Unknown", chef=name, spawn=200, color=0x0, listPl={[name]=1}, ban={}, id=#teams+1, points=0, victory=0}
  640.         if #teams>0 then
  641.             reloadTeams(true)
  642.         end
  643.     end
  644.     if arg[1]=="join" then
  645.         if players[name].chef then
  646.  
  647.         elseif getn(teams[tonumber(arg[2])].listPl)<=10 and (not teams[tonumber(arg[2])].ban[name:lower()]) and players[name].team~=tonumber(arg[2]) then
  648.             tfm.exec.movePlayer(name, teams[tonumber(arg[2])].spawn, 350)
  649.             tfm.exec.setNameColor(name, teams[tonumber(arg[2])].color)
  650.             if players[name].team~=0 and ams[players[name].team] and teams[players[name].team].listPl then
  651.                 teams[players[name].team].listPl[pl] = nil
  652.             end
  653.             players[name].team = tonumber(arg[2])
  654.             teams[tonumber(arg[2])].listPl[name] = 1
  655.             reloadTeams()
  656.         end
  657.     end
  658.     if arg[1]=="quit" then
  659.         if players[name].chef then
  660.             players[name].chef = false
  661.             for pl, ishere in pairs(teams[players[name].team].listPl) do
  662.                 players[pl].team = 0
  663.                 tfm.exec.killPlayer(pl)
  664.             end
  665.             for i=idTeam+teams[#teams].id*10+1, idTeam+teams[#teams].id*10+5 do
  666.                 tfm.exec.removePhysicObject(i)
  667.                 ui.removeTextArea(i)
  668.             end
  669.             table.remove(teams, tonumber(arg[2]))
  670.             --table.sort(teams)
  671.             reloadTeams(true)
  672.         elseif players[name].team~=0 then
  673.             teams[players[name].team].listPl[name] = nil
  674.             tfm.exec.killPlayer(name)
  675.             players[name].team = 0
  676.             reloadTeams()
  677.         end
  678.     end
  679.     if arg[1]=="close" then
  680.         ui["remove"..arg[2]](tonumber(arg[3]), name)
  681.     end
  682.     if arg[1]=="call" then
  683.         table.foreach(arg, function(k,v) if v=="n" then arg[k]=name elseif v:sub(0,1)=="N" then arg[k] = tonumber(v:sub(2)) end end)
  684.         _G[arg[2]](arg[3], arg[4])
  685.     end
  686. end
  687.  
  688. function eventLoop(t1, t2)
  689.     for k,v in ipairs(todespawn) do
  690.         if v.time<=os.time() then
  691.             tfm.exec.removeObject(v.id)
  692.             table.remove(todespawn, k)
  693.         end
  694.     end
  695.     for key,data in ipairs(aft) do
  696.         if data.t<=os.time() then
  697.             data.f()
  698.             table.remove(aft, key)
  699.         end
  700.     end
  701.     if timer and timer<=os.time() then start=true; ui.removeTextArea(idTimer); for i=1,4 do ui.removeTextArea(idTimer*100+i) end
  702.     elseif timer then
  703.         local epaisseur = 2
  704.         local t = {{x=epaisseur,y=0},{x=-epaisseur,y=0},{x=0,y=epaisseur},{x=0,y=-epaisseur}}
  705.         for i=1,4 do
  706.             ui.addTextArea(idTimer*100+i, "<p align='center'><font size='75' color='#000000' face='Agency FB'><b>"..tostring(math.ceil((timer-os.time())/1000)), nil, 0, 300+t[i].x, 800+t[i].y, nil, 0x0, 0x0, 0, true)
  707.         end
  708.         ui.addTextArea(idTimer, "<p align='center'><font size='75' color='#6A7595' face='Agency FB'><b>"..tostring(math.ceil((timer-os.time())/1000)), nil, 0, 300, 800, nil, 0x0, 0x0, 0, true)
  709.     end
  710.     if t2<0 and uwin and currentMap~="@0" and (not lobby) then
  711.         local team, pl = leftTeam(), {}
  712.         for k,v in roomPl() do
  713.             if not v.isDead then
  714.                 if teams[team] then
  715.                     tfm.exec.giveCheese(k)
  716.                     tfm.exec.playerVictory(k)
  717.                 end
  718.                 if nextRecord then
  719.                     if teams[team] then players[k].points = players[k].points +1 end
  720.                     players[k].survies = players[k].survies +1
  721.                 end
  722.                 table.insert(pl, k)
  723.             end
  724.         end
  725.         if nextRecord then
  726.             if teams[team] then
  727.                 teams[team].victory = teams[team].victory +1
  728.                 if teams[team].victory>=limite then
  729.                     nextMap = "end"
  730.                 end
  731.             end
  732.             table.insert(record, {team=team, pl=pl})
  733.         end
  734.         nextRecord = true
  735.         lastRecord = true
  736.         if teams[team] and teams[team].victory>=limite then
  737.             nextMap = "end"
  738.         end
  739.         newMap()
  740.     end
  741.     if pause.p then
  742.         if pause.t2 then
  743.             if pause.t2<=os.time() then
  744.                 pause.p = false
  745.                 joinQuit = true
  746.                 for i=idTeam, idTeam+100 do ui.removeTextArea(i) end
  747.                 newMap()
  748.             end
  749.         elseif pause.t1<=os.time() then
  750.             ui.removeTextArea(idPause)
  751.             nextMap = "pause"
  752.         end
  753.     end
  754.     if fireworks then
  755.         local tbl = {1,4,9}
  756.         for i=1, (math.random(1,5)==1 and 2 or 1) do
  757.             firework(tbl[math.random(#tbl)], math.random(100, 700), math.random(100, 400))
  758.         end
  759.     end
  760.     if setup then
  761.         for pl, data in pairs(players) do
  762.             if data.chef and data.afk_time<=os.time()-30000 and not teams[data.team].done then
  763.                 eventTextAreaCallback(1, pl, format("quit$%d", data.team))
  764.             end
  765.         end
  766.     end
  767. end
  768.  
  769. function eventNewGame()
  770.     lobby = false
  771.     tfm.exec.disableAfkDeath(tfm.get.room.currentMap=="@0")
  772.     if tfm.get.room.currentMap=="@0" then
  773.         timer = false
  774.         lobby = true
  775.         ui.setMapName("<j>Sourixl<g> - @7103699 | <j>V"..version.." <n2>created by Athesdrake\n")
  776.         ui.addTextArea(idTitle, "<p align='center'><font color='#CC2126' size='75' face='Bauhaus 93'>DeathWar", nil, 0, 30, 800, 150, 0x0)
  777.         -- font: Wide Latin, Algerian, Bauhaus 93, Castellar, Goudy Stout
  778.         -- font: ui.addTextArea(1, "<font size='50' face='Wide Latin'>DeathWar</font>\n<font size='50' face='Algerian'>DeathWar</font>\n<font size='50' face='Bauhaus 93'>DeathWar</font>\n<font size='50' face='Castellar'>DeathWar</font>\n<font size='50' face='Goudy Stout'>DeathWar</font>\n<font size='50>DeathWar</font>")
  779.     else
  780.         ui.removeTextArea(idTitle)
  781.         timer = os.time() +6000
  782.         for k,v in roomPl() do
  783.             if players[k].team==0 then
  784.                 tfm.exec.killPlayer(k)
  785.             else
  786.                 tfm.exec.setNameColor(k, teams[players[k].team].color)
  787.             end
  788.         end
  789.     end
  790.     start = false
  791.     win = true
  792.     currentMap = tfm.get.room.currentMap
  793. end
  794.  
  795. function setUp()
  796.     tfm.exec.newGame(lobby_map)
  797.     ui.addTextArea(idTeam, "<p align='center'><font size='30'>\n\n\n<b><a href='event:$team$1'>+", nil, 5, 155, 790, 237, nil, nil, 0.5)
  798. end
  799.  
  800. function reloadTeams(tp)
  801.     local sep = setup and (#teams+1==6 and 5 or #teams+1) or #teams
  802.     table.foreach(teams, function(k,v) if v.hide then sep = sep -1 end end)
  803.     table.sort(teams,
  804.         function(a, b)
  805.             if a.hide and not b.hide then
  806.                 return false
  807.             end
  808.             return true
  809.         end
  810.     )
  811.     for k,v in pairs(teams) do
  812.         v.id = k
  813.         if v.hide then
  814.             for i=idTeam+k*10+1,idTeam+k*10+4 do
  815.                 tfm.exec.removePhysicObject(i)
  816.                 ui.removeTextArea(i)
  817.             end
  818.         else
  819.             v.spawn = (400*(2*(k-1)+1)/sep)
  820.             tfm.exec.addPhysicObject(idTeam+k*10+1, (k-1)*(800/sep)+5, 275, {type=12, width=10, height=250, color=v.color})
  821.             tfm.exec.addPhysicObject(idTeam+k*10+2, k*(800/sep)-5, 275, {type=12, width=10, height=250, color=v.color})
  822.             tfm.exec.addPhysicObject(idTeam+k*10+3, v.spawn, 175, {type=12, width=800/sep, height=50, color=v.color})
  823.             tfm.exec.addPhysicObject(idTeam+k*10+4, v.spawn, 395, {type=12, width=800/sep, height=10, color=v.color, friction=0.3})
  824.             ui.addTextArea(idTeam+k*10+1, format("<p align='center'><font size='%d'>%s",#v.name>15 and 15 or 25, v.name), nil, (k-1)*(800/sep)+5, 150, 800/sep-10, nil, 0x0, 0x0, 0)
  825.             if joinQuit then
  826.                 if v.done then
  827.                     for pl in roomPl() do
  828.                         ui.addTextArea(idTeam+k*10+2, "<p align='center'><font size='25' color='#00FF00'>"..translate("team", pl).done, pl, (k-1)*(800/sep)+5, 350, 800/sep-10, nil, 0x0, 0x0, 0)
  829.                     end
  830.                 else
  831.                     for pl in roomPl() do
  832.                         if players[pl].team==k then
  833.                             ui.addTextArea(idTeam+k*10+2, format("<p align='center'><font size='25'><a href='event:quit$%d'><r>"..translate("team", pl).quit, k), pl, (k-1)*(800/sep)+5, 350, 800/sep-10, nil, 0x0, 0x0, 0)
  834.                         else
  835.                             ui.addTextArea(idTeam+k*10+2, format("<p align='center'><font size='25'><a href='event:join$%d'>"..translate("team", pl).join, k), pl, (k-1)*(800/sep)+5, 350, 800/sep-10, nil, 0x0, 0x0, 0)
  836.                         end
  837.                     end
  838.                 end
  839.             end
  840.         end
  841.         for pl,ishere in pairs(v.listPl) do
  842.             if tp then
  843.                 tfm.exec.movePlayer(pl, v.spawn, 350)
  844.             end
  845.             tfm.exec.setNameColor(pl, v.color)
  846.             players[pl].team = k
  847.         end
  848.     end
  849.     if #teams~=5 and joinQuit then
  850.         ui.addTextArea(idTeam, "<p align='center'><font size='30'>\n\n\n<b><a href='event:$team$"..sep.."'>+", nil, 800-800/sep, 155, 800/sep, 237, nil, nil, 0.5)
  851.     else
  852.         ui.removeTextArea(idTeam)
  853.     end
  854. end
  855.  
  856. function newMap()
  857.     joinQuit, fireworks, setup = false, false, false
  858.     if nextMap=="normal" then
  859.         local temp_map = ""
  860.         repeat
  861.             temp_map = maps[math.random(#maps)]
  862.         until temp_map~=currentMap
  863.         currentMap = temp_map
  864.         tfm.exec.newGame(temp_map)
  865.     elseif nextMap=="pause" then
  866.         tfm.exec.newGame(lobby_map)
  867.         nextMap = "normal"
  868.         pause.t2 = os.time() +300000
  869.         pause.t1 = false
  870.         for k,v in pairs(teams) do v.done = false end
  871.         after(1, function() reloadTeams(true) end)
  872.     elseif nextMap=="end" then
  873.         tfm.exec.newGame(lobby_map)
  874.         nextMap = "normal"
  875.         after(1, function() reloadTeams(true);win_() end)
  876.     end
  877. end
  878.  
  879. function roomPl() return next, tfm.get.room.playerList, nil end
  880.  
  881. function countPl()
  882.     local all, alive, dead = 0, 0, 0
  883.     for k,v in roomPl() do
  884.         all = all +1
  885.         if v.isDead then
  886.             dead = dead +1
  887.         else
  888.             alive = alive +1
  889.         end
  890.     end
  891.     return {
  892.         all = all,
  893.         alive = alive,
  894.         dead = dead
  895.     }
  896. end
  897.  
  898. function capitalize(str) return str:sub(0,1):upper()..str:sub(2):lower() end
  899.  
  900. function wHtml(str)
  901.     if type(str)=="string" then
  902.         return str:gsub("<[^>]+",""):gsub(">","") -- Supprime toutes la balises HTML
  903.     end
  904. end
  905.  
  906. function leftTeam()
  907.     local team = 0
  908.     for k,v in roomPl() do
  909.         if not v.isDead then
  910.             if team==0 then team = players[k].team end
  911.             if team~=players[k].team then return 0 end
  912.         end
  913.     end
  914.     return team
  915. end
  916.  
  917. function help(name, page)
  918.     if page==0 then
  919.         ui.addTextPopup(idHelp, format(translate("help_txt", name), version), name, 225, 58, 350, 280)
  920.     elseif page==1 then
  921.         local HELP = translate("HELP", name)
  922.         local H = HELP.title
  923.         local f = H.txt
  924.         if H.bcolor then f = format("<%s>%s</%s>", H.bcolor, f, H.bcolor) end
  925.         if H.b then f = format("<b>%s</b>", f) end;if H.u then f = format("<u>%s</u>", f) end;if H.i then f = format("<i>%s</i>", f) end
  926.         local txt = format("<p align='%s'><font color='#%s' size='%d'>%s</font></p>\n\n", H.align and H.align or L, H.color and tostring(H.color) or "c2c2da", H.size and H.size or 12, f)
  927.  
  928.        
  929.         H = HELP.p[page]
  930.         f = H.txt
  931.         if H.bcolor then f = format("<%s>%s</%s>", H.bcolor, f, H.bcolor) end
  932.         if H.b then f = format("<b>%s</b>", f) end;if H.u then f = format("<u>%s</u>", f) end;if H.i then f = format("<i>%s</i>", f) end
  933.         txt = format("%s<p align='%s'><font color='#%s' size='%d'>%s</font></p>", txt, H.align and H.align or L, H.color and tostring(H.color) or "c2c2da", H.size and H.size or 12, f)
  934.         for key in pairs(HELP.p[page].content) do
  935.             H = HELP.p[page].content[key]
  936.             local args = ""
  937.             if H.arg then
  938.                 for kk, arg in pairs(H.arg) do
  939.                     if type(kk)=="number" then
  940.                         local space = string.rep(" ", H.space or 1)
  941.                         if H.arg.f then f = format("<%s>%s</%s>", H.arg.f[kk], arg, H.arg.f[kk]) else f = arg end
  942.                         args = format("%s%s[%s]", args, space, f)
  943.                     end
  944.                 end
  945.             end
  946.             txt = format("%s<font face='Lucida Console'>!%s%s%s</font>%s\n", txt, H.cmd, args, (" "):rep(24-string.len(wHtml(H.cmd..args))), H.description)
  947.         end
  948.  
  949.         ui.addTextPopup(idHelp, txt, name, 100, 35, 600, 335)
  950.         local x, y, width = 625, 352, 60
  951.         ui.addTextArea(idHelp*100+7, " ", name, x-1, y-1, width-1, 11, 0x5D7D90, 0x5D7D90, 1, true)
  952.         ui.addTextArea(idHelp*100+8, " ", name, x+1, y+1, width  , 12, 0x11171C, 0x11171C, 1, true)
  953.         ui.addTextArea(idHelp*100+9, " ", name, x  , y  , width  , 12, 0x3C5064, 0x3C5064, 1, true)
  954.         ui.addTextArea(idHelp*100+10, "<p align='center'><a href='event:call$help$n$N2'>&gt;", name, x  , y-3, width  , 20, 0x0, 0x0, 0, true)
  955.     elseif page==2 then
  956.         local HELP = translate("HELP", name)
  957.         local H = HELP.title
  958.         local f = H.txt
  959.         if H.bcolor then f = format("<%s>%s</%s>", H.bcolor, f, H.bcolor) end
  960.         if H.b then f = format("<b>%s</b>", f) end;if H.u then f = format("<u>%s</u>", f) end;if H.i then f = format("<i>%s</i>", f) end
  961.         local txt = format("<p align='%s'><font color='#%s' size='%d'>%s</font></p>\n\n", H.align and H.align or L, H.color and tostring(H.color) or "c2c2da", H.size and H.size or 12, f)
  962.  
  963.         H = HELP.p[page]
  964.         f = H.txt
  965.         if H.bcolor then f = format("<%s>%s</%s>", H.bcolor, f, H.bcolor) end
  966.         if H.b then f = format("<b>%s</b>", f) end;if H.u then f = format("<u>%s</u>", f) end;if H.i then f = format("<i>%s</i>", f) end
  967.         txt = format("%s<p align='%s'><font color='#%s' size='%d'>%s</font></p>", txt, H.align and H.align or L, H.color and tostring(H.color) or "c2c2da", H.size and H.size or 12, f)
  968.         for key in pairs(HELP.p[page].content) do
  969.             H = HELP.p[page].content[key]
  970.             local args = ""
  971.             if H.arg then
  972.                 for kk, arg in pairs(H.arg) do
  973.                     if type(kk)=="number" then
  974.                         local space = string.rep(" ", H.space or 1)
  975.                         if H.arg.f then f = format("<%s>%s</%s>", H.arg.f[kk], arg, H.arg.f[kk]) else f = arg end
  976.                         args = format("%s%s[%s]", args, space, f)
  977.                     end
  978.                 end
  979.             end
  980.             txt = format("%s<font face='Lucida Console'>!%s%s%s</font>%s\n", txt, H.cmd, args, (" "):rep(24-string.len(wHtml(H.cmd..args))), H.description)
  981.         end
  982.  
  983.         ui.addTextPopup(idHelp, txt, name, 100, 35, 600, 335)
  984.         local x, y, width = 115, 352, 60
  985.         ui.addTextArea(idHelp*100+7, " ", name, x-1, y-1, width-1, 11, 0x5D7D90, 0x5D7D90, 1, true)
  986.         ui.addTextArea(idHelp*100+8, " ", name, x+1, y+1, width  , 12, 0x11171C, 0x11171C, 1, true)
  987.         ui.addTextArea(idHelp*100+9, " ", name, x  , y  , width  , 12, 0x3C5064, 0x3C5064, 1, true)
  988.         ui.addTextArea(idHelp*100+10, "<p align='center'><a href='event:call$help$n$N1'>&lt;", name, x  , y-3, width  , 20, 0x0, 0x0, 0, true)
  989.     elseif page==3 then
  990.         -- Old Help
  991.         ui.addTextPopup(idHelp, format("Module imaginé par <bv>Sourixl</bv>, créé par <n2>Athesdrake</n2>.\n\nSignalez-moi les bugs que vous rencontrez par messages sur le forum! Décrivez le bug avec autant de détails que possible, avec un screen si possible.\n\n\n\n<vi>Version</vi> <rose>%s</rose>", version), name, 225, 75, 350, 180)
  992.     end
  993. end
  994.  
  995. function win_()
  996.     local winners, sep = "", #teams
  997.     for k,v in pairs(teams) do
  998.         if v.victory>=limite then
  999.             winners = v
  1000.         end
  1001.     end
  1002.     if winners and winners.id and sep then
  1003.         local name = winners.name
  1004.         ui.addTextArea(idWinner, "<p align='center'><font face='Webdings' size='75' color='#ffff00'>%", nil, (winners.id-1)*(800/sep)+5, 250, 800/sep-10, nil, 0x0, 0x0, 0)
  1005.         for pl in roomPl() do
  1006.             ui.addTextArea(idWinner*100, format("<p align='center'><font face='Lucida Console' size='30'>"..translate('team', pl).win, #name>19 and name:sub(0,16).."..." or name), nil, 0, 105, 800, nil, 0x0, 0x0, 0, true)
  1007.         end
  1008.         fireworks = true
  1009.         after(2, function() after(30, restart) end)
  1010.     else
  1011.         error(format("<r>ERROR 404. NOT FOUND. Please report to Athesdrake on the forum these informations: -%s -%s -%s", tostring(winners), tostring(winners.id), tostring(sep)))
  1012.     end
  1013. end
  1014.  
  1015. function checkTeamActivity(team)
  1016.     for pl, ishere in pairs(teams[team].listPl) do
  1017.         if ishere==1 then
  1018.             teams[team].hide = false
  1019.             return false
  1020.         end
  1021.     end
  1022.     teams[team].hide = true
  1023.     return true
  1024. end
  1025.  
  1026. function restart()
  1027.     for key, data in pairs(teams) do
  1028.         data.points = 0
  1029.         data.victory = 0
  1030.         data.done = false
  1031.     end
  1032.     start = false
  1033.     setup = true
  1034.     lobby = true
  1035.     joinQuit = true
  1036.     uwin = true
  1037.     fireworks = false
  1038.     reloadTeams(true)
  1039.     ui.removeTextArea(idWinner)
  1040.     ui.removeTextArea(idWinner*100)
  1041. end
  1042.  
  1043. function math.rand_negative(...)
  1044.     local x = 0
  1045.     repeat
  1046.         x = math.random(-1, 1)
  1047.     until x~=0
  1048.     return x*math.random(table.unpack({...}))
  1049. end
  1050.  
  1051. function getn(tbl)
  1052.     local lenght = 0
  1053.     for k,v in next, tbl do
  1054.         lenght = lenght +1
  1055.     end
  1056.     return lenght
  1057. end
  1058.  
  1059. function torad(deg)
  1060.     return deg*math.pi/180
  1061. end
  1062.  
  1063. function firework(id, x, y, name)
  1064.     for i=0, 10 do
  1065.         local angle = math.rand_negative(0, 180)
  1066.         local xs, ys, xa, ya = 2*math.cos(torad(angle)), 2*math.sin(torad(angle)), math.rand_negative()/10, math.rand_negative()/10
  1067.         tfm.exec.displayParticle(id, x, y, xs, ys, 0, 0, name)
  1068.         tfm.exec.displayParticle(id, x, y, xs, ys, xa, ya, name)
  1069.     end
  1070. end
  1071.  
  1072. function after(temps, func)
  1073.     table.insert(aft, {t=os.time()+temps*1000, f=func})
  1074. end
  1075.  
  1076. ui.addBox = function(id, txt, name, x, y, largeur, hauteur)
  1077.     if (not txt) then txt = "" end
  1078.     if (not x) then x = 100 end
  1079.     if (not y) then y = 100 end
  1080.     if (not hauteur) then hauteur = 200 end
  1081.     if (not largeur) then largeur = 200 end
  1082.     ui.addTextArea(id*100+0 ," ", name, x+0, y+0, largeur     , hauteur   , 0x2D211A, 0x2D211A, 0.8, true)
  1083.     ui.addTextArea(id*100+1 ," ", name, x+1, y+1, largeur-2   , hauteur-2 , 0x986742, 0x986742, 1  , true)
  1084.     ui.addTextArea(id*100+2 ," ", name, x+4, y+4, largeur-8   , hauteur-8 , 0x171311, 0x171311, 1  , true)
  1085.     ui.addTextArea(id*100+3 ," ", name, x+5, y+5, largeur-10  , hauteur-10, 0x0C191C, 0x0C191C, 1  , true)
  1086.     ui.addTextArea(id*100+4 ," ", name, x+6, y+6, largeur-12  , hauteur-12, 0x24474D, 0x24474D, 1  , true)
  1087.     ui.addTextArea(id*100+5 ," ", name, x+7, y+7, largeur-14  , hauteur-14, 0x183337, 0x183337, 1  , true)
  1088.     ui.addTextArea(id       ,txt, name, x+8, y+8, largeur-16  , hauteur-16, 0x122528, 0x122528, 1  , true)
  1089. end
  1090.  
  1091. ui.addTextPopup = function(id, txt, name, x, y, largeur, hauteur)
  1092.     ui.addTextArea(id*100+0, " ", name, x-1, y-1, largeur-1, hauteur-1, 0x648FA4, 0x648FA4, 1, true)
  1093.     ui.addTextArea(id*100+1, " ", name, x+1, y+1, largeur  , hauteur  , 0x0E1417, 0x0E1417, 1, true)
  1094.     ui.addTextArea(id*100+2, txt, name, x  , y  , largeur  , hauteur  , 0x324650, 0x324650, 1, true)
  1095.  
  1096.     local x2, y2, l2, h2, tx2 = x+largeur*0.15, y+hauteur-18, largeur*0.7, 12, format("<p align='center'><a href='event:$close$Pop$%d'>%s", id, translate("win_close", name))
  1097.     ui.addTextArea(id*100+3, " ", name, x2-1, y2-1, l2-1, h2-1, 0x5D7D90, 0x5D7D90, 1, true)
  1098.     ui.addTextArea(id*100+4, " ", name, x2+1, y2+1, l2  , h2  , 0x11171C, 0x11171C, 1, true)
  1099.     ui.addTextArea(id*100+5, " ", name, x2  , y2  , l2  , h2  , 0x3C5064, 0x3C5064, 1, true)
  1100.     ui.addTextArea(id*100+6, tx2, name, x2  , y2-3, l2  , 20  , 0x0, 0x0, 0, true)
  1101. end
  1102.  
  1103. ui.removePop = function(id, name)
  1104.     for i=id*100, id*100+10 do
  1105.         ui.removeTextArea(i, name)
  1106.     end
  1107. end
  1108.  
  1109. ui.removeBox = function(id, name)
  1110.     if id then
  1111.         ui.removeTextArea(id, name)
  1112.         for i=id*100, id*100+15 do
  1113.             ui.removeTextArea(i, name)
  1114.         end
  1115.     end
  1116. end
  1117.  
  1118. ui.addText = function(id, txt, name, x, y, border, size)
  1119.     local i = id*100
  1120.     for ox=-1, 1 do
  1121.         for oy=-1, 1 do
  1122.             if math.abs(ox)~=math.abs(oy) and ox~=-oy and (not (ox==0 and oy==0) or t==2) then
  1123.                 i = i +1
  1124.                 ui.addTextArea(i, "<p align='center'><b><font color='#000000' size='"..(size or 35).."'>"..txt, name, x+ox*(border or 1)-350, y+oy*(border or 1)-size/1.5, 700, nil, 0x0, 0x0, 0)
  1125.             end
  1126.         end
  1127.     end
  1128.     ui.addTextArea(i+1, "<p align='center'><b><font color='#6A7595' size='"..(size or 35).."'>"..txt, name, x-350, y-size/1.5, 700, nil, 0x0, 0x0, 0)
  1129. end
  1130.  
  1131. function translate(msg, name)
  1132.     return T[players[name].lang][msg]
  1133. end
  1134.  
  1135. function string:split(sep) -- Split a string into a table thanks to a separator
  1136.     local sep, buffer = sep or "$", {}
  1137.     for element in self:gmatch("[^"..sep.."]+") do
  1138.         table.insert(buffer, element)
  1139.     end
  1140.     return buffer
  1141. end
  1142.  
  1143. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement