Advertisement
Eliaseeg

Rank system.

Feb 22nd, 2015
859
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.86 KB | None | 0 0
  1. r2 = {}
  2. mice = {}
  3. rank = false
  4.  
  5. function r2:rank(name)
  6.     scores = {}
  7.     rank = true
  8.     txt="Name\t\t - \t\tScore\n\n"
  9.     table.foreach(mice, function(k, v) table.insert(scores,{name=k,score=v.score}) end)
  10.     table.sort(scores, function(a, b) return a.score>b.score end)
  11.     table.foreachi(scores, function(k, v) txt = txt..""..k..") "..v.name.."\t\t - \t\t"..v.score.."\n" end)
  12.     ui.addTextArea(0, txt, name, 100, 50, 400, 200, 0x191919, 0x191919, 0.6, true)
  13. end
  14.  
  15. _G["eventNewPlayer"]=function(name)
  16.     mice[name] = {
  17.         score = 0,
  18.         rank = r2.rank
  19.     }
  20. end
  21.  
  22. function eventPlayerWon(name)
  23.     mice[name].score = mice[name].score + 1
  24. end
  25.  
  26. function eventChatCommand(name, command)
  27.     if command:lower() == "rank" and not rank then
  28.         mice[name].rank(name)
  29.     else
  30.         ui.removeTextArea(0, name)
  31.         rank = false
  32.     end
  33. end
  34.  
  35. table.foreach(tfm.get.room.playerList,_G["eventNewPlayer"])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement