Advertisement
Bolodefchoco_LUAXML

[Game] Click

Jan 14th, 2017
385
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.32 KB | None | 0 0
  1. click = {
  2.     new = 11,
  3.     timer = 21,
  4.     info = {},
  5.     init = function()
  6.         for k,v in next,{"utoNewGame","utoShaman","fkDeath","utoScore"} do
  7.             tfm.exec["disableA"..v]()
  8.         end
  9.         tfm.exec.setRoomMaxPlayers(30)
  10.         system.disableChatCommandDisplay("p",true)
  11.         click.map()
  12.     end,
  13.     map = function()
  14.         tfm.exec.newGame('<C><P /><Z><S><S L="800" H="100" X="400" Y="400" T="0" P="0,0,0.3,0.2,0,0,0,0" /></S><D><DS X="25" Y="350" /></D><O /><L><JPL P1="125,127"P3="125,131"P4="124,136"P2="123,142"c="000000,16"/><JPL P1="123,142"P3="123,147"P4="123,153"P2="123,160"c="000000,16"/><JPL P1="123,160"P3="123,166"P4="125,172"P2="126,178"c="000000,16"/><JPL P1="126,178"P3="129,185"P4="133,191"P2="138,196"c="000000,16"/><JPL P1="138,196"P3="144,201"P4="151,206"P2="160,210"c="000000,16"/><JPL P1="160,210"P3="171,214"P4="183,216"P2="197,218"c="000000,16"/><JPL P1="197,218"P3="213,219"P4="231,219"P2="213,219"c="000000,16"/><JD P1="215,244"P2="243,225"c="000000,16"/><JD P1="243,225"P2="229,196"c="000000,16"/><L /></L></Z></C>')
  15.     end,
  16.     eventPlayerDied = function(n)
  17.         tfm.exec.respawnPlayer(n)
  18.     end,
  19.     eventNewPlayer = function(n)
  20.         tfm.exec.chatMessage("<BV>Welcome to <CH><B>#click</B><BV>!\n\t» Typing <B>!info</B> displays the help message\n\t» Typing <B>!p Playername</B> opens the profile of the player",n)
  21.         click.info[n] = {
  22.             count = 0,
  23.             total = 0,
  24.             best = 0
  25.         }
  26.         tfm.exec.setPlayerScore(n,0)
  27.     end,
  28.     eventLoop = function()
  29.         click.new = click.new - .5
  30.         if click.new <= 0 then
  31.             if click.timer > 0 then
  32.                 click.timer = click.timer - .5
  33.                 ui.setMapName("CLICK!<")
  34.                 ui.addTextArea(0,"<p align='center'><font size='30'>Click as fast as you can! You have "..math.floor(click.timer).." seconds!",nil,5,30,nil,nil,1,1,0,true)
  35.                 ui.addTextArea(1,"<p align='center'><font size='600'><R><a href='event:.'>•",nil,240,-180,nil,nil,1,1,0,false)
  36.             else
  37.                 local p,r = {},""
  38.                 for k,v in next,click.info do
  39.                     p[#p+1] = {k,v.count}
  40.                 end
  41.                 table.sort(p,function(t1,t2) return t1[2] > t2[2] end)
  42.                 for k,v in next,p do
  43.                     if k < 51 then
  44.                         if k == 1 and v[2]>0 then
  45.                             tfm.exec.chatMessage("<J>"..v[1].." <G>won!")
  46.                             tfm.exec.setPlayerScore(v[1],1,true)
  47.                         end
  48.                         r = r .. "<J>"..k..". <V>"..v[1].." <BL>- <VP>"..v[2].." clicks\n"
  49.                     end
  50.                 end
  51.                 ui.addTextArea(0,r,nil,5,30,250,330,1,1,1,true)
  52.                 click.new = 11
  53.                 click.timer = 21
  54.                 for k,v in next,click.info do
  55.                     if #p > 2 then
  56.                         v.total = v.total + v.count
  57.                         if v.count > v.best then
  58.                             v.best = v.count
  59.                         end
  60.                     end
  61.                     v.count = 0
  62.                     tfm.exec.respawnPlayer(k)
  63.                 end
  64.             end
  65.         else
  66.             ui.setMapName("<J>New game in <ROSE>"..math.floor(click.new).." <J>seconds!<")
  67.         end
  68.     end,
  69.     eventTextAreaCallback = function(i,n,c)
  70.         if c == "." then
  71.             if click.new <= 0 and not tfm.get.room.playerList[n].isDead then
  72.                 click.info[n].count = click.info[n].count + 1
  73.                 tfm.exec.displayParticle(15,math.random(150,650),math.random(100,300),0,0,0,0,n)
  74.             end
  75.         end
  76.         if c == "cp" then
  77.             for i = 3,4 do
  78.                 ui.removeTextArea(i,n)
  79.             end
  80.         end
  81.     end,
  82.     eventChatCommand = function(n,c)
  83.         local p = {}
  84.         for k in c:gmatch("[^%s]+") do
  85.             p[#p+1]=k
  86.         end
  87.         if p[1] == "info" then
  88.             tfm.exec.chatMessage("<BV>Click in the big circle <CH>as fast as you can<BV>. The more you click the higher your chances to be the winner!",n)
  89.         end
  90.         if p[1] == "p" then
  91.             if p[2] then
  92.                 p[2] = p[2]:lower():gsub("%a",string.upper,1)
  93.             else
  94.                 p[2] = n
  95.             end
  96.             if click.info[p[2]] then
  97.                 ui.addTextArea(3,"<p align='center'><font size='18'><a:active>"..p[2].."<font size='13'><p align='left'>\n<J>Total clicks <BL>: <V>"..click.info[p[2]].total.."\n<J>High Score <BL>: <V>"..click.info[p[2]].best.."\n\n<J>Victories <BL>: <V>"..tfm.get.room.playerList[p[2]].score,n,620,260,175,130,1,1,1,true)
  98.                 ui.addTextArea(4,"<p align='center'><R><B><a href='event:cp'>Close",n,625,365,165,20,0x101010,0x101010,1,true)
  99.             end
  100.         end
  101.     end,
  102. }
  103.  
  104. eventPlayerDied = function(n)
  105.     click.eventPlayerDied(n)
  106. end
  107.  
  108. eventNewPlayer = function(n)
  109.     click.eventNewPlayer(n)
  110. end
  111. table.foreach(tfm.get.room.playerList,eventNewPlayer)
  112.  
  113. eventLoop = function()
  114.     click.eventLoop()
  115. end
  116.  
  117. eventTextAreaCallback = function(i,n,c)
  118.     click.eventTextAreaCallback(i,n,c)
  119. end
  120.  
  121. eventChatCommand = function(n,c)
  122.     click.eventChatCommand(n,c)
  123. end
  124.  
  125. click.init()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement