Advertisement
Dudugz-Contistente

Untitled

Dec 11th, 2016
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.42 KB | None | 0 0
  1. mapas = {'<C><P H="4000" Ca="" D="x_transformice/x_maps/x_nonoel_2014/x_cheminee.jpg,200,0" /><Z><S><S H="3000" o="6a7495" L="200" Y="1500" X="700" P="0,0,0,0,0,0,0,0" T="12" N="" /><S H="3000" o="6a7495" L="200" Y="3205" X="700" P="0,0,0,0,0,0,0,0" T="12" N="" /><S H="3000" o="6a7495" L="200" Y="1500" X="100" P="0,0,0,0,0,0,0,0" T="12" N="" /><S H="3000" o="6a7495" L="200" Y="3205" X="100" P="0,0,0,0,0,0,0,0" T="12" N="" /><S H="10" o="3b3b3b" L="401" Y="4000" c="3" X="400" P="0,0,0.3,0.2,0,0,0,0" T="12" /></S><D><T X="402" Y="3998" /></D><O /></Z></C>'}
  2. tempo = os.time();
  3.  
  4. tfm.exec.disableAutoNewGame(true)
  5. tfm.exec.disableAutoShaman(true)
  6. tfm.exec.disableAutoTimeLeft(true)
  7.  
  8. vivos=0
  9. wons=0
  10.  
  11. p={}
  12.  
  13. piso = {
  14. type=12,
  15. color=math.random(0,0xFFFFFF),
  16. linearDamping=1,
  17. angularDamping=1,
  18. dynamic=true,
  19. fixedRotation=true,
  20. width=math.random(20,100),
  21. groundCollision = false
  22. }
  23.  
  24. function eventNewPlayer(name)
  25. tfm.exec.bindKeyboard(name,32,true,true)
  26. tfm.exec.chatMessage("<VP>Bem-vindo ao Sky run alpha 0.6</VP>",name)
  27. tfm.exec.chatMessage("<ROSE>Agora tem mais obstaculos...</ROSE>",name)
  28. tfm.exec.chatMessage("<J>Criado por Contistente.</J>",name)
  29. p[name]={
  30. wins=0
  31. }
  32. end
  33.  
  34. function eventKeyboard(name, key, down, x, y)
  35. if key == 32 and time >= 3000 then
  36. if y < 50 then
  37. tfm.exec.giveCheese(name)
  38. tfm.exec.playerVictory(name)
  39. end
  40.  
  41. tfm.exec.movePlayer(name,0,0,false,0,-math.random(20,25),true)
  42.  
  43. end
  44.  
  45. ui.addTextArea(3,"<B><VP>"..tfm.get.room.playerList[name].y.."m",name,6,25,nil,20,0,0,0,true)
  46. end
  47.  
  48.  
  49. function split(t,s)
  50. local a={}
  51. for i,v in string.gmatch(t,string.format("[^%s]+",s or "%s")) do
  52. table.insert(a,i)
  53. end
  54. return a
  55. end
  56.  
  57. function eventChatCommand(p, cmd)
  58. local arg = split(cmd, " ")
  59.  
  60. if arg[1] == "rank" then
  61. eventRanking(p)
  62. end
  63. end
  64.  
  65. function scoreBoard()
  66. local sc = {}
  67. for name, player in pairs(tfm.get.room.playerList) do
  68. sc[#sc+1] = {n=name,s=player.score}
  69. end
  70. table.sort(sc,function(a,b) return a.s>b.s end)
  71.  
  72. str = ''
  73. for k,v in pairs(sc) do
  74. if k < 15 then
  75. if str ~= '' then
  76. str=str.."<br><J>"..k.."°</J> - <VP>"..v.n.."</VP>"
  77. else
  78. str="<J>"..k.."°</J> - <VP>"..v.n.."</VP>"
  79. end
  80. end
  81. end
  82.  
  83. ui.addTextArea(0,"",name,300,45,200,300,nil,0x324650,nil,true)
  84. ui.addTextArea(1,'<B><J><font size="13"><p align="center">Score Board',name,295,40,210,30,nil,0x2e424d,nil,true)
  85. ui.addTextArea(2,"<B><font size='12'>"..str,name,305,85,190,255,0x0e232b,0x0e232b,nil,true)
  86. return str
  87. end
  88.  
  89. function eventRanking(name)
  90. local sc = {}
  91. for name, player in pairs(tfm.get.room.playerList) do
  92. sc[#sc+1] = {n=name,s=player.score,w=p[name].wins}
  93. end
  94.  
  95. table.sort(sc,function(a,b) return a.s>b.s end)
  96. table.sort(sc,function(a,b) return a.w>b.w end)
  97.  
  98. str = ''
  99. for k,v in pairs(sc) do
  100. if k < 15 then
  101. if str ~= '' then
  102. str=str.."<br><J>"..k.."°</J> - <VP>"..v.n.."</VP>"
  103. else
  104. str="<J>"..k.."°</J> - <VP>"..v.n.."</VP>"
  105. end
  106. end
  107. end
  108.  
  109. ui.addTextArea(0,"",name,300,45,200,300,nil,0x324650,nil,true)
  110. ui.addTextArea(1,'<B><J><font size="13"><p align="center">Ranking',name,295,40,210,30,nil,0x2e424d,nil,true)
  111. ui.addTextArea(2,"<B><font size='12'>"..str,name,305,85,190,220,0x0e232b,0x0e232b,nil,true)
  112. ui.addTextArea(-1,"<B><p align='center'><font size='15'><R><a href='event:close'>Fechar</a>",name,305,320,190,20,0x3c5063,0x3c5063,nil,true)
  113. return str
  114. end
  115.  
  116. function eventTextAreaCallback(id,name,link)
  117. if link == "close" then
  118. for id=-1,2 do
  119. ui.removeTextArea(id,name)
  120. ui.removeTextArea(6969+id,name)
  121. ui.removeTextArea(7979+id,name)
  122. end
  123. end
  124. end
  125.  
  126. function eventPlayerWon(name)
  127. if wons < 3 then
  128. wons=wons+1;
  129. tfm.exec.chatMessage("<V>"..name.."</V> venceu em <J>"..wons.."°</J> lugar.")
  130. p[name].wins=p[name].wins+1;
  131. end
  132.  
  133. vivos=vivos-1;
  134.  
  135. if vivos == 0 then
  136. tfm.exec.setGameTime(15)
  137. end
  138. end
  139.  
  140. function eventLoop(t,r)
  141. time = t
  142. tr = r
  143.  
  144. if t > 3000 and t < 3500 then
  145. tfm.exec.chatMessage("<VP>Vooe apertando espaço até as estrelas e vença a Sky run.</VP>")
  146. end
  147.  
  148. if tempo < os.time()-700 then
  149. piso.dynamic=true
  150.  
  151. for i=1,8 do
  152. type = math.random(15)
  153. if type >= 2 then
  154. tempo = os.time();
  155. piso.color=math.random(0,0xFFFFFF)
  156. piso.width=math.random(20,100)
  157. tfm.exec.addPhysicObject(tempo, math.random(200,600), 25, piso)
  158. else
  159. tfm.exec.addShamanObject(math.random(0,22), math.random(200,600), 25, 180, 0, 0, false)
  160. end
  161. end
  162. end
  163.  
  164. if r < 15000 and r > 14000 then
  165. scoreBoard();
  166. end
  167.  
  168. if r < 1000 then
  169. tfm.exec.newGame(mapas[math.random(#mapas)])
  170. end
  171. end
  172.  
  173. for all in pairs(tfm.get.room.playerList) do
  174. eventNewPlayer(all)
  175. end
  176.  
  177. function eventPlayerDied(name)
  178. vivos=vivos-1;
  179.  
  180. if vivos == 0 then
  181. tfm.exec.setGameTime(15)
  182. end
  183.  
  184. if vivos < 3 and tr > 40000 then
  185. tfm.exec.setGameTime(40)
  186. end
  187. end
  188.  
  189. function eventNewGame()
  190. vivos=0
  191. wons=0
  192. piso.dynamic = false
  193. piso.width = 1600
  194. piso.color = 0x6a7495
  195. tfm.exec.addPhysicObject(os.time(), 5, 15, piso)
  196. for name in pairs(tfm.get.room.playerList) do
  197. ui.addTextArea(3,"<B><VP>"..tfm.get.room.playerList[name].y.."m",name,6,25,nil,20,0,0,0,true)
  198. tfm.exec.setPlayerScore(name,0,false)
  199. vivos=vivos+1;
  200. end
  201.  
  202. tfm.exec.setGameTime(301)
  203.  
  204. for id=0,2 do
  205. ui.removeTextArea(id,nil)
  206. ui.removeTextArea(6969+id,nil)
  207. ui.removeTextArea(7979+id,nil)
  208. end
  209. end
  210.  
  211. tfm.exec.newGame(mapas[math.random(#mapas)])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement