Advertisement
Guest User

Untitled

a guest
Aug 30th, 2014
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.76 KB | None | 0 0
  1. -- By Nicolasledu
  2. alive = {}
  3. admin = {"Nicolasledu"}
  4. -- Le premier admin choisira la question
  5. -- admin = {"pseud 1", "pseudo2"}
  6. -- Ajouter autant d'admin que vous voulez.
  7.  
  8. tfm.exec.disableAutoShaman(true)
  9. tfm.exec.disableAutoNewGame(true)
  10. tfm.exec.disableAfkDeath(true)
  11. tfm.exec.newGame("@5382897")
  12. tfm.exec.setUIMapName("Le jeu de la bombe ! | <r>@5382897")
  13.  
  14. function eventNewPlayer(name)
  15.     alive[name] = false
  16.     ui.addTextArea(10, "En attente de la nouvelle partie", name, 10, 26, 780, 18)
  17.     tfm.exec.respawnPlayer(name)
  18.     tfm.exec.movePlayer(name,194,286)
  19.     system.bindMouse("Nicolasledu",true)
  20.  
  21. end
  22.  
  23. function eventPlayerLeft(name)
  24.     alive[name] = false
  25.  
  26. end
  27.  
  28. function eventMouse(playerName,x,y)
  29.     tfm.exec.movePlayer(playerName,x,y)
  30. end
  31.  
  32. for i,k in pairs(tfm.get.room.playerList) do
  33.     eventNewPlayer(i)
  34. end
  35.  
  36. function isAdmin(p)
  37. -- test "Si il est admin"
  38.     for i,k in pairs(admin) do
  39.         if k == p then return true end
  40.     end
  41.     return false
  42. end
  43.  
  44. function start()
  45.     for i,k in pairs(tfm.get.room.playerList) do
  46.         if isAdmin(i) then
  47.             alive[i] = "admin"
  48.             tfm.exec.movePlayer(i,402,81)
  49.             -- Téléportation des joueurs
  50.         else
  51.             alive[i] = true
  52.             tfm.exec.movePlayer(i,603,286)
  53.         end
  54.     end
  55.     ui.addPopup(1,2, "<p align='center'><b>Rentre la question ici :</b></p>", admin[1], 292, 150, 212)
  56. end
  57.  
  58. function eventNewGame()
  59.     start()
  60. end
  61.  
  62. function eventPopupAnswer(idpopup, playerName, answer)
  63.     if idpopup==1 then -- Set Question
  64.         question = answer
  65.         ui.addPopup(2,2, "<p align='center'><b>Rentre la réponse</b></p>", admin[1], 292, 150, 212)
  66.  
  67.     elseif idpopup==2 then -- Set Reponse
  68.         reponse = string.lower(answer)
  69.         for i,k in pairs(tfm.get.room.playerList) do
  70.             if alive[i] == true then -- Si il est en vie, affiche la question, et fenêtre de réponse
  71.                 ui.addTextArea(10, "La question est : <BL>"..question.."", i, 10, 26, 780, 18)
  72.                 ui.addPopup(3,2, "<p align='center'><b>Rentrez votre réponse ici</b></p>", i, 292, 150, 212)
  73.             elseif alive[i] == "admin" then
  74.                 ui.addTextArea(10, "<j>La question est : <BL>"..question.."<j> Et la réponse :<bl> "..reponse.."", i, 10, 26, 780, 18)
  75.             else
  76.                 ui.addTextArea(10, "Tu es éliminé, mais la question est : <BL>"..question..".", i, 10, 26, 780, 18)
  77.             end
  78.         end
  79.     elseif idpopup==3 then -- Joueurs donnent réponse
  80.    
  81.         if string.lower(answer)==tostring(reponse) and alive[playerName] then -- Si la réponse est juste
  82.             ui.addPopup(3,2, " ", all, 50000, 1400000, 212,true)
  83.             gagnant = playerName
  84.             -- Affichage des pseudos au gagnant
  85.             a = ""
  86.             for i,k in pairs(tfm.get.room.playerList) do
  87.                 if alive[i] == true then
  88.                 a = a.."<a href='event:"..i.."'>"..i.."</a>\n"
  89.                 end
  90.             end
  91.             ui.addTextArea(100,a,gagnant,805,15)
  92.             a = nil
  93.             canvote = true
  94.             ui.addTextArea(10, "<r><b>"..gagnant.."</b> <j>a trouvé la réponse ! La réponse était <r>"..reponse.."<j>, il peut maintenant choisir quelqu'un à éliminer", i, 10, 26, 780, 18)
  95.             reponse = nil
  96.         else -- Si elle l'est pas
  97.             ui.addPopup(3,2, "<p align='center'><b>Rentrez votre réponse ici</b></p>", playerName, 292, 150, 212)
  98.         end
  99.     end
  100.  
  101. end
  102.  
  103.  
  104. function eventTextAreaCallback(id,name,callback) -- Détection des liens cliquables
  105.     if id == 100 and canvote then
  106.         canvote = false
  107.         alive[callback] = false
  108.         tfm.exec.movePlayer(callback,194,286)
  109.         b = 0
  110.         ui.removeTextArea(100)
  111.         for i,k in pairs(tfm.get.room.playerList) do
  112.             if alive[i] == true then
  113.             b = b + 1
  114.             end
  115.         end
  116.             if b == 1 then
  117.                 ui.addTextArea(10, "<r>"..gagnant.."<j> a décidé d'éliminé <r>"..callback.."<j> ! Dommage pour elle/lui !<VP> Et "..gagnant.." a gagné la partie !!", i, 10, 26, 780, 18)
  118.     local xp=tfm.get.room.playerList[gagnant].x
  119.     local yp=tfm.get.room.playerList[gagnant].y
  120.         drawCircle({{x=xp,y=yp},{x=xp+20,y=yp+20},5})
  121.         drawCircle({{x=xp,y=yp},{x=xp+20,y=yp+20},29})
  122.         drawCircle({{x=xp,y=yp},{x=xp+20,y=yp+20},29})         
  123.             else
  124.                 ui.addTextArea(10, "<r>"..gagnant.."<j> a décidé d'éliminé <r>"..callback.."<j> ! Dommage pour elle/lui ! <VP> Prochaine question dans pas longtemps", i, 10, 26, 780, 18)
  125.                 gagnant = nil
  126.                 ui.addPopup(1,2, "<p align='center'><b>Rentre la question ici :</b></p>", admin[1], 292, 150, 212) 
  127.             end
  128.         gagnant = nil
  129.     end
  130. end
  131.  
  132. function drawCircle(arg)
  133.     local point1,point2,particle=arg[1],arg[2],arg[3]
  134.     r = math.sqrt(math.pow((point1.x-point2.x),2)+math.pow((point1.y-point2.y),2))
  135.     res = 1-r*math.pow(10,-2)
  136.     if res<0.1 then
  137.         res =0.04
  138.     end
  139.     for i=0,2*math.pi,res do
  140.         tfm.exec.displayParticle(particle,point1.x+r*math.cos(i),point1.y+r*math.sin(i),math.random(-1,1),math.random(-1,1),0,0)
  141.     end
  142. end
  143.  
  144. function eventChatCommand(joueur,commande)
  145.     if joueur==admin[1] then
  146.         if commande:sub(0,4)=="kill" then
  147.             alive[commande:sub(6)] = false
  148.             tfm.exec.movePlayer(commande:sub(6),194,286)
  149.         elseif commande:sub(0,5) == "alive" then
  150.             alive[commande:sub(7)] = true
  151.             tfm.exec.movePlayer(commande:sub(7),603,286)
  152.         end
  153.     end
  154. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement