Advertisement
podoko_Lua

Premier Utilitaire [v1.1]

Jan 13th, 2014
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 12.86 KB | None | 0 0
  1.    
  2. admin =         {   "Podoko", "Pseudo", "Pseudo" }  -- Remplacez "Pseudo" par "Votre pseudo"
  3.  
  4. mapList =   {   "1", "2", "@3014000", "@3471523", "@4087743",
  5.                     "@3998852", "@3997006", "@423670", "@4672806", "@3758121",
  6.                     "@4160083", "@4057776", "@825035", "@469280", "@1081762",
  7.                     "@1933292", "@2734103", "@204059", "@251430", "@3464359",
  8.                     "@2746128", "@523865", "@3296031", "@3630912", "@1474189",
  9.    
  10.                 }               -- Pour ajouter vos maps : ,"@code1", "@code2"
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  --------------------------------------
  17.  --  Évitez de toucher à ce qui suit --
  18.  --------------------------------------
  19.  
  20.  
  21.  
  22.  
  23.  
  24. mapHistory =    {   0   }
  25. nbMapL = 0
  26. nbMapH = 0
  27.  
  28. parametre = {   ["Fromages pour tous"] = false, ["Respawn auto"] = false, ["Chamane auto"] = true,
  29.    
  30.                     ["Nouvelle map auto"] = true, ["Temps automatique"] = true, ["Compte des points"] = true,
  31.                     ["Mort des afk"] = true,
  32.  
  33.                     ["Tous vampires"] = false, ["Meep pour tous"] =false, ["Tous chamanes"] = false,
  34.  
  35.                     ["Compétences"] = true , ["Temps par défaut"] = 120
  36.  
  37.                 }
  38.  
  39. parametreJ =    {   ch="Chamane", fromage="Fromage", vampire="Vampire",
  40.                     meep="Meep", tuer="Tuer", rez="Respawn", win="Victoire",
  41.                     fly="Voler", tp="Téléporter"
  42.  
  43.                 }
  44.  
  45.  
  46. aff =       {   lJoueurs ={} , joueur = {} , param = {}
  47.                 }
  48.  
  49. all =       {   fly = false , tp = false }
  50.  
  51.  
  52. joueur =     {}
  53. dernierProfil = {}
  54.  
  55. for k, v in pairs (tfm.get.room.playerList) do
  56.         joueur[k] = {}
  57.         joueur[k]["fly"] = false
  58.         joueur[k]["tp"] = false
  59.    
  60. end
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67. for k, pseudo in pairs(admin) do
  68.         ui.addTextArea (1, "<p align='center'><b><a href='event:time'>time</a></b></p>", pseudo, 60, 30, 35, 20, 0x324650, 0x324650, 1, true)
  69.         ui.addTextArea (2, "<p align='center'><b><a href='event:joueurs'>joueurs</a></b></p>", pseudo, 110, 30, 80, 20, 0x324650, 0x324650, 1, true)
  70.         ui.addTextArea (3, "<p align='center'><b><a href='event:parametre'>paramètres</a></b></p>", pseudo, 205, 30, 80, 20, 0x324650, 0x324650, 1, true)
  71.         ui.addTextArea (4, "<p align='center'><b><a href='event:map'>map</a></b></p>", pseudo, 10, 30, 35, 20, 0x324650, 0x324650, 1, true)
  72.         ui.addTextArea (5, "<font size='15' color='#1'><b> <a href='event:-1'>&lt;  </a> <a href='event:repeat'>|| </a>  <a href='event:+1'>&gt;</a>   <a href='event:random'>R</a></b></font>", pseudo, 300, 30, 120, 20, 0,0,1, true)
  73.  
  74.         for l, m in pairs ( aff ) do
  75.             aff[l][pseudo] = false
  76.  
  77.         end
  78. end
  79.  
  80.  
  81.  
  82. function eventTextAreaCallback(id, source, callback)
  83.  
  84.         if callback == 'time' then
  85.    
  86.             ui.addPopup (0, 2, "time to set", source, 10, 70, 150, true)
  87.    
  88.    
  89.         elseif callback == 'map' then  
  90.  
  91.             ui.addPopup (1, 2, "map to play", source, 10, 70, 150, true)
  92.    
  93.  
  94.         elseif callback == 'joueurs' then
  95.  
  96.             if aff["lJoueurs"][source] == false then
  97.                 affLJoueurs ( source )
  98.             else
  99.                 effLJoueurs ( source )
  100.             end
  101.    
  102.  
  103.         elseif callback == 'parametre' then
  104.  
  105.             if aff["param"][source] == false then
  106.                 affParam( source )
  107.             else
  108.                 effParam( source )
  109.             end
  110.    
  111.  
  112.         elseif parametre[callback] ~= nil then
  113.  
  114.             paraGestion(callback,  source )
  115.             ui.updateTextArea (id, callback .. ": <a href='event:" .. callback .. "'>" .. B(parametre[callback]) .. "</a>", source )
  116.    
  117.  
  118.         elseif joueur[callback] ~= nil or callback == "all" then
  119.    
  120.             if aff["joueur"][source] then
  121.                 effJoueur ( source )
  122.                 if callback ~= dernierProfil[source] then
  123.                     eventTextAreaCallback(id, source, callback)
  124.                 end
  125.  
  126.             else
  127.                 affJoueur(source, callback)
  128.                 ui.updateTextArea (id, "<p align='center'><b><V><a href='event:" .. callback .. "'>" .. callback .. "</a></N></b></p>", source)
  129.             end
  130.    
  131.             dernierProfil[source] = callback
  132.  
  133.         elseif parametreJ[callback] ~= nil then
  134.             if dernierProfil[source] == "all" then
  135.  
  136.                 for k, v in pairs ( joueur ) do
  137.                     if all[callback] ~= nil then
  138.                         joueur[k][callback] = all[callback]
  139.                     end
  140.    
  141.                     paraJGestion ( k, callback )
  142.                 end
  143.                 all[callback] = not all[callback]
  144.             else
  145.  
  146.                 paraJGestion ( dernierProfil[source], callback )
  147.    
  148.             end
  149.  
  150.         elseif id == 5 then
  151.    
  152.             mapGestion(callback)
  153.  
  154.         end
  155.    
  156. end
  157.  
  158.  
  159.  
  160. function eventPopupAnswer (id, playerName, answer)
  161.  
  162.         if id == 0 then
  163.             tfm.exec.setGameTime(answer, true)
  164.  
  165.         elseif id == 1 then
  166.             tfm.exec.newGame(answer)
  167.  
  168.         elseif id == 3 then
  169.  
  170.             parametre["Temps par défaut"] = answer  
  171.    
  172.         end
  173. end
  174.  
  175.  
  176. function eventChatCommand ( name, command )
  177.         M = 1
  178.         LM = {}
  179.  
  180.         for w in string.gmatch(command, "%a+") do
  181.             LM[M] = w
  182.             M = M+1
  183.         end
  184.         if command == "commande" then
  185.            
  186.             listeCommande = ""
  187.             for k, v in pairs ( parametreJ ) do        
  188.                 listeCommande = listeCommande.."\n!"..k.." [Pseudo] =&gt; "..v
  189.             end
  190.  
  191.             ui.addPopup (0, 3, "Liste des commandes et de leur équivalent dans le menu : \n"..listeCommande, name, 10, 80, 200, true) 
  192.  
  193.         else
  194.             if isAdmin ( name ) then
  195.  
  196.                 if parametreJ[LM[1]] ~= nil then
  197.                     if joueur[LM[2]] ~= nil then
  198.                         paraJGestion ( LM[2], LM[1] )
  199.                     else
  200.                         ui.addPopup (0, 3, "Je ne trouve pas "..LM[2].." dans le salon. \nNe me tapez pas :(", name, 515, 325, 280, true)
  201.                     end
  202.                 else
  203.                     ui.addPopup (0, 3, "Je ne connais pas cette commande. Tapez !commande pour voir la liste des commandes.", name, 515, 325, 280, true)
  204.                 end
  205.            
  206.             else
  207.            
  208.                 ui.addPopup (0, 3, "Tu n'as pas le droit d'utiliser cette commande :/", name, 515, 340, 280, true)
  209.        
  210.             end
  211.         end
  212. end
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226. function affLJoueurs(playerName)
  227.         aff["lJoueurs"][playerName] = true
  228.         if aff["param"][playerName] then
  229.             effParam ( playerName )
  230.         end
  231.         ui.addTextArea(1000, "<p align='center'><a href='event:all'>all</a></p>", playerName, 110, 65, 80, 20, 0x324650, 0x324650, 1, true)
  232.         a=1
  233.         for k, v in pairs(joueur) do
  234.             ui.addTextArea(1000+a, "<p align='center'><a href='event:" ..k.. "'>" .. k .. "</a></p>", playerName, 110-100*math.floor(a/10), 65+35*(a%10), 80, 20, 0x324650, 0x324650, 1, true)
  235.             a=a+1
  236.         end
  237. end
  238.  
  239. function effLJoueurs(playerName)
  240.         aff["lJoueurs"][playerName] = false
  241.  
  242.  
  243.         if aff["joueur"][playerName] then
  244.             effJoueur ( playerName )
  245.         end
  246.  
  247.         for k=a+1000,1000,-1 do
  248.             ui.removeTextArea(k, playerName)
  249.         end
  250. end
  251.  
  252.  
  253. function affParam(playerName)
  254.         aff["param"][playerName] = true
  255.         if aff["lJoueurs"][playerName] then
  256.             effLJoueurs ( playerName )
  257.         end
  258.  
  259.  
  260.         b=0
  261.         for k, v in pairs(parametre) do
  262.             ui.addTextArea (b+2000, k.." : <a href='event:"..k.."'>"..B(v).."</a>" , playerName, 10+185*math.floor(b/6), 65+35*(b % 6), 170, 20, 0x324650, 0x324650, 1, true)
  263.  
  264.             b=b+1
  265.         end
  266. end
  267.  
  268.  
  269. function effParam(playerName)
  270.         aff["param"][playerName] = false
  271.         for k=b,0,-1 do
  272.             ui.removeTextArea(k+2000, playerName)
  273.         end
  274. end
  275.  
  276.  
  277.  
  278.  
  279. function affJoueur ( playerName, callback )
  280.         aff["joueur"][playerName] = true
  281.  
  282.         c = 0
  283.         for k, v in pairs ( parametreJ ) do
  284.             c = c+1
  285.             ui.addTextArea (c+3000, "<a href='event:"..k.."'>"..v.."</a>", playerName, 205, 30+35*c, 60, 20, 0x324650, 0x324650, 1, true)
  286.         end
  287.  
  288. end
  289.  
  290. function effJoueur ( playerName )
  291.         aff["joueur"][playerName] = false
  292.    
  293.         for k = c, 0, -1 do
  294.             ui.removeTextArea( k+3000, playerName )
  295.         end
  296.  
  297. end
  298.  
  299.  
  300.  
  301.  
  302. function B(v)
  303.         if type(v) == "boolean" then
  304.             if v==true then
  305.                 return "<v><b>true</b></v>"
  306.             else
  307.                 return "<r><b>false</b></r>"
  308.             end
  309.         else
  310.             return "<b>  "..v.."  </b>"
  311.         end
  312. end
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323. function paraGestion ( paraModif , playerName)
  324.    
  325.         if type(parametre[paraModif]) == "boolean" then
  326.             parametre[paraModif] = not parametre[paraModif]
  327.         end
  328.    
  329.    
  330.         if paraModif == "Fromages pour tous" and parametre[paraModif] then
  331.             for k, v in pairs (joueur) do
  332.                 tfm.exec.giveCheese ( k )
  333.             end
  334.         elseif paraModif == "Respawn auto" and parametre[paraModif] then
  335.             for k, v in pairs (joueur) do
  336.                 tfm.exec.respawnPlayer ( k )
  337.             end
  338.  
  339.  
  340.  
  341.         elseif paraModif == "Chamane auto" then
  342.             tfm.exec.disableAutoShaman( not parametre[paraModif] )
  343.         elseif paraModif == "Nouvelle map auto" then
  344.             tfm.exec.disableAutoNewGame ( not parametre[paraModif] )
  345.         elseif paraModif == "Temps automatique" then
  346.             tfm.exec.disableAutoTimeLeft ( not parametre[paraModif] )
  347.         elseif paraModif == "Compte des points" then
  348.             tfm.exec.disableAutoScore ( not parametre[paraModif] )
  349.         elseif paraModif == "Mort des afk" then
  350.             tfm.exec.disableAfkDeath ( not parametre[paraModif] )
  351.         elseif paraModif == "Temps par défaut" then
  352.             ui.addPopup (3, 2, "enter default map time", playerName, 200, 200, 150, true)
  353.  
  354.  
  355.         elseif paraModif == "Tous vampires" and parametre[paraModif] then
  356.             for k, v in pairs ( joueur ) do
  357.                 tfm.exec.setVampirePlayer ( k )
  358.             end
  359.         elseif paraModif == "Meep pour tous" and parametre[paraModif] then
  360.             for k, v in pairs ( joueur ) do
  361.                 tfm.exec.giveMeep ( k )
  362.             end
  363.         elseif paraModif == "Tous chamanes" and parametre[paraModif] then
  364.             for k, v in pairs ( joueur ) do
  365.                 tfm.exec.setShaman ( k )
  366.             end
  367.    
  368.    
  369.         elseif paraModif == "Compétences" then
  370.             tfm.exec.disableAllShamanSkills ( not parametre[paraModif] )
  371.         end
  372.  
  373.    
  374.  
  375.  
  376.  
  377. end
  378.  
  379.  
  380. function paraJGestion ( playerName, action )
  381.         if action == "fromage" then
  382.             tfm.exec.giveCheese ( playerName )
  383.         elseif action == "ch" then
  384.             tfm.exec.setShaman ( playerName )
  385.         elseif action == "vampire" then
  386.             tfm.exec.setVampirePlayer ( playerName )
  387.         elseif action == "meep" then
  388.             tfm.exec.giveMeep ( playerName )
  389.         elseif action == "tuer" then
  390.             tfm.exec.killPlayer ( playerName )
  391.         elseif action == "rez" then
  392.             tfm.exec.respawnPlayer ( playerName )
  393.         elseif action == "win" then
  394.             tfm.exec.giveCheese ( playerName )
  395.             tfm.exec.playerVictory ( playerName )
  396.         elseif action == "fly" then
  397.             joueur[playerName]["fly"] = not joueur[playerName]["fly"]
  398.             tfm.exec.bindKeyboard (playerName, 32, true, joueur[playerName]["fly"])
  399.             if joueur[playerName]["fly"] then
  400.                 ui.addPopup (10, 3, "Tu peux voler, appuie sur espace :)", playerName, 400, 200, 220, true)
  401.             else
  402.                 ui.addPopup (10, 3, "Tu ne peux plus voler :(", playerName, 400, 200, 220, true)
  403.             end
  404.         elseif action == "tp" then
  405.             joueur[playerName]["tp"] = not joueur[playerName]["tp"]
  406.             system.bindMouse ( playerName, joueur[playerName]["tp"] )
  407.             if joueur[playerName]["tp"] then
  408.                 ui.addPopup (10, 3, "Tu peux te téléporter, cli clic :)", playerName, 400, 200, 200, true)
  409.             else
  410.                 ui.addPopup (10, 3, "Tu ne peux plus te téléporter :(", playerName, 400, 200, 200, true)
  411.             end
  412.  
  413.         end
  414.  
  415. end
  416.  
  417.  
  418.  
  419. function mapGestion (action)
  420.         if action == 'random' then
  421.             nbMapL = math.random(#mapList)
  422.             tfm.exec.newGame(mapList[nbMapL])
  423.  
  424.         elseif action == 'repeat' then
  425.             tfm.exec.newGame(tfm.get.room.currentMap)
  426.  
  427.         else
  428.             if action == '-1' and (nbMapL + action) > 0 then
  429.                 nbMapL = nbMapL -1
  430.                 tfm.exec.newGame ( mapList[nbMapL] )
  431.  
  432.             elseif action == '+1' and (nbMapL + action) <= #mapList then
  433.                 nbMapL = nbMapL + 1
  434.                 tfm.exec.newGame ( mapList[nbMapL] )
  435.         end
  436.         end
  437. end
  438.  
  439.  
  440.  
  441.  
  442. function eventNewPlayer ( playerName )
  443.    
  444.         print ( playerName .. " vient d'entrer dans le salon \o/" )
  445.         joueur[playerName] = {}
  446.         joueur[playerName]["fly"] = all["fly"]
  447.         joueur[playerName]["tp"] = all["tp"]
  448.  
  449.         if parametre["Respawn auto"] then
  450.             tfm.exec.respawnPlayer ( playerName )
  451.         end
  452.  
  453. end
  454.  
  455. function eventPlayerLeft ( playerName )
  456.  
  457.         print ( playerName.. " vient de quitter le salon :(" )
  458.         joueur[playerName] = nil
  459.  
  460. end
  461.  
  462. function eventPlayerDied ( playerName )
  463.  
  464.  
  465.         if parametre["Respawn auto"] then
  466.             tfm.exec.respawnPlayer ( playerName )
  467.         end
  468.  
  469. end
  470.  
  471.  
  472. function eventPlayerWon ( playerName )
  473.  
  474.         if parametre["Respawn auto"] then
  475.    
  476.             tfm.exec.respawnPlayer ( playerName )
  477.         end
  478. end
  479.  
  480.  
  481.  
  482. function eventNewGame ()
  483.  
  484.         if tfm.get.room.currentMap ~= mapHistory[nbMap] then
  485.    
  486.             nbMapH = nbMapH
  487.             mapHistory[nbMapH] = tfm.get.room.currentMap
  488.         end
  489.  
  490.         tfm.exec.setGameTime ( parametre["Temps par défaut"] )  
  491.  
  492.         for k, v in pairs ( joueur ) do
  493.             eventPlayerRespawn ( k )
  494.         end
  495.  
  496. end
  497.  
  498.  
  499.  
  500. function eventPlayerRespawn ( playerName )
  501.  
  502.         if parametre["Fromages pour tous"] then
  503.             tfm.exec.giveCheese ( playerName )
  504.         end
  505.         if parametre["Tous chamanes"] then
  506.             tfm.exec.setShaman ( playerName )
  507.         end
  508.         if parametre["Tous vampires"] then
  509.             tfm.exec.setVampirePlayer ( playerName )
  510.         end
  511.         if parametre["Meep pour tous"] then
  512.             tfm.exec.giveMeep ( playerName )
  513.         end
  514. end
  515.  
  516.  
  517.  
  518. function eventKeyboard (playerName, keyCode, down, xPlayerPosition, yPlayerPosition)
  519.  
  520.         if keyCode == 32 then
  521.             tfm.exec.movePlayer(playerName,0,0,true,0,-50,false)
  522.         end
  523.  
  524. end
  525.  
  526. function eventMouse (playerName, xMousePosition, yMousePosition)
  527.  
  528.         tfm.exec.movePlayer(playerName,xMousePosition,yMousePosition,false,0,0,true)
  529.  
  530. end
  531.  
  532.  
  533.  
  534.  
  535.  
  536.  
  537. function isAdmin ( name )
  538.         for k, v in pairs( admin ) do
  539.             if name == v then
  540.                 return true
  541.             end
  542.         end
  543.         return false
  544. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement