Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local xml = '<C><P /><Z><S><S L="800" o="6a7495" H="28" X="401" Y="390" T="12" P="0,0,0.3,0.2,0,0,0,0" /></S><D><DS Y="366" X="405" /></D><O /></Z></C>'
- local positions = {
- -- X1, X2(detect) X, Y (arrow)
- {34, 172, 86, 263, "Racing"},
- {233, 360, 281, 263, "Bootcamp"},
- {425, 550, 471, 263, "Deathmatch"},
- {614, 735, 661, 263, "Random"},
- {173, 220},
- {361, 420},
- {551, 610},
- }
- local mice = {}
- local score = {0, 0, 0, 0}
- local countdown = 7
- function main()
- tfm.exec.disableAutoShaman(true)
- tfm.exec.disableAutoNewGame(true)
- tfm.exec.disableAfkDeath(true)
- tfm.exec.newGame(xml)
- ui.addTextArea(5, "\n\n<font size='30'><p align='center'>Racing</p></font>", nil, 32, 146, 140, 100, 0x324650, 0x000000, 1, true)
- ui.addTextArea(6, "\n\n<font size='27'><p align='center'>Bootcamp</p></font>", nil, 224, 146, 140, 100, 0x324650, 0x000000, 1, true)
- ui.addTextArea(7, "\n<font size='30'><p align='center'>Deathmatch</p></font>", nil, 416, 146, 140, 100, 0x324650, 0x000000, 1, true)
- ui.addTextArea(8, "\n\n<font size='30'><p align='center'>Random</p></font>", nil, 608, 145, 140, 100, 0x324650, 0x000000, 1, true)
- ui.addTextArea(0, "<font size='60' face='Freestyle Script'>¡Escoge un modo de juego!</font>", nil, 197, 34, 594, 78, 0x324650, 0x000000, 0, true)
- ui.addTextArea(12, "<font size='30' color='#000000'>" .. countdown .. "</font>", nil, 363, 82, 42, 42, 0x324650, 0x000000, 0, true)
- table.foreach(tfm.get.room.playerList, eventNewPlayer)
- end
- function eventNewPlayer(name)
- if not mice[name] then
- mice[name] = {
- vote = 0
- }
- end
- end
- function eventLoop()
- countdown = countdown - 0.5
- if countdown >= 1 then
- for name, player in pairs(tfm.get.room.playerList) do
- for i = 1, #positions do
- if player.x >= positions[i][1] and player.x <= positions[i][2] then
- if i <= 4 then
- mice[name].vote = i
- ui.addTextArea(10, "<font size='30'>↑</font>", name, positions[i][3], positions[i][4], 23, 53, 0x324650, 0x000000, 0, true)
- else
- mice[name].vote = 0
- ui.removeTextArea(10, name)
- end
- end
- end
- end
- elseif countdown <= 0 then
- ui.removeTextArea(12, nil)
- score = {0, 0, 0, 0}
- for name, mice in pairs(mice) do
- if mice.vote ~= 0 then
- score[mice.vote] = score[mice.vote] + 1
- end
- end
- getModeWinner()
- countdown = 5000
- end
- ui.updateTextArea(12, "<font size='30' color='#000000'>".. countdown.. "</font>", nil)
- end
- function max(t, fn)
- local i = 0
- for a = 1, #t do
- if t[a] > 0 then
- i = i + 1
- end
- end
- if i > 0 then
- if #t == 0 then return nil, nil end
- local key, value = 1, t[1]
- for i = 2, #t do
- if fn(value, t[i]) then
- key, value = i, t[i]
- end
- end
- return key, value
- end
- return 4
- end
- function getModeWinner()
- local mode = max(score, function(a,b) return a < b end)
- print(positions[mode][5])
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement