Fireicefly

FavoMice v.1.0

May 23rd, 2015
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.69 KB | None | 0 0
  1. function main()
  2.     player = {}
  3.     rang = {   
  4.             {rank="<J>SS<N>", req=1000},
  5.                 {rank="<V>S<N>", req=700},
  6.                 {rank="<VP>A<N>", req=500},
  7.                 {rank="<BL>B<N>", req=350},
  8.                 {rank="<BV>C<N>", req=200},
  9.                 {rank="<VI>D<N>", req=100},
  10.                 {rank="<ROSE>E<N>", req=50},
  11.                 {rank="<R>F<N>", req=0}
  12.         }
  13.         souris = {}
  14.         favo = ""
  15.         shaman = ""
  16.     mapList = {0, 2, 3, 4, 5, 9, 13, 15, 16, 17, 18, 19, 20, 21, 25, 32, 33, 38, 39, 40, 41, 66, 69, 71, 72, 75, 76, 85, 90, 91, 93, 94, 98, 99, 101, 102, 103, 104, 105, 106, 107, 132}
  17.      tfm.exec.disableAutoNewGame(true)
  18.      tfm.exec.disableAutoShaman(true)
  19.      tfm.exec.newGame(mapList[math.random(#mapList)])
  20.     system.disableChatCommandDisplay("p", true)
  21. end
  22.  
  23. function eventNewPlayer(name)
  24.     player[name] = {
  25.         class = rang[8],
  26.         jouees = 0,
  27.         pts = 0
  28.     }
  29.     tfm.exec.bindKeyboard(name, 80, true, true)
  30.     updateRank(name)
  31.     getPlayers()
  32. end
  33.  
  34. function eventPlayerLeft(name)
  35.     player[name] = {}
  36.     getPlayers()
  37. end
  38.  
  39. function eventChatCommand(name, cmd)
  40.     if cmd:sub(0,1) == "p" then
  41.         for all in pairs(tfm.get.room.playerList) do
  42.             if all==cmd:sub(3)  then
  43.                 viewProfil(name, cmd:sub(3))
  44.             end
  45.         end
  46.     end
  47. end
  48.        
  49. function sendMenu(id, player, text, x, y, width, height, alpha)
  50.     text = '<font color="#8ECD26">'..text
  51.         ui.addTextArea(id..'00', '', player, x+4, y+24, width+12, height+2, 0x1D130E, 0x1D130E, alpha, true)
  52.         ui.addTextArea(id..'000', '', player, x+5, y+25, width+10, height+0, 0x1E140E, 0x1E140E, alpha, true)
  53.         ui.addTextArea(id..'0000', text, player, x+6, y+26, width+8, height+-2, 0x483224, 0x483224, alpha, true)
  54.         ui.addTextArea(id..'00000', '', player, x+15, y+height-20+25, width-10, 15, 0x553523, 0x553523, alpha, true)
  55.         ui.addTextArea(id..'000000', '', player, x+15, y+height-20+27, width-10, 15, 0x150D09, 0x150D09, alpha, true)
  56.         ui.addTextArea(id..'0000000', '<p align="center"><a href="event:fechar@'..id..'"><font color="#B65900">Fermer</a>', player, x+15, y+height-20+26, width-10, 15, 0x2B1D15, 0x2B1D15, alpha, true)
  57. end
  58.      
  59. function closeMenu(id, player)
  60.     for x = 11,0,-1 do
  61.         id = id..'0'
  62.         ui.removeTextArea(id, player)
  63.     end
  64. end
  65.    
  66. function viewProfil(name, pseudo)
  67.     sendMenu(1728, name, "<p align='center'><font size='24px' face='Comic Sans MS' color='#2F7FCC'>"..pseudo.."</font></p><br /><font size='16px' face='Verdana'><p align='right'><N>Rang : "..player[pseudo].class.."</p><p align='left'><br /><N>Parties jouΓ©es : <J>"..player[pseudo].jouees.."<N><br /><br />Points : <J>"..player[pseudo].pts.."</p></font>", 300, 113, 200, 175, 1)
  68. end
  69.  
  70. function eventTextAreaCallback(id, name, cb)
  71.     if cb:sub(0,6) == 'fechar' then
  72.                 id = cb:sub(8)
  73.                 closeMenu(id, name)
  74.         end
  75. end
  76.  
  77. function eventKeyboard(name, key, down, x, y)
  78.     if key == 80 then
  79.         viewProfil(name, name)
  80.     end
  81. end
  82.  
  83. function updateRank(name)
  84.     for _,v in ipairs(rang) do
  85.         if player[name].pts >= v.req then
  86.             player[name].class = v.rank
  87.             break
  88.         end
  89.     end
  90. end
  91.  
  92. function randomFavo()
  93.     favo = souris[math.random(#souris)]
  94. end
  95.  
  96. function randomShaman()
  97.     randomch = souris[math.random(#souris)]
  98.         while favo == randomch do
  99.             randomch = souris[math.random(#souris)]
  100.         end
  101.         if favo ~= randomch then
  102.             shaman = randomch
  103.         end
  104. end
  105.  
  106. function getPlayers()
  107.     souris = {}
  108.         for all in pairs(tfm.get.room.playerList) do
  109.             table.insert(souris, all)
  110.         end
  111.     if souris[3] then
  112.         ui.removeTextArea(1000, nil)
  113.         return true
  114.     else
  115.         ui.addTextArea(1000, "<font size='48px' face='Comic Sans MS'><p align='center'><R>ERREUR :<J></font><br /><br /><font size='30px'>Vous devez Γͺtre <VP>3<J> au minimum pour jouer.</p></font>", nil, 5, 25, 790, 400, 0x222222, 0xCCCCCC, 0.9, true)
  116.          return false
  117.     end
  118. end
  119.  
  120. function eventNewGame()
  121.     if getPlayers() then
  122.         for all in pairs(tfm.get.room.playerList) do
  123.             player[all].jouees = player[all].jouees + 1
  124.         end
  125.         ui.removeTextArea(1, shaman)
  126.         ui.removeTextArea(2, favo)
  127.         randomFavo()
  128.         randomShaman()
  129.         tfm.exec.setShaman(shaman)
  130.         ui.addTextArea(1, "<p align='center'><font size='16px'>Tu dois favoriser <R>"..favo.."<N> !</p>", shaman, 5, 25, 790, 30, 0x222222, 0xCCCCCC, 0.9, true)
  131.         ui.addTextArea(2, "<p align='center'><font size='16px'>Tu es le favorisΓ©, <R>"..shaman.."<N> essayera de te faire rentrer !</p>", favo, 5, 25, 790, 30, 0x222222, 0xCCCCCC, 0.7, true)
  132.     end
  133. end
  134.  
  135. function eventPlayerDied(name)
  136.    if playerLeft() == 0 then -- S'il n'y a plus de joueurs sur la carte ...
  137.        tfm.exec.newGame(mapList[math.random(#mapList)]) -- On lance une carte de la liste
  138.    end
  139. end
  140.  
  141. function eventPlayerWon(name, timeBegin, timeRes)
  142.     if getPlayers() then
  143.         if name==favo then
  144.             player[favo].pts = player[favo].pts + 5
  145.             player[shaman].pts = player[shaman].pts + 5
  146.         else
  147.             player[name].pts = player[name].pts + 3
  148.             player[shaman].pts = player[shaman].pts - 1
  149.             player[favo].pts = player[favo].pts - 1
  150.         end
  151.         updateRank(name)
  152.     end
  153.    if playerLeft() == 0 then -- Comme pour eventPlayerDied
  154.        tfm.exec.newGame( mapList[math.random(#mapList)] )
  155.    end
  156. end
  157.  
  158. function eventLoop(timePast, timeLeft)
  159.    if timeLeft <= 0 then -- S'il reste moins de 0 millisecondes
  160.        tfm.exec.newGame( mapList[math.random(#mapList)] ) -- On lance une carte de la liste
  161.    end
  162. end
  163.  
  164. function playerLeft()
  165.    local i = 0 -- Compteur de souris
  166.    for _, prop in pairs(tfm.get.room.playerList) do
  167.        if not prop.isDead then -- Si le joueur est encore sur la carte ...
  168.            i = i+1 -- On ajoute 1 au compteur
  169.        end
  170.    end
  171.    return i -- On renvoie le nombre de souris vivantes
  172. end
  173.  
  174. main()
  175.  
  176. for name in pairs(tfm.get.room.playerList) do eventNewPlayer(name) end
Advertisement
Add Comment
Please, Sign In to add comment