Advertisement
Guest User

Untitled

a guest
Mar 1st, 2015
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.72 KB | None | 0 0
  1.  
  2.  
  3. baseXML = [[
  4. <C><P DS="y;90" Ca="" /><Z><S><S P="0,0,9999,0.2,0,0,0,0" L="800" o="0" H="10" v="3000" Y="110" T="12" X="400" /><S L="800" o="fffffffff" H="10" X="400" v="3000" Y="70" T="12" P="0,0,9999,0.2,0,0,0,0" /><S P="0,0,9999,0.2,0,0,0,0" L="50" o="0" X="400" Y="-200" T="12" H="10" /><S L="50" o="0" X="400" H="10" Y="-240" T="12" P="0,0,9999,0.2,0,0,0,0" /><S P="0,0,9999,0.2,90,0,0,0" L="50" o="0" H="10" Y="-220" T="12" X="430" /><S L="50" o="0" H="10" X="370" Y="-220" T="12" P="0,0,9999,0.2,90,0,0,0" /></S><D><DS Y="90" X="400" /></D><O /></Z></C>
  5. ]]
  6. tfm.exec.disableAfkDeath(true)
  7. tfm.exec.disableAutoShaman(true)
  8. tfm.exec.disableAutoNewGame(true)
  9. tfm.exec.disableAutoScore(true)
  10. tfm.exec.disableAutoTimeLeft(true)
  11. system.disableChatCommandDisplay("afk")
  12. maps = {"@4535536","@4535536","@4533657","@4535757","@4535960","@4537526","@4537526","@4537526","@4537528","@4537632"}
  13. players = {}
  14. afk = {}
  15. spawnFrequency = 1
  16. spiritFrequency = 4
  17. cannonFrequency = 5
  18. delayUnfrequency = 5
  19. spiritTime = 20
  20. cannonTime = 40
  21. lang = {}
  22. lang.fr = {
  23. info = "Bubbles !",
  24. afk = "<N>Estas<J>AFK<N>.¿Estas de vuelta? Escribe : <ROSE>!afk<N>."
  25. }
  26. lang.en = {
  27. info = "Bubbles !",
  28. afk = "<N>Estas <J>AFK<N>. ¿Estas de vuelta? Escribe : <ROSE>!afk<N>."
  29. }
  30.  
  31. text = lang.fr
  32.  
  33. timer = {
  34. start = 0,
  35. frequence = 0,
  36. unfrequence = 0
  37. }
  38.  
  39. bubbles = {}
  40.  
  41. function eventNewGame()
  42. bubbles = {}
  43. players = {}
  44. spawnFrequency = 0.5
  45.  
  46. for timerName,value in pairs(timer) do
  47. timer[timerName] = 0
  48. end
  49.  
  50. for n,p in pairs(tfm.get.room.playerList) do
  51. table.insert(players, n)
  52. end
  53.  
  54. local bestPlayer = bestPlayer()
  55. tfm.exec.setUIMapName("<PT>"..text.info.." <font color='#60608F'>|</font> <N>!Maestro Bubble : <VP>"..bestPlayer)
  56.  
  57. for _,p in pairs(players) do
  58. if afk[p] then
  59. tfm.exec.movePlayer(p, 400, -200, false, 0, 0, false)
  60. else
  61. tfm.exec.movePlayer(p, math.random(100, 700), 90, false, 0, 0, false)
  62. end
  63. end
  64.  
  65. showAfk()
  66. end
  67.  
  68. function eventNewPlayer(playerName)
  69. table.insert(players, playerName)
  70. afk[playerName] = false
  71. end
  72.  
  73. function eventPlayerLeft(playerName)
  74. local toRemove = 0
  75.  
  76. for i,p in pairs(players) do
  77. if p==playerName then
  78. toRemove = i
  79. end
  80. end
  81.  
  82. table.remove(players, toRemove)
  83. afk[playerName] = false
  84. end
  85.  
  86. function eventPlayerDied(playerName)
  87. if #players > 1 then
  88. local alive = 0
  89. local pname = ""
  90.  
  91. for _,p in pairs(players) do
  92. if not tfm.get.room.playerList[p].isDead and not afk[p] and tfm.get.room.playerList[p].y > 0 then
  93. alive = alive + 1
  94. pname = p
  95. end
  96. end
  97.  
  98. if alive == 1 then
  99. tfm.exec.giveCheese(pname)
  100. tfm.exec.playerVictory(pname)
  101. tfm.exec.setGameTime(5)
  102. elseif alive == 0 then
  103. newGame()
  104. end
  105. else
  106. newGame()
  107. end
  108. end
  109.  
  110. function eventPlayerWon(playerName)
  111. if playerName == bestPlayer() then
  112. tfm.exec.setPlayerScore(playerName, 5, true)
  113. else
  114. tfm.exec.setPlayerScore(playerName, 16, true)
  115. end
  116. end
  117.  
  118. function eventLoop(currentTime, timeRemaining)
  119. timer.start = timer.start + 0.5
  120.  
  121. if timeRemaining <= 0 then
  122. for _,p in pairs(players) do
  123. if not tfm.get.room.playerList[p].isDead and not afk[p] then
  124. tfm.exec.giveCheese(p)
  125. tfm.exec.playerVictory(p)
  126. end
  127. end
  128.  
  129. newGame()
  130. end
  131.  
  132. if timer.start > 40 and (timer.start % 52) == 0 and tfm.get.room.currentMap == "@4537632" then
  133. tfm.exec.snow()
  134. end
  135.  
  136. if timer.start > spiritTime then
  137. if (timer.start % spiritFrequency) == 0 then
  138. local nbAfk = math.random(#bubbles)
  139. local target = bubbles[nbAfk]
  140.  
  141. tfm.exec.addShamanObject(24, tfm.get.room.objectList[target].x, tfm.get.room.objectList[target].y, 0, 0, 0, false)
  142. tfm.exec.removeObject(target)
  143. table.remove(bubbles, nbAfk)
  144. end
  145. end
  146.  
  147. if timer.start > cannonTime then
  148. if (timer.start % cannonFrequency) == 0 then
  149. tfm.exec.addShamanObject(18, math.random(30, 770), 20, 0, 0, 75, false)
  150. end
  151. end
  152.  
  153. for _,p in pairs(players) do
  154. if not tfm.get.room.playerList[p].isDead then
  155. if tfm.get.room.playerList[p].x < 0 or tfm.get.room.playerList[p].x > 800 or tfm.get.room.playerList[p].y < 10 then
  156. if tfm.get.room.playerList[p].y > -150 then
  157. tfm.exec.movePlayer(p, 400, 500, false, 0, 0, false)
  158. end
  159. end
  160. end
  161. end
  162.  
  163. timer.frequence = timer.frequence + 0.5
  164.  
  165. if timer.frequence >= spawnFrequency then
  166. timer.frequence = 0
  167.  
  168. timer.unfrequence = timer.unfrequence + 0.5
  169.  
  170. if timer.unfrequence == delayUnfrequency and spawnFrequency < 2 then
  171. timer.unfrequence = 0
  172. spawnFrequency = spawnFrequency + 0.5
  173. end
  174.  
  175. spawnBubble()
  176. end
  177.  
  178. for i,id in pairs(bubbles)do
  179. if tfm.get.room.objectList[id] and tfm.get.room.objectList[id].y<=20 then
  180. tfm.exec.removeObject(id)
  181. table.remove(bubbles, i)
  182. end
  183. end
  184. end
  185.  
  186. function eventChatCommand(playerName, message)
  187. if message == "afk" and timer.start > 3 then
  188. toggleAfk(playerName)
  189. end
  190. end
  191.  
  192. function toggleAfk(playerName)
  193. for p,v in pairs(afk) do
  194. if p == playerName then
  195. if v then
  196. afk[p] = false
  197.  
  198. if #players == 1 then
  199. newGame()
  200. else
  201. local diff = 0
  202.  
  203. for p,v in pairs(afk) do
  204. if v then
  205. diff = diff + 1
  206. end
  207. end
  208.  
  209. if #players - diff == 1 then
  210. newGame()
  211. end
  212. end
  213. else
  214. afk[p] = true
  215. tfm.exec.movePlayer(p, 400, -200, false, 0, 0, false)
  216.  
  217. if #players > 1 then
  218. local alive = 0
  219. local pname = ""
  220.  
  221. for _,p in pairs(players) do
  222. if not tfm.get.room.playerList[p].isDead and not afk[p] and tfm.get.room.playerList[p].y > 0 then
  223. alive = alive + 1
  224. pname = p
  225. end
  226. end
  227.  
  228. if alive == 1 then
  229. tfm.exec.giveCheese(pname)
  230. tfm.exec.playerVictory(pname)
  231. tfm.exec.setGameTime(5)
  232. elseif alive == 0 then
  233. newGame()
  234. end
  235. else
  236. newGame()
  237. end
  238. end
  239. end
  240. end
  241.  
  242. showAfk()
  243. end
  244.  
  245. function showAfk()
  246. local nbAfk = 0
  247. local nbNonAfk = 0
  248. local nbPreAfk = 0
  249. local message = ""
  250.  
  251. while nbAfk <= #players do
  252. ui.removeTextArea(nbAfk)
  253. nbAfk = nbAfk + 1
  254. end
  255.  
  256. while nbNonAfk <= #players do
  257. ui.removeTextArea(nbNonAfk)
  258. nbNonAfk = nbNonAfk + 1
  259. end
  260.  
  261. nbAfk = 0
  262. nbNonAfk = 0
  263.  
  264. for p,v in pairs(afk) do
  265. if v then nbPreAfk = nbPreAfk + 1 end
  266. end
  267.  
  268. for p,v in pairs(afk) do
  269. if v then
  270. ui.addTextArea(nbAfk, "<p align='center'>"..text.afk.."</p>", p, 0, 22, 800, 20, 0x010101, 0x010101, 0.7f)
  271.  
  272. nbAfk = nbAfk + 1
  273.  
  274. if nbAfk == nbPreAfk then
  275. if nbAfk == 1 then
  276. message = message.."<J>"..p.."<N> est AFK."
  277. else
  278. message = message.."<N>et <J>"..p.."<N> sont AFK."
  279. end
  280. else
  281. message = message.."<J>"..p.."<N>, "
  282. end
  283. end
  284. end
  285.  
  286. for p,v in pairs(afk) do
  287. if not v and nbAfk > 0 then
  288. ui.addTextArea(nbNonAfk, "<p align='center'>"..message.."</p>", p, 0, 22, 800, 20, 0x010101, 0x010101, 0.7f)
  289.  
  290. nbNonAfk = nbNonAfk + 1
  291. end
  292. end
  293. end
  294.  
  295. function spawnBubble()
  296. local id
  297. id = tfm.exec.addShamanObject(59, math.random(30, 770), 400, 0, 0, 0, false)
  298. table.insert(bubbles, id)
  299. end
  300.  
  301. function newGame()
  302. local map = tfm.get.room.currentMap
  303.  
  304. if map == "@4537632" then -- Map neige
  305. tfm.exec.snow()
  306. end
  307.  
  308. if #maps > 1 then
  309. while map == tfm.get.room.currentMap do
  310. map = maps[math.random(#maps)]
  311. end
  312. else
  313. map = maps[math.random(#maps)]
  314. end
  315.  
  316. tfm.exec.newGame(map)
  317.  
  318. if map == "@4537632" then -- Map neige
  319. tfm.exec.snow()
  320. end
  321. end
  322.  
  323. function bestPlayer()
  324. local topScore = 16
  325. local bestPlayer = "-"
  326.  
  327. for name,player in pairs(tfm.get.room.playerList) do
  328. if player.score >= topScore then
  329. topScore = player.score
  330. bestPlayer = name
  331. end
  332. end
  333.  
  334. return bestPlayer
  335. end
  336.  
  337. for name,player in pairs(tfm.get.room.playerList) do
  338. tfm.exec.setPlayerScore(name, 0, false)
  339. afk[name] = false
  340. end
  341.  
  342. newGame()
  343. -- Fréquence de spawn des boulets
  344. cannonFrequency = 5
  345.  
  346. -- Nombre de secondes avant que la fréquence de spawn des bulles ne baisse
  347. delayUnfrequency = 5
  348.  
  349. -- Nombre de secondes avant que les esprits n'apparaîssent
  350. spiritTime = 20
  351.  
  352. -- Nombre de secondes avant que les boulets n'apparaissent
  353. cannonTime = 40
  354.  
  355. lang = {}
  356.  
  357. lang.fr = {
  358. info = "Bubbles !",
  359. afk = "<N>!Estas<J>AFK<N>.¿Estas de vuelta? Escribe : <ROSE>!afk<N>."
  360. }
  361.  
  362. lang.en = {
  363. info = "Bubbles !",
  364. afk = "<N>Estas <J>AFK<N>. Escribe : <ROSE>!afk<N> para volver a modo normal."
  365. }
  366.  
  367. text = lang.fr
  368.  
  369. timer = {
  370. start = 0,
  371. frequence = 0,
  372. unfrequence = 0
  373. }
  374.  
  375. bubbles = {}
  376.  
  377. function eventNewGame()
  378. bubbles = {}
  379. players = {}
  380. spawnFrequency = 0.5
  381.  
  382. for timerName,value in pairs(timer) do
  383. timer[timerName] = 0
  384. end
  385.  
  386. for n,p in pairs(tfm.get.room.playerList) do
  387. table.insert(players, n)
  388. end
  389.  
  390. local bestPlayer = bestPlayer()
  391. tfm.exec.setUIMapName("<PT>"..text.info.." <font color='#60608F'>|</font> <N>!Maestro bubble : <VP>"..bestPlayer)
  392.  
  393. for _,p in pairs(players) do
  394. if afk[p] then
  395. tfm.exec.movePlayer(p, 400, -200, false, 0, 0, false)
  396. else
  397. tfm.exec.movePlayer(p, math.random(100, 700), 90, false, 0, 0, false)
  398. end
  399. end
  400.  
  401. showAfk()
  402. end
  403.  
  404. function eventNewPlayer(playerName)
  405. table.insert(players, playerName)
  406. afk[playerName] = false
  407. end
  408.  
  409. function eventPlayerLeft(playerName)
  410. local toRemove = 0
  411.  
  412. for i,p in pairs(players) do
  413. if p==playerName then
  414. toRemove = i
  415. end
  416. end
  417.  
  418. table.remove(players, toRemove)
  419. afk[playerName] = false
  420. end
  421.  
  422. function eventPlayerDied(playerName)
  423. if #players > 1 then
  424. local alive = 0
  425. local pname = ""
  426.  
  427. for _,p in pairs(players) do
  428. if not tfm.get.room.playerList[p].isDead and not afk[p] and tfm.get.room.playerList[p].y > 0 then
  429. alive = alive + 1
  430. pname = p
  431. end
  432. end
  433.  
  434. if alive == 1 then
  435. tfm.exec.giveCheese(pname)
  436. tfm.exec.playerVictory(pname)
  437. tfm.exec.setGameTime(5)
  438. elseif alive == 0 then
  439. newGame()
  440. end
  441. else
  442. newGame()
  443. end
  444. end
  445.  
  446. function eventPlayerWon(playerName)
  447. if playerName == bestPlayer() then
  448. tfm.exec.setPlayerScore(playerName, 5, true)
  449. else
  450. tfm.exec.setPlayerScore(playerName, 16, true)
  451. end
  452. end
  453.  
  454. function eventLoop(currentTime, timeRemaining)
  455. timer.start = timer.start + 0.5
  456.  
  457. if timeRemaining <= 0 then
  458. for _,p in pairs(players) do
  459. if not tfm.get.room.playerList[p].isDead and not afk[p] then
  460. tfm.exec.giveCheese(p)
  461. tfm.exec.playerVictory(p)
  462. end
  463. end
  464.  
  465. newGame()
  466. end
  467.  
  468. if timer.start > 40 and (timer.start % 52) == 0 and tfm.get.room.currentMap == "@4537632" then
  469. tfm.exec.snow()
  470. end
  471.  
  472. if timer.start > spiritTime then
  473. if (timer.start % spiritFrequency) == 0 then
  474. local nbAfk = math.random(#bubbles)
  475. local target = bubbles[nbAfk]
  476.  
  477. tfm.exec.addShamanObject(24, tfm.get.room.objectList[target].x, tfm.get.room.objectList[target].y, 0, 0, 0, false)
  478. tfm.exec.removeObject(target)
  479. table.remove(bubbles, nbAfk)
  480. end
  481. end
  482.  
  483. if timer.start > cannonTime then
  484. if (timer.start % cannonFrequency) == 0 then
  485. tfm.exec.addShamanObject(18, math.random(30, 770), 20, 0, 0, 75, false)
  486. end
  487. end
  488.  
  489. for _,p in pairs(players) do
  490. if not tfm.get.room.playerList[p].isDead then
  491. if tfm.get.room.playerList[p].x < 0 or tfm.get.room.playerList[p].x > 800 or tfm.get.room.playerList[p].y < 10 then
  492. if tfm.get.room.playerList[p].y > -150 then
  493. tfm.exec.movePlayer(p, 400, 500, false, 0, 0, false)
  494. end
  495. end
  496. end
  497. end
  498.  
  499. timer.frequence = timer.frequence + 0.5
  500.  
  501. if timer.frequence >= spawnFrequency then
  502. timer.frequence = 0
  503.  
  504. timer.unfrequence = timer.unfrequence + 0.5
  505.  
  506. if timer.unfrequence == delayUnfrequency and spawnFrequency < 2 then
  507. timer.unfrequence = 0
  508. spawnFrequency = spawnFrequency + 0.5
  509. end
  510.  
  511. spawnBubble()
  512. end
  513.  
  514. for i,id in pairs(bubbles)do
  515. if tfm.get.room.objectList[id] and tfm.get.room.objectList[id].y<=20 then
  516. tfm.exec.removeObject(id)
  517. table.remove(bubbles, i)
  518. end
  519. end
  520. end
  521.  
  522. function eventChatCommand(playerName, message)
  523. if message == "afk" and timer.start > 3 then
  524. toggleAfk(playerName)
  525. end
  526. end
  527.  
  528. function toggleAfk(playerName)
  529. for p,v in pairs(afk) do
  530. if p == playerName then
  531. if v then
  532. afk[p] = false
  533.  
  534. if #players == 1 then
  535. newGame()
  536. else
  537. local diff = 0
  538.  
  539. for p,v in pairs(afk) do
  540. if v then
  541. diff = diff + 1
  542. end
  543. end
  544.  
  545. if #players - diff == 1 then
  546. newGame()
  547. end
  548. end
  549. else
  550. afk[p] = true
  551. tfm.exec.movePlayer(p, 400, -200, false, 0, 0, false)
  552.  
  553. if #players > 1 then
  554. local alive = 0
  555. local pname = ""
  556.  
  557. for _,p in pairs(players) do
  558. if not tfm.get.room.playerList[p].isDead and not afk[p] and tfm.get.room.playerList[p].y > 0 then
  559. alive = alive + 1
  560. pname = p
  561. end
  562. end
  563.  
  564. if alive == 1 then
  565. tfm.exec.giveCheese(pname)
  566. tfm.exec.playerVictory(pname)
  567. tfm.exec.setGameTime(5)
  568. elseif alive == 0 then
  569. newGame()
  570. end
  571. else
  572. newGame()
  573. end
  574. end
  575. end
  576. end
  577.  
  578. showAfk()
  579. end
  580.  
  581. function showAfk()
  582. local nbAfk = 0
  583. local nbNonAfk = 0
  584. local nbPreAfk = 0
  585. local message = ""
  586.  
  587. while nbAfk <= #players do
  588. ui.removeTextArea(nbAfk)
  589. nbAfk = nbAfk + 1
  590. end
  591.  
  592. while nbNonAfk <= #players do
  593. ui.removeTextArea(nbNonAfk)
  594. nbNonAfk = nbNonAfk + 1
  595. end
  596.  
  597. nbAfk = 0
  598. nbNonAfk = 0
  599.  
  600. for p,v in pairs(afk) do
  601. if v then nbPreAfk = nbPreAfk + 1 end
  602. end
  603.  
  604. for p,v in pairs(afk) do
  605. if v then
  606. ui.addTextArea(nbAfk, "<p align='center'>"..text.afk.."</p>", p, 0, 22, 800, 20, 0x010101, 0x010101, 0.7f)
  607.  
  608. nbAfk = nbAfk + 1
  609.  
  610. if nbAfk == nbPreAfk then
  611. if nbAfk == 1 then
  612. message = message.."<J>"..p.."<N> est AFK."
  613. else
  614. message = message.."<N>et <J>"..p.."<N> sont AFK."
  615. end
  616. else
  617. message = message.."<J>"..p.."<N>, "
  618. end
  619. end
  620. end
  621.  
  622. for p,v in pairs(afk) do
  623. if not v and nbAfk > 0 then
  624. ui.addTextArea(nbNonAfk, "<p align='center'>"..message.."</p>", p, 0, 22, 800, 20, 0x010101, 0x010101, 0.7f)
  625.  
  626. nbNonAfk = nbNonAfk + 1
  627. end
  628. end
  629. end
  630.  
  631. function spawnBubble()
  632. local id
  633. id = tfm.exec.addShamanObject(59, math.random(30, 770), 400, 0, 0, 0, false)
  634. table.insert(bubbles, id)
  635. end
  636.  
  637. function newGame()
  638. local map = tfm.get.room.currentMap
  639.  
  640. if map == "@4537632" then -- Map neige
  641. tfm.exec.snow()
  642. end
  643.  
  644. if #maps > 1 then
  645. while map == tfm.get.room.currentMap do
  646. map = maps[math.random(#maps)]
  647. end
  648. else
  649. map = maps[math.random(#maps)]
  650. end
  651.  
  652. tfm.exec.newGame(map)
  653.  
  654. if map == "@4537632" then -- Map neige
  655. tfm.exec.snow()
  656. end
  657. end
  658.  
  659. function bestPlayer()
  660. local topScore = 16
  661. local bestPlayer = "-"
  662.  
  663. for name,player in pairs(tfm.get.room.playerList) do
  664. if player.score >= topScore then
  665. topScore = player.score
  666. bestPlayer = name
  667. end
  668. end
  669.  
  670. return bestPlayer
  671. end
  672.  
  673. for name,player in pairs(tfm.get.room.playerList) do
  674. tfm.exec.setPlayerScore(name, 0, false)
  675. afk[name] = false
  676. end
  677.  
  678. newGame()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement