Advertisement
podoko_Lua

Premier Utilitaire [v1.2]

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