Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- isRoom = tfm.get.room.name:find("#")~=nil
- roomAdmin,winners = "",{}
- isRunning = false
- do
- local chat,txtarea = tfm.exec.chatMessage,ui.addTextArea
- tfm.exec.chatMessage = function(...)
- if isRoom then
- chat(...)
- end
- end
- ui.addTextArea = function(...)
- if not isRoom or ({...})[1]==3 or ({...})[1]==4 then
- txtarea(...)
- end
- end
- end
- for k,v in next,{"AutoShaman","AutoNewGame","AutoTimeLeft","AutoScore","AfkDeath","MortCommand","DebugCommand"} do
- tfm.exec["disable"..v]()
- end
- table.random=function(t)
- return (type(t)=="table" and t[math.random(#t)] or math.random())
- end
- system.rank=function(players,lim)
- local p,rank = {},""
- lim = tonumber(lim) or 100
- for m,n in next,players do
- p[#p+1] = {name=n[1],v=n[2]+tfm.get.room.playerList[n[1]].score}
- end
- table.sort(p,function(f,s) return f.v>s.v end)
- for o,n in next,p do
- if o <= lim then
- rank = rank .. "<J>"..o..". <V>" .. n.name .. " <BL>- <VP>" .. n.v .. "x <BL>- <CS>" .. tfm.get.room.playerList[n.name].score .. "x\n"
- end
- end
- return rank
- end
- eventNewPlayer = function(n)
- tfm.exec.chatMessage("<J>Welcome to <VP><B>#presents</B><J>! Choose a gap according to the gift represented and good luck! You will win if your three-gifts-sequence is correct!\n\n<CE>Developed by Bolodefchoco and projected by Ruamorangos",n)
- if isRunning then
- ui.addTextArea(2,"<font size='20'>You will appear in the next sortition!",n,216,65,365,35,1,1,1,true)
- tfm.exec.chatMessage("<VP>You will appear in the next sortition!",n)
- else
- tfm.exec.respawnPlayer(n)
- updateTextAreas()
- end
- end
- choice = {15,true}
- block = {5,false}
- newMap = {10,false}
- currentGift = 1
- total = 1
- eventNewGame = function()
- if isRunning then
- for i,x in next,{250,400,550} do
- tfm.exec.addPhysicObject(i,x,75,{
- type = 12,
- height = 90,
- width = 90,
- miceCollision = false,
- groundCollision = false,
- color = 0x6A7495
- })
- end
- for i = 0,1 do
- ui.removeTextArea(i)
- end
- choice = {15,true}
- block = {5,false}
- newMap = {10,false}
- currentGift = 1
- else
- updateTextAreas()
- end
- tfm.exec.setGameTime(1e7)
- end
- eventTextAreaCallback = function(i,n,c)
- if n == roomAdmin and c == "new" and time>4 then
- ui.addPopup(0,2,"<p align='center'>Inform the amount of sortitions are going to be done",roomAdmin,217,157,366,true)
- end
- end
- eventPopupAnswer = function(i,n,a)
- a = tonumber(a)
- if a then
- total = (a<1 and 1 or a>15 and 15 or a) or 1
- tfm.exec.chatMessage("<R>"..total.." sortitions are going to be done!")
- newGame()
- cleanTextArea()
- else
- eventTextAreaCallback(nil,roomAdmin,"new")
- end
- end
- string.nick = function(player)
- return player:lower():gsub('%a',string.upper,1)
- end
- cleanTextArea = function()
- for i = 0,4 do
- ui.removeTextArea(i,nil)
- end
- end
- updateTextAreas = function()
- cleanTextArea()
- ui.addTextArea(3,"<p align='center'><J><B><font size='14'><a href='event:new'>New Sortition</a>",roomAdmin,5,25,120,21,1,1,1,true)
- ui.addTextArea(4,"<p align='center'><font size='15'><V><B>LEADERBOARD</B></p></font><R>____________________<p align='left'><font size='12'><N>\n\n<BV>"..system.rank(winners,20),nil,275,40,250,340,1,1,1,true)
- end
- kill = function()
- local gift = gifts[currentGift] - 2099
- for k,v in next,tfm.get.room.playerList do
- if not v.isDead then
- if v.x >= (gift * 120) and v.x <= (gift * 120 + 80) and v.y > 267 then
- tfm.exec.setPlayerScore(k,1,true)
- else
- tfm.exec.killPlayer(k)
- end
- end
- end
- end
- newGame = function()
- isRunning = true
- gifts = {
- [1] = table.random({2104,2102,2100,2101,2103,2100,2104,2102,2103,2101,2104,2102,2100,2101,2103,2100,2104,2102,2103,2101,2104,2102,2100,2101,2103,2100,2104,2102,2103,2101}),
- [2] = table.random({2102,2100,2101,2103,2100,2104,2102,2103,2101,2104,2102,2100,2101,2103,2100,2104,2102,2103,2101,2104,2102,2100,2101,2103,2100,2104,2102,2103,2101,2104}),
- [3] = table.random({2100,2101,2103,2100,2104,2102,2103,2101,2104,2102,2100,2101,2103,2100,2104,2102,2103,2101,2104,2102,2100,2101,2103,2100,2104,2102,2103,2101,2104,2102})
- }
- tfm.exec.newGame('<C><P DS="m;250,120,400,120,550,120" D="x_transformice/x_inventaire/'..gifts[1]..'.jpg,230,60;x_transformice/x_inventaire/'..gifts[2]..'.jpg,380,60;x_transformice/x_inventaire/'..gifts[3]..'.jpg,530,60;x_transformice/x_inventaire/2100.jpg,140,320;x_transformice/x_inventaire/2101.jpg,260,320;x_transformice/x_inventaire/2102.jpg,380,320;x_transformice/x_inventaire/2103.jpg,500,320;x_transformice/x_inventaire/2104.jpg,620,320" /><Z><S><S P="1,0.0001,20,0.2,90,1,0,0" H="700" L="15" X="400" c="3" Y="161" T="4" /><S X="100" P="0,0,20,0.2,0,0,0,0" L="40" H="135" c="3" Y="335" T="4" /><S H="135" P="0,0,20,0.2,0,0,0,0" L="40" X="220" c="3" Y="335" T="4" /><S X="340" P="0,0,20,0.2,0,0,0,0" L="40" H="135" c="3" Y="335" T="4" /><S H="135" P="0,0,20,0.2,0,0,0,0" L="40" X="460" c="3" Y="335" T="4" /><S X="580" P="0,0,20,0.2,0,0,0,0" L="40" H="135" c="3" Y="335" T="4" /><S H="40" P="0,0,0.3,0.2,0,0,0,0" L="40" X="100" c="3" Y="160" T="0" /><S X="700" P="0,0,0.3,0.2,0,0,0,0" L="40" H="40" c="3" Y="160" T="0" /><S X="550" P="0,0,0.3,0.2,0,0,0,0" L="40" H="40" c="3" Y="160" T="0" /><S X="400" P="0,0,0.3,0.2,0,0,0,0" L="40" H="40" c="3" Y="160" T="0" /><S X="250" P="0,0,0.3,0.2,0,0,0,0" L="40" H="40" c="3" Y="160" T="0" /><S H="20" P="0,0,0.3,0.2,0,0,0,0" L="800" X="400" Y="10" T="0" /><S H="135" P="0,0,20,0.2,0,0,0,0" L="40" X="700" c="3" Y="335" T="4" /><S X="400" P="0,0,0.3,0.2,0,0,0,0" L="800" H="100" c="3" Y="415" T="0" /><S P="0,0,0.3,0.2,0,0,0,0" H="10" L="50" o="324650" X="745" c="3" Y="138" T="13" /><S X="55" P="0,0,0.3,0.2,0,0,0,0" L="50" o="324650" H="10" c="3" Y="138" T="13" /><S P="0,0,0.3,0.2,0,0,0,0" H="140" L="100" o="324650" X="55" c="3" Y="72" T="12" /><S X="745" P="0,0,0.3,0.2,0,0,0,0" L="100" o="324650" H="140" c="3" Y="72" T="12" /><S P="0,0,0,0,0,0,0,0" H="102" L="581" o="6a7495" X="401" c="4" v="3001" Y="78" T="12" /></S><D /><O /><L><JR M2="10" M1="0" /></L></Z></C>')
- end
- players = function()
- local p = {}
- for k,v in next,tfm.get.room.playerList do
- if not v.isDead then
- p[#p + 1] = k
- end
- end
- return p
- end
- victory = function(none)
- if choice[2] then
- local winner = "%s %s%s!"
- if none or #players() == 0 then
- winner = winner:format("","","Nobody won")
- tfm.exec.chatMessage("<J>Nobody won")
- else
- winner = winner:format(table.concat(players(),", "),"%s","won")
- for k,v in next,players() do
- tfm.exec.chatMessage("<G>"..v.." <J>won!")
- local found = {false,0}
- for i,j in next,winners do
- if j[1] == v then
- found = {true,i}
- break
- end
- end
- if found[1] then
- winners[found[2]][2] = winners[found[2]][2] + 1
- else
- winners[#winners + 1] = {v,1}
- end
- end
- end
- ui.addTextArea(0,"<B><p align='center'><font size='22' color='#1'>".. winner:format(""),nil,0,222,800,h,1,1,0,true)
- ui.addTextArea(1,"<B><p align='center'><font size='22'><V>".. winner:format("<J>"),nil,0,220,800,h,1,1,0,true)
- newMap[2] = true
- end
- end
- def = function()
- total = total - 1
- if isRoom and total == 0 then
- isRunning = false
- tfm.exec.newGame('<C><P DS="y;315" /><Z><S><S P=",,.3,.2,,,," H="100" L="800" X="400" Y="380" T="0" /></S><D /><O /></Z></C>')
- else
- newGame()
- end
- end
- eventLoop = function(time)
- _G.time = (time/1000)
- local mapName = "<N>Rivals : <V>"..#players()
- if not isRunning then
- mapName = "<N>Mice : <V>"..#players().." <G>| <a:active>"..roomAdmin.." is the controler!"
- end
- if _G.time > 4 and isRunning then
- if choice[2] then
- mapName = "<N>Rivals : <V>"..#players().." <G>| <J>Choose a gift in less than <PT>"..math.floor(choice[1]).."<J> seconds!"
- choice[1] = choice[1] - .5
- if choice[1] <= 0 then
- choice = {15,false}
- block[2] = true
- end
- end
- if block[2] then
- mapName = "<N>Rivals : <V>"..#players().." <G>| <R>Those who are out of the correct gift will be dead!"
- block[1] = block[1] - .5
- tfm.exec.addPhysicObject(4,400,270,{
- type = 4,
- height = 10,
- width = 640,
- miceCollision = true,
- groundCollision = false
- })
- tfm.exec.removePhysicObject(currentGift)
- if block[1] == 2 then
- kill()
- end
- if block[1] <= 0 then
- currentGift = currentGift + 1
- block = {5,false}
- choice[2] = true
- if currentGift == 4 then
- victory()
- choice[2] = false
- end
- end
- else
- tfm.exec.removePhysicObject(4)
- end
- if newMap[2] then
- if isRoom and total < 2 then
- mapName = "<PS>Sortition ending in <PT>"..math.floor(newMap[1]).."<PS> seconds!"
- else
- mapName = "<PS>New sortition in <PT>"..math.floor(newMap[1]).."<PS> seconds!"
- end
- newMap[1] = newMap[1] - .5
- if newMap[1] <= 0 then
- def()
- end
- end
- if #players() == 0 then
- victory(true)
- newMap[2] = true
- choice[2] = false
- end
- end
- ui.setMapName(mapName.."<")
- end
- eventChatCommand = function(n,c)
- if n == roomAdmin and not isRunning then
- if c:sub(1,1) == "c" then
- c = string.nick(c:sub(3))
- if tfm.get.room.playerList[c] then
- roomAdmin = c
- ui.removeTextArea(3,n)
- updateTextAreas()
- tfm.exec.chatMessage("<ROSE>"..roomAdmin.." is the new controler!")
- end
- end
- end
- end
- for n in next,tfm.get.room.playerList do
- if isRoom and roomAdmin == "" then
- roomAdmin = n
- end
- end
- def()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement