Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function main()
- player = {}
- rang = {
- {rank="<J>SS<N>", req=1000},
- {rank="<V>S<N>", req=700},
- {rank="<VP>A<N>", req=500},
- {rank="<BL>B<N>", req=350},
- {rank="<BV>C<N>", req=200},
- {rank="<VI>D<N>", req=100},
- {rank="<ROSE>E<N>", req=50},
- {rank="<R>F<N>", req=0}
- }
- souris = {}
- favo = ""
- shaman = ""
- 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}
- tfm.exec.disableAutoNewGame(true)
- tfm.exec.disableAutoShaman(true)
- tfm.exec.newGame(mapList[math.random(#mapList)])
- system.disableChatCommandDisplay("p", true)
- end
- function eventNewPlayer(name)
- player[name] = {
- class = rang[8],
- jouees = 0,
- pts = 0
- }
- tfm.exec.bindKeyboard(name, 80, true, true)
- updateRank(name)
- getPlayers()
- end
- function eventPlayerLeft(name)
- player[name] = {}
- getPlayers()
- end
- function eventChatCommand(name, cmd)
- if cmd:sub(0,1) == "p" then
- for all in pairs(tfm.get.room.playerList) do
- if all==cmd:sub(3) then
- viewProfil(name, cmd:sub(3))
- end
- end
- end
- end
- function sendMenu(id, player, text, x, y, width, height, alpha)
- text = '<font color="#8ECD26">'..text
- ui.addTextArea(id..'00', '', player, x+4, y+24, width+12, height+2, 0x1D130E, 0x1D130E, alpha, true)
- ui.addTextArea(id..'000', '', player, x+5, y+25, width+10, height+0, 0x1E140E, 0x1E140E, alpha, true)
- ui.addTextArea(id..'0000', text, player, x+6, y+26, width+8, height+-2, 0x483224, 0x483224, alpha, true)
- ui.addTextArea(id..'00000', '', player, x+15, y+height-20+25, width-10, 15, 0x553523, 0x553523, alpha, true)
- ui.addTextArea(id..'000000', '', player, x+15, y+height-20+27, width-10, 15, 0x150D09, 0x150D09, alpha, true)
- 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)
- end
- function closeMenu(id, player)
- for x = 11,0,-1 do
- id = id..'0'
- ui.removeTextArea(id, player)
- end
- end
- function viewProfil(name, pseudo)
- 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)
- end
- function eventTextAreaCallback(id, name, cb)
- if cb:sub(0,6) == 'fechar' then
- id = cb:sub(8)
- closeMenu(id, name)
- end
- end
- function eventKeyboard(name, key, down, x, y)
- if key == 80 then
- viewProfil(name, name)
- end
- end
- function updateRank(name)
- for _,v in ipairs(rang) do
- if player[name].pts >= v.req then
- player[name].class = v.rank
- break
- end
- end
- end
- function randomFavo()
- favo = souris[math.random(#souris)]
- end
- function randomShaman()
- randomch = souris[math.random(#souris)]
- while favo == randomch do
- randomch = souris[math.random(#souris)]
- end
- if favo ~= randomch then
- shaman = randomch
- end
- end
- function getPlayers()
- souris = {}
- for all in pairs(tfm.get.room.playerList) do
- table.insert(souris, all)
- end
- if souris[3] then
- ui.removeTextArea(1000, nil)
- return true
- else
- 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)
- return false
- end
- end
- function eventNewGame()
- if getPlayers() then
- for all in pairs(tfm.get.room.playerList) do
- player[all].jouees = player[all].jouees + 1
- end
- ui.removeTextArea(1, shaman)
- ui.removeTextArea(2, favo)
- randomFavo()
- randomShaman()
- tfm.exec.setShaman(shaman)
- 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)
- 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)
- end
- end
- function eventPlayerDied(name)
- if playerLeft() == 0 then -- S'il n'y a plus de joueurs sur la carte ...
- tfm.exec.newGame(mapList[math.random(#mapList)]) -- On lance une carte de la liste
- end
- end
- function eventPlayerWon(name, timeBegin, timeRes)
- if getPlayers() then
- if name==favo then
- player[favo].pts = player[favo].pts + 5
- player[shaman].pts = player[shaman].pts + 5
- else
- player[name].pts = player[name].pts + 3
- player[shaman].pts = player[shaman].pts - 1
- player[favo].pts = player[favo].pts - 1
- end
- updateRank(name)
- end
- if playerLeft() == 0 then -- Comme pour eventPlayerDied
- tfm.exec.newGame( mapList[math.random(#mapList)] )
- end
- end
- function eventLoop(timePast, timeLeft)
- if timeLeft <= 0 then -- S'il reste moins de 0 millisecondes
- tfm.exec.newGame( mapList[math.random(#mapList)] ) -- On lance une carte de la liste
- end
- end
- function playerLeft()
- local i = 0 -- Compteur de souris
- for _, prop in pairs(tfm.get.room.playerList) do
- if not prop.isDead then -- Si le joueur est encore sur la carte ...
- i = i+1 -- On ajoute 1 au compteur
- end
- end
- return i -- On renvoie le nombre de souris vivantes
- end
- main()
- for name in pairs(tfm.get.room.playerList) do eventNewPlayer(name) end
Advertisement
Add Comment
Please, Sign In to add comment