Advertisement
Xlyjc

RatoBird

Dec 26th, 2017
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.44 KB | None | 0 0
  1.  
  2. ui.addPopup(0, 0, "RatoBird V1 \nVoe com E ou seta para baixo\nTente voar com o queijo e chegar na toca\n By Xlyjc\n", nil, 0, 162, 788, true)
  3. ui.addTextArea(0, "Enjoy by Xlyjc", nil, 690, 370, 100, 20, 0x000000, 0xff00dd, 1, true)
  4. function eventNewPlayer(name)
  5. for i,key in ipairs({83,40,69}) do
  6. tfm.exec.bindKeyboard(name,key,true,true)
  7. end
  8. end
  9.  
  10. function eventKeyboard(name,key,down,x,y)
  11. if key==83 or key==40 or key==69 then
  12. tfm.exec.movePlayer(name,0,0,true,0,-50,true)
  13. end
  14. end
  15.  
  16. for name,player in pairs(tfm.get.room.playerList) do
  17. eventNewPlayer(name)
  18. end
  19.  
  20. print("Voe E ou seta para baixo by Xlyjc!")
  21.  
  22. --[[
  23. COMO INICIAR?
  24. Copie todo o Script e siga as instruções que vão aparecer no chat #lua
  25.  
  26. COMANDOS:
  27. !game Jogador1 Jogador2 - INICIA NOVO JOGO
  28. !score Jogador Ponto - MUDA A PONTUAÇAO DO JOGADOR
  29. !pause Jogador - PAUSA O TEMPO, VOCÊ PODE MUDAR O TEMPO MAXIMO EM _MAIN.config.pauseDelay, PARA DESPAUSAR UTILIZE O COMANDO NOVAMENTE
  30. !chola - RSRSRSRSRSRSRSRS
  31. !bb
  32.  
  33. BOM JOGO!
  34. ]]--
  35.  
  36. _MAIN = {
  37. admins = {Xlyjc = true},
  38. participants = {},
  39. command = "",
  40. config = {
  41. win = 2,
  42. difference = 0,
  43. lowerTime = 10,
  44. paused = false,
  45. canShowScore = false,
  46. pauseDelay = 120,
  47. mapid = 1,
  48. lastfirst = "",
  49. invertedGame = "",
  50. },
  51. maps = {"@7340839","@7340893"},
  52. }
  53.  
  54. _MESSAGES = {
  55. newGame = "<p align=\"center\"><font size=\"46\" color=\"#FFF10F\" face=\"Crazy Krabs\">Nova Partida!</font><BR><font size=\"18\" color=\"#F700FF\" face=\"Crazy Krabs\">%s!</font></p>",
  56. score = "<p align=\"center\"><font size=\"16\" color=\"#FFFFFF\" face=\"Verdana\">| %s</font></p>",
  57. paused = "<p align=\"center\"><font size=\"14\" color=\"#FFFFFF\">Jogo pausado para %s</font></p>",
  58. unpaused = "<p align=\"center\"><font size=\"14\" color=\"#FFFFFF\">Jogo retomado para %s</font></p>",
  59. pausedInfo = "<p align=\"left\"><font size=\"12\" color=\"#FFFFFF\">%s</font></p>",
  60. timeUp = "<p align=\"center\"><font size=\"46\" color=\"#FFFFFF\">Tempo esgotado para %s!</font></p>",
  61. timeCanceled = "<p align=\"center\"><font size=\"46\" color=\"#FFFFFF\">TEMPO RETOMADO!</font><BR><font size=\"14\" color=\"#FFFFFF\" face=\"Verdana\">Reiniciando jogo no próximo mapa!</font></p>",
  62. first = "<p align=\"center\"><font size=\"46\" color=\"#0100FF\" face=\"Crazy Krabs\">%s GG!</font></p>",
  63. newScore = "<p align=\"left\"><font size=\"14\" color=\"#FFFFFF\">Pontuação de %s mudada para %s</font></p>",
  64. gameWon = "<p align=\"center\"><font size=\"36\" color=\"#FFF10F\" face=\"Crazy Krabs\">Acabou! %s ganhou!</font><br><font size=\"14\" color=\"#FFF10F\" face=\"Crazy Krabs\">GG %s! %s</font></p>",
  65. }
  66.  
  67. _ROUND = {
  68. place = 0,
  69. counter = 0,
  70. lastfirst = {}
  71. }
  72.  
  73. _UI = {
  74. windows = {}
  75. }
  76.  
  77. function string.split(rawString, separator)
  78. splittedString = {}
  79. for str in string.gmatch(rawString, "[^"..separator.."]+") do
  80. table.insert(splittedString, str)
  81. end
  82. return splittedString
  83. end
  84.  
  85. function string.title(rawString)
  86. allWords = string.split(rawString, " ")
  87. for index, word in pairs(allWords) do
  88. allWords[index] = string.gsub(string.lower(word), "%a", string.upper, 1)
  89. end
  90. return table.concat(allWords, " ")
  91. end
  92.  
  93. function string.startswith(rawString, toCompare)
  94. return (string.sub(rawString, 0, string.len(toCompare)) == toCompare)
  95. end
  96.  
  97. function string.getsubstring(rawString, toSub)
  98. return (string.sub(rawString, string.len(toSub)))
  99. end
  100.  
  101. function _UI.updateScore()
  102. scoreString = ""
  103. if not _MAIN.config.paused then
  104. for player, data in pairs(_MAIN.participants) do
  105. scoreString = string.format("%s jogador: <font color=\"#0010FF\">%s:</font> <font color=\"#0010FF\">%s</font> /", scoreString, player, data.pontuation)
  106. end
  107. else
  108. scoreString = "<font color=\"#FFFFFF\">PAUSADO</font> /"
  109. end
  110. _UI.createWindow(2, string.format(_MESSAGES.score, scoreString), nil, 0, 20, 800, nil, true, os.time())
  111. end
  112.  
  113. function _UI.createWindow(id, text, affected, positionX, positionY, width, height, fixed, lifeTime)
  114. blackText = string.gsub(text, "color=\"[0-9A-Za-z#]+\"", "color=\"#000000\"")
  115. ui.addTextArea(id*10, blackText, affected, positionX-1, positionY, width, height, 0, 0, 0, fixed)
  116. ui.addTextArea(id*100, blackText, affected, positionX+1, positionY, width, height, 0, 0, 0, fixed)
  117. ui.addTextArea(id*1000, blackText, affected, positionX, positionY-1, width, height, 0, 0, 0, fixed)
  118. ui.addTextArea(id*10000, blackText, affected, positionX, positionY+1, width, height, 0, 0, 0, fixed)
  119. ui.addTextArea(id*100000, text, affected, positionX, positionY, width, height, 0, 0, 0, fixed)
  120. _UI.windows[id] = {spawn = os.time(), id = id, life = lifeTime*1000}
  121. end
  122.  
  123. function table.shuffle(rawTable)
  124. local iterations = #rawTable
  125. local j
  126. for i = iterations, 2, -1 do
  127. j = math.random(i)
  128. rawTable[i], rawTable[j] = rawTable[j], rawTable[i]
  129. end
  130. return rawTable
  131. end
  132.  
  133. function _MAIN.checkPauses()
  134. pauses = 0
  135. for player, data in pairs(_MAIN.participants) do
  136. if data.paused then
  137. pauses = pauses+1
  138. end
  139. end
  140. return pauses
  141. end
  142.  
  143. function _MAIN.chooseNewGame()
  144. _MAIN.config.mapid = _MAIN.config.mapid+1
  145. if _MAIN.config.mapid > #_MAIN.maps then
  146. _MAIN.config.mapid = 1
  147. end
  148. tfm.exec.newGame(_MAIN.maps[_MAIN.config.mapid])
  149. end
  150.  
  151. function _MAIN.getScoreDifference(player)
  152. local diff = 0
  153. local points = _MAIN.participants[player].pontuation
  154. for name, data in pairs(_MAIN.participants) do
  155. if name ~= player then
  156. diff = diff+data.pontuation
  157. end
  158. end
  159. return points-diff
  160. end
  161.  
  162. function eventLoop(timeElapsed, timeRemain)
  163. timeRemain = math.ceil(timeRemain/1000)
  164. if _MAIN.config.started then
  165. if timeRemain <= 1 then
  166. _MAIN.chooseNewGame()
  167. end
  168. end
  169.  
  170. for index, window in pairs(_UI.windows) do
  171. if window.spawn < os.time()-window.life then
  172. for _, multiplier in pairs({10, 100, 1000, 10000, 100000}) do
  173. ui.removeTextArea(window.id*multiplier)
  174. end
  175. window = nil
  176. end
  177. if window and window.id and window.id == 8 then
  178. for i = 80, 0, -1 do
  179. ids = {31, 32}--{0, 1, 2, 9, 11, 13}
  180. tfm.exec.displayParticle(ids[math.random(#ids)], math.random(200, 600), math.random(180, 240), math.random(-0.11, 0.11), math.random(-0.11, 0.11), math.random(-0.11, 0.11), math.random(-0.11, 0.11))
  181. end
  182. end
  183. end
  184.  
  185. if _MAIN.config.paused then
  186. text = ""
  187. for player, data in pairs(_MAIN.participants) do
  188. if data.paused then
  189. decorredTime = math.ceil((os.time()-data.paused)/1000)--(_MAIN.config.pauseDelay*1000)
  190. timeMin = (_MAIN.config.pauseDelay)-decorredTime
  191. timeFormat = string.format("%.2d:%.2d:%.2d", timeMin/(60*60), timeMin/60%60, timeMin%60)
  192. text = text..player..": "..timeFormat.."\n"
  193. if timeMin < 0 then
  194. data.paused = false
  195. _UI.createWindow(3, string.format(_MESSAGES.timeUp, player), nil, 0, 160, 800, nil, true, 5)
  196. _UI.updateScore()
  197. end
  198. end
  199. end
  200. _UI.createWindow(4, string.format(_MESSAGES.pausedInfo, text), nil, 0, 140, 800, nil, true, 1)
  201. if _MAIN.checkPauses() == 0 then
  202. _MAIN.config.paused = false
  203. _UI.createWindow(3, _MESSAGES.timeCanceled, nil, 0, 160, 800, nil, true, 3)
  204. tfm.exec.setGameTime(3)
  205. end
  206. end
  207. end
  208.  
  209. function eventPlayerWon(player, timeElapsed)
  210. if _MAIN.participants[player] then
  211. if _MAIN.config.lastfirst == player then
  212. _MAIN.participants[player].firstsLine = _MAIN.participants[player].firstsLine+1
  213. else
  214. if _MAIN.participants[_MAIN.config.lastfirst] then
  215. if _MAIN.participants[_MAIN.config.lastfirst].firstsLine >= _MAIN.config.win/2 then
  216. _MAIN.config.invertedGame = player
  217. end
  218. _MAIN.participants[_MAIN.config.lastfirst].firstsLine = 0
  219. end
  220. _MAIN.config.lastfirst = player
  221. end
  222.  
  223. if not _MAIN.config.paused then
  224. _ROUND.place = _ROUND.place+1
  225. if _ROUND.place == 1 then
  226. tfm.exec.setGameTime(5)
  227. _MAIN.participants[player].pontuation = _MAIN.participants[player].pontuation+1
  228. local difference = _MAIN.getScoreDifference(player)
  229. _UI.createWindow(3, string.format(_MESSAGES.first, player), nil, 0, 180, 800, nil, true, 5)
  230. if _MAIN.participants[player].pontuation >= _MAIN.config.win and _MAIN.getScoreDifference(player) >= _MAIN.config.difference then
  231. specialMessage = string.format("Voador %s! ", _MAIN.participants[_MAIN.config.lastfirst].firstsLine)
  232. if _MAIN.getScoreDifference(player) == 0 then
  233. specialMessage = string.format("%s Muito Bom!", specialMessage)
  234. elseif _MAIN.getScoreDifference(player) == 1 then
  235. specialMessage = string.format("%s Ratinho voador", specialMessage)
  236. end
  237. if _MAIN.config.invertedGame == player then
  238. specialMessage = string.format("%s GG MAN!", specialMessage)
  239. end
  240. print(difference)
  241. _UI.createWindow(3, string.format(_MESSAGES.gameWon, player, difference, specialMessage), nil, 0, 160, 800, nil, true, 20)
  242. _MAIN.participants = {}
  243. end
  244. end
  245. end
  246. end
  247. _UI.updateScore()
  248. end
  249.  
  250. function eventNewGame()
  251. _ROUND.place = 0
  252. _UI.updateScore()
  253. if _MAIN.config.started then
  254. tfm.exec.setGameTime(60)
  255. end
  256. end
  257.  
  258. function eventChatCommand(player, command)
  259. if command == _MAIN.command then
  260. _MAIN.admins[player] = true
  261. _MAIN.command = tostring(math.random())
  262. _UI.createWindow(4, string.format("<font color=\"#FFFFFF\">%s script pronto para uso", player), nil, 10, 380, 800, nil, true, 5)
  263. end
  264.  
  265. if _MAIN.admins[player] then
  266. if string.startswith(command, "game") then
  267. toPlay = string.split(string.title(string.getsubstring(command, "game ")), " ")
  268. _MAIN.participants = {}
  269. for index, player in pairs(toPlay) do
  270. if tfm.get.room.playerList[player] then
  271. _MAIN.participants[player] = {pontuation = 0, paused = false, firstsLine = 0}
  272. toPlay[index] = string.format("<font color=\"#30BA76\">%s</font>", player)
  273. else
  274. toPlay[index] = string.format("<font color=\"#FFFFFF\">%s</font>", player)
  275. end
  276. if toPlay[index] then
  277. if player == "Gecs" then
  278. toPlay[index] = "<font color=\"#30BA76\">Gecs <font size=\"9\">nooba</font></font>"
  279. end
  280. end
  281. end
  282. _MAIN.config.canShowScore = true
  283. _MAIN.config.started = true
  284. _UI.updateScore()
  285. tfm.exec.disableAutoNewGame(true)
  286. tfm.exec.disableAutoShaman(true)
  287. tfm.exec.setGameTime(3)
  288. _MAIN.maps = table.shuffle(_MAIN.maps)
  289. _UI.createWindow(1, string.format(_MESSAGES.newGame, table.concat(toPlay, " vs ")), nil, 0, 160, 800, nil, true, 5)
  290.  
  291. elseif string.startswith(command, "score") then
  292. toScore = string.split(string.title(string.getsubstring(command, "score ")), " ")
  293. if _MAIN.participants[toScore[1]] then
  294. if tonumber(toScore[2]) then
  295. _MAIN.participants[toScore[1]].pontuation = tonumber(toScore[2])
  296. _UI.createWindow(4, string.format(_MESSAGES.newScore, toScore[1], toScore[2]), nil, 10, 380, 800, nil, true, 5)
  297. end
  298. end
  299. _UI.updateScore()
  300.  
  301. elseif string.startswith(command, "chola") then
  302. _UI.createWindow(8, "<p align=\"center\"><font color=\"#FFFFFF\" size=\"40\">CHOLA MAIS", nil, 0, 180, 800, nil, true, 5)
  303. elseif string.startswith(command, "bb") then
  304. _UI.createWindow(8, "<p align=\"center\"><font color=\"#F100FF\" size=\"40\">BB!", nil, 0, 180, 800, nil, true, 5)
  305. elseif string.startswith(command, "brabo") then
  306. _UI.createWindow(8, "<p align=\"center\"><font color=\"#F100FF\" size=\"40\">EU TO BRABO", nil, 0, 180, 800, nil, true, 5)
  307. elseif string.startswith(command, "gjuo") then
  308. _UI.createWindow(8, "<p align=\"center\"><font color=\"#FF0B00\" size=\"40\">Modo Flash Ativado = Gjuo kkk", nil, 0, 180, 800, nil, true, 5)
  309. elseif string.startswith(command, "maluco") then
  310. _UI.createWindow(8, "<p align=\"center\"><font color=\"#FFFFFF\" size=\"40\">MALUCO E BRABO", nil, 0, 180, 800, nil, true, 5)
  311.  
  312. elseif string.startswith(command, "pause") then
  313. toPause = string.title(string.getsubstring(command, "pause "))
  314. if _MAIN.participants[toPause] then
  315. if not _MAIN.participants[toPause].paused then
  316. _MAIN.config.paused = true
  317. _MAIN.participants[toPause].paused = os.time()
  318. _UI.createWindow(6, string.format(_MESSAGES.paused, toPause), nil, 0, 380, 800, nil, true, 3)
  319. else
  320. _MAIN.participants[toPause].paused = false
  321. _UI.createWindow(6, string.format(_MESSAGES.unpaused, toPause), nil, 0, 380, 800, nil, true, 3)
  322. end
  323. end
  324. _UI.updateScore()
  325. end
  326. end
  327. end
  328.  
  329. _MAIN.command = string.format("%x", math.random(0x000000, 0xFFFFFFF)..math.random(0x000000, 0xFFFFFFF))
  330. _UI.createWindow(6, "<p align=\"center\"><font size=\"36\" color=\"#0100FF\" face=\"Sweetpaint\">RatoBird !</font><br><font size=\"18\" color=\"#F700FF\" face=\"DOCK11\">AQUELE RATOBIRD QUE VOCE RESPEITA</font></p>", nil, 0, 180, 800, nil, true, 7)
  331. print(string.format("<R>Digite esse comando !%s para poder usar os comandos do RatoBird - Comandos de textarea:!bb-!chola-!brabo-!gjuo-!maluco", _MAIN.command))
  332. system.disableChatCommandDisplay(_MAIN.command)
  333. system.disableChatCommandDisplay("chola")
  334. system.disableChatCommandDisplay("bb")
  335. system.disableChatCommandDisplay("brabo")
  336. system.disableChatCommandDisplay("gjuo")
  337. system.disableChatCommandDisplay("maluco")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement