Advertisement
Bolodefchoco_LUAXML

[Function] API

Oct 24th, 2015
484
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.95 KB | None | 0 0
  1. --Creator: Bolodefchoco
  2. --Made in: 24/10/2015
  3. --Last update: 17/05/2016
  4. --[[ Notes:
  5.     Does:
  6.         Uma api ( API() ) que retorna o dado necessário do jogador.
  7.     Args:
  8.         name --> Nome do jogador
  9.         data --> Dados do jogador:
  10.             cheese --> Queijos coletados
  11.             first --> Firsts já conseguidos
  12.             shaman --> Quantas vezes já foi shaman
  13.             rounds --> Rounds já jogados
  14.             easy --> Ratos salvos em EasyMode
  15.             hard --> Ratos salvos em HardMode
  16.             divine --> Ratos salvos em DivineMode
  17.             death --> Mortes
  18.             scheese --> Quantas vezes já pegou o queijo como shaman
  19.             time --> Tempo de jogo
  20. ]]--
  21.  
  22. mice = {}
  23. gcheese = 0
  24.  
  25. eventNewPlayer=function(n)
  26.     if not mice[n] then
  27.         mice[n] = {
  28.             cheese = 0, first = 0, shaman = 0, rounds = 0, easy = 0, hard = 0, divine = 0, death = 0, schesse = 0, time = 0
  29.         }
  30.     end
  31. end
  32. table.foreach(tfm.get.room.playerList,eventNewPlayer)
  33.  
  34. eventNewGame=function()
  35.     gcheese = 0
  36.     for n,v in next,tfm.get.room.playerList do
  37.         mice[n].rounds = mice[n].rounds + 1
  38.         if v.isShaman then
  39.             mice[n].shaman = mice[n].shaman + 1
  40.         end
  41.     end
  42. end
  43.  
  44. eventPlayerWon=function(n)
  45.     mice[n].cheese = mice[n].cheese + 1
  46.     if not tfm.get.room.playerList[n].isShaman then
  47.         gcheese = gcheese + 1
  48.         if gcheese == 1 then
  49.             mice[n].first = mice[n].first + 1
  50.         end
  51.     else
  52.         mice[n].scheese = mice[n].scheese + 1
  53.     end
  54.     for k,v in next,tfm.get.room.playerList do
  55.         if v.isShaman then
  56.             if v.shamanMode == 0 then
  57.                 mice[n].easy = mice[n].easy + 1
  58.             end
  59.             if v.shamanMode == 1 then
  60.                 mice[n].hard = mice[n].hard + 1
  61.             end
  62.             if v.shamanMode == 2 then
  63.                 mice[n].divine = mice[n].divine + 1
  64.             end
  65.         end
  66.     end
  67. end
  68.  
  69. eventPlayerDied=function(n)
  70.     mice[n].death = mice[n].death + 1
  71. end
  72.  
  73. eventLoop=function()
  74.     for n in next,tfm.get.room.playerList do
  75.         mice[n].time = mice[n].time + .5
  76.     end
  77. end
  78.  
  79. API = function(name,data)
  80.     if mice[name] then
  81.         if mice[name][data] then
  82.             return mice[name][data]
  83.         end
  84.     end
  85. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement