Advertisement
Eliaseeg

Sistema de estadísticas y perfiles.

Jun 7th, 2014
504
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.96 KB | None | 0 0
  1. local data = {}
  2.  
  3. function eventNewPlayer(name)
  4.   if not data[name] then
  5.     data[name]={}
  6.     data[name].puntos = 0
  7.     data[name].muertes = 0
  8.  end
  9. end
  10.  
  11. for i, command in ipairs ({"perfil","p","stats","profile"}) do
  12.   system.disableChatCommandDisplay(command,true)
  13. end
  14.  
  15. for name, player in pairs(tfm.get.room.playerList) do
  16.   eventNewPlayer(name)
  17. end
  18.  
  19. function eventPlayerDied(name)
  20.   data[name].muertes = data[name].muertes+1
  21.   print(name.." ha muerto, ahora tiene "..data[name].muertes.." muertes")
  22. end
  23.  
  24. function eventPlayerWon(name)
  25.   data[name].puntos = data[name].puntos+1
  26.   print(name.." ha conseguido un queso, ahora tiene "..data[name].puntos.." puntos")
  27. end
  28.  
  29. function eventTextAreaCallback(id,name,cb)
  30.   if cb=='cperfil' then
  31.     removePerfil(name)
  32.   end
  33. end
  34.  
  35. function eventChatCommand(name,command)
  36. local args={}
  37.  for word in command:gmatch("[^%s]+") do
  38.   table.insert(args, word)
  39.  end
  40.   if args[1] == "stats" or args[1] == "perfil" or args[1] == "p" or args[1]=="profile" and data[capitalize(args[2])] then
  41.     getPerfil(capitalize(args[2]), name)
  42.   end
  43. end
  44.  
  45. function getPerfil(n,to)
  46.   ui.addTextArea(2,"<font size='13'><br><bl>• Puntos: <g>"..data[n].puntos.."<br><bl>• Muertes: <g>"..data[n].muertes.."",to,300,120,260,nil,0x324650,0x324650,nil,true)
  47.   ui.addTextArea(3,"<font size='17'><v>Perfil: <n>"..n.."",to,300,100,260,nil,0x1C3C41,0x1C3C41,nil,true)
  48.   ui.addTextArea(4,"",to,543,104,13,13,0x009D9D,0x009D9D,nil,true)
  49.   ui.addTextArea(5,"<font size='15' color='#1C3C41'><b><a href='event:cperfil'>X",to,542,99,nil,nil,"0","0",nil,true)
  50. end
  51.  
  52. function removePerfil(name)
  53.   ui.removeTextArea(2,name)
  54.   ui.removeTextArea(3,name)
  55.   ui.removeTextArea(4,name)
  56.   ui.removeTextArea(5,name)
  57. end
  58.  
  59. function capitalize(word)
  60.   if word then
  61.     if word:find("+") then  
  62.       return string.upper(word:sub(1,2)) .. string.lower (word:sub(3));
  63.     else
  64.       return string.upper(word:sub(1,1)) .. string.lower (word:sub(2));
  65.     end
  66.   end
  67. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement