Dudugz-Contistente

Untitled

Dec 12th, 2016
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.60 KB | None | 0 0
  1. height = math.random(3000,6000)
  2.  
  3. xml='<C><P H="'..height..'" Ca="" F="'..math.random(0,8)..'" /><Z><S><S H="'..height..'" o="6a7495" L="200" Y="1500" X="700" P="0,0,0,0,0,0,0,0" T="12" N="" /><S H="'..height..'" o="6a7495" L="600" Y="3206" X="900" P="0,0,0,0,0,0,0,0" T="12" N="" /><S H="'..height..'" o="6a7495" L="200" Y="1500" X="100" P="0,0,0,0,0,0,0,0" T="12" N="" /><S H="'..height..'" o="6a7495" L="200" Y="3205" X="100" P="0,0,0,0,0,0,0,0" T="12" N="" /><S X="400" o="212f36" L="400" Y="'..height..'" c="3" H="10" P="0,0,0.3,0.2,0,0,0,0" T="12" /><S H="150" o="6a7495" L="1200" Y="4760" c="4" X="449" P="0,0,0,0,0,0,0,0" T="12" N="" /></S><D><T X="400" Y="'..math.floor(height-10)..'" /></D><O /></Z></C>'
  4.  
  5. tempo = os.time();
  6.  
  7. tfm.exec.disableAutoNewGame(true)
  8. tfm.exec.disableAutoShaman(true)
  9. tfm.exec.disableAutoTimeLeft(true)
  10.  
  11. vivos=0
  12. wons=0
  13.  
  14. _time = 0;
  15.  
  16. p={}
  17. data={}
  18.  
  19. piso = {
  20. type=12,
  21. color=math.random(0,0xFFFFFF),
  22. linearDamping=1,
  23. angularDamping=1,
  24. dynamic=true,
  25. fixedRotation=true,
  26. width=math.random(20,100),
  27. groundCollision = false
  28. }
  29.  
  30. function eventNewPlayer(name)
  31. tfm.exec.bindKeyboard(name,32,true,true)
  32. tfm.exec.chatMessage("<VP>Bem-vindo ao Sky run alpha 1.5</VP>",name)
  33. tfm.exec.chatMessage("<ROSE>[~Update] Fundos aleatórios, obstaculos mais difíceis, sistema de recorde, perfil.</ROSE>",name)
  34. tfm.exec.chatMessage("<B><J>Comandos:</J></B><br>!p [nome] - abre o perfil de alguém e sem o nome abre o seu.<br>!rank - abre o ranking.<br>!help - abre a janela de ajuda.",name)
  35. tfm.exec.chatMessage("<J>Criado por Contistente.</J>",name)
  36. eventChatCommand(name,'help')
  37.  
  38. p[name]={
  39. rounds=0,
  40. wins=0,
  41. pm=0,
  42. kills=0,
  43. new_record=0,
  44. old_record=0,
  45. }
  46.  
  47. for i,v in pairs(data) do
  48. if v[1] == name then
  49. p[name] = v[2]
  50. end
  51. end
  52.  
  53. table.insert(data,{name, p[name]})
  54. end
  55.  
  56. function eventKeyboard(name, key, down, x, y)
  57. if key == 32 and time >= 3000 then
  58. if y < 55 then
  59. tfm.exec.giveCheese(name)
  60. tfm.exec.playerVictory(name)
  61. end
  62.  
  63. tfm.exec.movePlayer(name,0,0,false,0,-math.random(30,50),true)
  64.  
  65. end
  66. end
  67.  
  68.  
  69. function split(t,s)
  70. local a={}
  71. for i,v in string.gmatch(t,string.format("[^%s]+",s or "%s")) do
  72. table.insert(a,i)
  73. end
  74. return a
  75. end
  76.  
  77. function eventChatCommand(name, cmd)
  78. local arg = split(cmd, " ")
  79.  
  80. if arg[1] == "help" then
  81. ui.addTextArea(3,"",name,300,45,200,300,nil,0x324650,nil,true)
  82. ui.addTextArea(4,'<B><J><font size="13"><p align="center">Central de ajuda',name,295,40,210,30,nil,0x2e424d,nil,true)
  83. ui.addTextArea(5,"<B><font size='12'>Olá "..name..", o jogo é simplesmente uma Corrida pelos ceús, voe <font color='#00FF00'>apertando espaço</font> até o topo e seja um dos 5° vencedores do jogo<br>!rank - abre o ranking.",name,305,85,190,220,0x0e232b,0x0e232b,nil,true)
  84. ui.addTextArea(6,"<B><p align='center'><font size='15'><R><a href='event:close'>Fechar</a>",name,305,320,190,20,0x3c5063,0x3c5063,nil,true)
  85. end
  86.  
  87. if arg[1] == "p" then
  88. if arg[2] then
  89. nome = arg[2]:lower():gsub('%a', string.upper, 1) -- guarda na variavel
  90. else
  91. nome = name
  92. end
  93.  
  94. if tfm.get.room.playerList[nome] then
  95. ui.addTextArea(0,"",name,250,45,300,300,nil,0x324650,nil,true)
  96. ui.addTextArea(1,'<B><J><font size="13"><p align="center">'..nome,name,245,40,310,30,nil,0x2e424d,nil,true)
  97. ui.addTextArea(2,"<font size='12'>Tribo : <J>"..tfm.get.room.playerList[nome].tribeName.."</J><br>Comunidade : <V>"..tfm.get.room.playerList[nome].community.."</V><br><br><font size='15'>Rato</font><br><font color='#6a7495'> • Rodadas jogadas : </font> <V>"..p[nome].rounds.."</V><br><font color='#6a7495'> • Vitórias : </font> <V>"..p[nome].wins.."</V><br><font color='#6a7495'> • Derrotas : </font> <V>"..p[nome].kills.."</V><br><font color='#6a7495'> • Pontuação máxima : </font> <V>"..p[nome].pm.."</V><br><font color='#6a7495'> • Recorde : </font><br> Novo: <V>"..p[nome].new_record.."</V><BL> | </BL>Antigo: <J>"..p[nome].old_record.."</J>",name,255,85,290,220,0x0e232b,0x0e232b,nil,true)
  98. ui.addTextArea(-1,"<B><p align='center'><font size='15'><R><a href='event:close'>Fechar</a>",name,255,320,290,20,0x3c5063,0x3c5063,nil,true)
  99. else
  100. tfm.exec.chatMessage("<R>"..nome.." não se encostra em sala.</R>",name)
  101. end
  102. end
  103.  
  104. if arg[1] == "rank" then
  105. eventRanking(name)
  106. end
  107. end
  108.  
  109. function scoreBoard()
  110. local sc = {}
  111. for name, player in pairs(tfm.get.room.playerList) do
  112. sc[#sc+1] = {n=name,s=player.score,pm=p[name].pm}
  113. end
  114. table.sort(sc,function(a,b) return a.pm>b.pm end)
  115.  
  116. str = ''
  117. for k,v in pairs(sc) do
  118. if k < 19 then
  119. if str ~= '' then
  120. str=str.."<br><J>"..k.."°</J> | <VP>"..v.n.."</VP> | <R>"..v.pm.."</R>"
  121. else
  122. str="<J>"..k.."°</J> | <VP>"..v.n.."</VP> | <R>"..v.pm.."</R>"
  123. end
  124. end
  125. end
  126.  
  127. ui.addTextArea(0,"",name,250,45,300,300,nil,0x324650,nil,true)
  128. ui.addTextArea(1,'<B><J><font size="13"><p align="center">Score Board',name,245,40,310,30,nil,0x2e424d,nil,true)
  129. ui.addTextArea(2,"<B><font size='12'>"..str,name,255,85,290,255,0x0e232b,0x0e232b,nil,true)
  130. return str
  131. end
  132.  
  133. function eventRanking(name)
  134. local sc = {}
  135. for name, player in pairs(tfm.get.room.playerList) do
  136. sc[#sc+1] = {n=name,s=player.score,w=p[name].wins,pm=p[name].pm}
  137. end
  138.  
  139. table.sort(sc,function(a,b) return a.w>b.w end)
  140.  
  141. str = ''
  142. for k,v in pairs(sc) do
  143. if k < 15 then
  144. if str ~= '' then
  145. str=str.."<br><J>"..k.."°</J> | <VP>"..v.n.."</VP> | <CE>"..v.w.."</CE> | <R>"..v.pm.."</R>"
  146. else
  147. str="<br><J>"..k.."°</J> | <VP>"..v.n.."</VP> | <CE>"..v.w.."</CE> | <R>"..v.pm.."</R>"
  148. end
  149. end
  150. end
  151.  
  152. ui.addTextArea(0,"",name,250,45,300,300,nil,0x324650,nil,true)
  153. ui.addTextArea(1,'<B><J><font size="13"><p align="center">Ranking',name,245,40,310,30,nil,0x2e424d,nil,true)
  154. ui.addTextArea(2,"<B><font size='12'>"..str,name,255,85,290,220,0x0e232b,0x0e232b,nil,true)
  155. ui.addTextArea(-1,"<B><p align='center'><font size='15'><R><a href='event:close'>Fechar</a>",name,255,320,290,20,0x3c5063,0x3c5063,nil,true)
  156. return str
  157. end
  158.  
  159. function eventTextAreaCallback(id,name,link)
  160. if link == "close" then
  161. for id=-1,6 do
  162. ui.removeTextArea(id,name)
  163. ui.removeTextArea(6969+id,name)
  164. ui.removeTextArea(7979+id,name)
  165. end
  166. end
  167. end
  168.  
  169. function eventPlayerWon(name)
  170. if wons < 5 then
  171. wons=wons+1;
  172. tfm.exec.chatMessage("<V>"..name.."</V> venceu em <J>"..wons.."°</J> lugar.")
  173. p[name].wins=p[name].wins+1;
  174. else
  175. for i,v in pairs(tfm.get.room.playerList) do
  176. if v.score < 1 then
  177. p[name].kills = p[name].kills+1;
  178. end
  179. end
  180. end
  181.  
  182. if _time < p[name].new_record then
  183. p[name].old_record = p[name].new_record
  184. p[name].new_record = _time
  185. tfm.exec.chatMessage("<VP>"..name.." bateu o próprio recorde de "..p[name].old_record.."s para "..p[name].new_record.."s.</VP>")
  186. elseif p[name].new_record == 0 then
  187. p[name].new_record = _time
  188. end
  189.  
  190. vivos=vivos-1;
  191.  
  192. if vivos < 4 and tr > 40000 then
  193. tfm.exec.setGameTime(40)
  194. end
  195.  
  196. if vivos == 0 then
  197. tfm.exec.setGameTime(12)
  198. end
  199.  
  200. for i,v in pairs(tfm.get.room.playerList) do
  201. if name == i then
  202. p[i].pm = p[i].pm+v.score
  203. end
  204. end
  205. end
  206.  
  207. function eventLoop(t,r)
  208. time = t
  209. tr = r
  210.  
  211. if t > 3000 then
  212. _time = _time+0.1;
  213. ui.addTextArea(7,"<B><font size='12'><VP>".._time.."s",nil,6,378,nil,20,0,0,0,true)
  214. end
  215.  
  216. if t > 3000 and t < 3500 then
  217. tfm.exec.chatMessage("<VP>Voe apertando espaço até as estrelas e vença a Sky run.</VP>")
  218. end
  219.  
  220. if tempo < os.time()-600 then
  221. piso.dynamic=true
  222.  
  223. for i=1,18 do
  224. type = math.random(18)
  225. if type >= 5 then
  226. piso.restitution = math.random(0.1,1.2)
  227. piso.friction = math.random(0.1,1.2)
  228. piso.color=math.random(0,0xFFFFFF)
  229. piso.width=math.random(20,100)
  230. tfm.exec.addPhysicObject(tempo, math.random(200,600), 25, piso)
  231. else
  232. tfm.exec.addShamanObject(math.random(0,22), math.random(200,600), 25, 180, 0, math.random(0,10), false)
  233. end
  234. end
  235. tempo = os.time();
  236. end
  237.  
  238. if r < 12000 and r > 10000 then
  239. scoreBoard();
  240. end
  241.  
  242. if r < 1000 then
  243. tfm.exec.newGame(xml)
  244. end
  245. end
  246.  
  247. for all in pairs(tfm.get.room.playerList) do
  248. eventNewPlayer(all)
  249. end
  250.  
  251. function eventPlayerDied(name)
  252. vivos=vivos-1;
  253.  
  254. if vivos == 0 then
  255. tfm.exec.setGameTime(12)
  256. end
  257.  
  258. if vivos < 4 and tr > 40000 then
  259. tfm.exec.setGameTime(40)
  260. end
  261. end
  262.  
  263. function eventNewGame()
  264. vivos=0
  265. wons=0
  266. piso.restitution = 0
  267. piso.friction = 0
  268. piso.dynamic = false
  269. piso.width = 1600
  270. piso.color = 0x6a7495
  271. tfm.exec.addPhysicObject(os.time(), 5, 15, piso)
  272. for name in pairs(tfm.get.room.playerList) do
  273. tfm.exec.setPlayerScore(name,0,false)
  274. vivos=vivos+1;
  275. p[name].rounds = p[name].rounds+1;
  276. end
  277.  
  278. tfm.exec.setGameTime(200)
  279.  
  280. for id=-1,2 do
  281. ui.removeTextArea(id,nil)
  282. ui.removeTextArea(6969+id,nil)
  283. ui.removeTextArea(7979+id,nil)
  284. end
  285.  
  286. _time = 0;
  287.  
  288. height = math.random(3000,6000)
  289.  
  290. xml='<C><P H="'..height..'" Ca="" F="'..math.random(0,8)..'" /><Z><S><S H="'..height..'" o="6a7495" L="200" Y="1500" X="700" P="0,0,0,0,0,0,0,0" T="12" N="" /><S H="'..height..'" o="6a7495" L="600" Y="3206" X="900" P="0,0,0,0,0,0,0,0" T="12" N="" /><S H="'..height..'" o="6a7495" L="200" Y="1500" X="100" P="0,0,0,0,0,0,0,0" T="12" N="" /><S H="'..height..'" o="6a7495" L="200" Y="3205" X="100" P="0,0,0,0,0,0,0,0" T="12" N="" /><S X="400" o="212f36" L="400" Y="'..height..'" c="3" H="10" P="0,0,0.3,0.2,0,0,0,0" T="12" /><S H="150" o="6a7495" L="1200" Y="4760" c="4" X="449" P="0,0,0,0,0,0,0,0" T="12" N="" /></S><D><T X="400" Y="'..math.floor(height-10)..'" /></D><O /></Z></C>'
  291. end
  292.  
  293. tfm.exec.newGame(xml)
Advertisement
Add Comment
Please, Sign In to add comment