Tectoon

[TFM] Treinando Racing'

Jun 26th, 2015
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.54 KB | None | 0 0
  1. OBS: Ainda é preciso por uma rotação para por os mapas! ou seja a script ainda esta incompleta.
  2.  
  3. ---------------------------------------------------------------------------------------------------------------------------------
  4.  
  5. data = {games=0}
  6.  
  7. topBar = {
  8.     pos = {
  9.         fg = "<font color='#336600'><b>First</b>: %s</font>",
  10.         bg = "<font color='#FFFFFF'><b>First</b>: %s</font>",
  11.     },
  12.     neg = {
  13.         fg = "<font color='#CC0000'><b>First</b>: %s</font>",
  14.         bg = "<font color='#FFFFFF'><b>First</b>: %s</font>",
  15.     }
  16. }
  17.  
  18. statsMgr = {
  19.     update = function(name)
  20.         x, y = 0, 25
  21.         if data[name].First >= 0 then
  22.             ui.addTextArea(1, string.format(topBar.pos.fg, data[name].First), name, x, y-1, 900, 25, nil, nil, 0, true)
  23.             ui.addTextArea(2, string.format(topBar.pos.fg, data[name].First), name, x, y+1, 900, 25, nil, nil, 0, true)
  24.             ui.addTextArea(3, string.format(topBar.pos.fg, data[name].First), name, x+1, y, 900, 25, nil, nil, 0, true)
  25.             ui.addTextArea(4, string.format(topBar.pos.fg, data[name].First), name, x-1, y, 900, 25, nil, nil, 0, true)
  26.             ui.addTextArea(5, string.format(topBar.pos.bg, data[name].First), name, x, y, 900, 25, nil, nil, 0, true)
  27.         else
  28.             ui.addTextArea(1, string.format(topBar.neg.fg, data[name].First), name, x, y-1, 900, 25, nil, nil, 0, true)
  29.             ui.addTextArea(2, string.format(topBar.neg.fg, data[name].First), name, x, y+1, 900, 25, nil, nil, 0, true)
  30.             ui.addTextArea(3, string.format(topBar.neg.fg, data[name].First), name, x+1, y, 900, 25, nil, nil, 0, true)
  31.             ui.addTextArea(4, string.format(topBar.neg.fg, data[name].First), name, x-1, y, 900, 25, nil, nil, 0, true)
  32.             ui.addTextArea(5, string.format(topBar.neg.bg, data[name].First), name, x, y, 900, 25, nil, nil, 0, true)
  33.         end
  34.         tfm.exec.setPlayerScore(name, data[name].stats, true)
  35.     end
  36. }
  37.  
  38. function main()
  39.     for k,v in pairs(tfm.get.room.playerList) do
  40.         eventNewPlayer(k)
  41.         tfm.exec.setPlayerScore(k, 0, true)
  42.         tfm.exec.newGame("#7")
  43.     end
  44. end
  45.  
  46. function eventLoop(time, remainingtime)
  47.     if tfm.get.room.alive() == 0 and remainingtime <= 0 then
  48.         local currentMap = "#7"
  49.         tfm.exec.newGame(currentMap)
  50.     end
  51. end
  52.  
  53.  
  54. function eventNewGame()
  55.     data.games = data.games + 1
  56.     if tfm.get.room.xmlMapInf then
  57.         mapcode = tfm.get.room.xmlMapInfo.mapCode or "0"
  58.     else
  59.         mapcode = "0, 5"
  60.     end
  61. end
  62.  
  63. function eventNewPlayer(name)
  64.     tbl = {First=0,stats=0}
  65.     data[name] = tbl
  66.     statsMgr.update(name)
  67. end
  68.  
  69. function eventPlayerWon(name)
  70.     if tfm.get.room.alive() == 0 then
  71.         local currentMap = maps[math.random(#maps)]
  72.         tfm.exec.newGame(currentMap)
  73.     end
  74.     data[name].First = data[name].First + 1
  75.     data[name].stats = data[name].stats + 1
  76.     statsMgr.update(name)
  77. end
  78.  
  79. function eventPlayerDied(name)
  80.     data[name].First = data[name].First - 1
  81.     data[name].stats = data[name].stats - 1
  82.     statsMgr.update(name)
  83.     if tfm.get.room.alive() == 0 then
  84.         local currentMap = '#7'
  85.         tfm.exec.newGame(currentMap)
  86.     end
  87. end
  88.  
  89. function eventPlayerGotCheese(name)
  90.     data[name].First = data[name].First + 0.5
  91.     statsMgr.update(name)
  92. end
  93.  
  94. function tfm.get.room.alive()
  95.     local alivePlayers={}
  96.     for name,player in pairs(tfm.get.room.playerList) do
  97.         if not player.isDead then
  98.             table.insert(alivePlayers, name)
  99.         end
  100.     end
  101.     return alivePlayers
  102. end
  103.  
  104. main()
Advertisement
Add Comment
Please, Sign In to add comment