Advertisement
Guest User

[Musugas] tutorial de títulos

a guest
Sep 14th, 2014
381
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.98 KB | None | 0 0
  1. local data = {}
  2. local titles = {"Noob","Pro","Divino","Cool"}
  3. local numerodewins = {1,2,3}
  4.  
  5. function eventNewPlayer(name)
  6.   if not data[name] then
  7.     data[name]={}
  8.     data[name].puntos = 0
  9.     data[name].muertes = 0
  10. data[name].title = 1
  11. data[name].titles = {1}
  12.  end
  13. end
  14.  
  15. for i, command in ipairs ({"perfil","p","stats","profile"}) do
  16.   system.disableChatCommandDisplay(command,true)
  17. end
  18.  
  19. for name, player in pairs(tfm.get.room.playerList) do
  20.   eventNewPlayer(name)
  21. end
  22.  
  23. function eventPlayerDied(name)
  24.   data[name].muertes = data[name].muertes+1
  25.   print(name.." ha muerto, ahora tiene "..data[name].muertes.." muertes")
  26. end
  27.  
  28. function eventPlayerWon(name)
  29.   data[name].puntos = data[name].puntos+1
  30. desbloquearT(name)
  31.   print(name.." ha conseguido un queso, ahora tiene "..data[name].puntos.." puntos")
  32. end
  33.  
  34. function eventTextAreaCallback(id,name,cb)
  35.   if cb=='cperfil' then
  36.     removePerfil(name)
  37.   end
  38. end
  39.  
  40. function eventChatCommand(name,command)
  41. local args={}
  42.  for word in command:gmatch("[^%s]+") do
  43.   table.insert(args, word)
  44.  end
  45.   if args[1] == "stats" or args[1] == "perfil" or args[1] == "p" or args[1]=="profile" and data[capitalize(args[2])] then
  46.     getPerfil(capitalize(args[2]), name)  
  47.  elseif args[1] == "title" then
  48.         changeTitle(args[2], name)
  49.   end
  50. end
  51.  
  52. function getPerfil(n,to)
  53.   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)
  54.   ui.addTextArea(3,"<font size='17'><v>Perfil: <n>"..n.."",to,300,100,260,nil,0x1C3C41,0x1C3C41,nil,true)
  55.   ui.addTextArea(4,"",to,543,104,13,13,0x009D9D,0x009D9D,nil,true)
  56.   ui.addTextArea(5,"<font size='15' color='#1C3C41'><b><a href='event:cperfil'>X",to,542,99,nil,nil,"0","0",nil,true)
  57. end
  58.  
  59. function removePerfil(name)
  60.   ui.removeTextArea(2,name)
  61.   ui.removeTextArea(3,name)
  62.   ui.removeTextArea(4,name)
  63.   ui.removeTextArea(5,name)
  64. end
  65.  
  66. function capitalize(word)
  67.   if word then
  68.     if word:find("+") then  
  69.       return string.upper(word:sub(1,2)) .. string.lower (word:sub(3));
  70.     else
  71.       return string.upper(word:sub(1,1)) .. string.lower (word:sub(2));
  72.     end
  73.   end
  74. end
  75.  
  76.  
  77. function desbloquearT(n)
  78. for i,ulo in ipairs(numerodewins) do
  79. if data[n].puntos==ulo then
  80. til = #data[n].titles + 1  
  81. table.insert(data[n].titles, til)  
  82. ui.addPopup(0, 0, "<VP>Has desbloqueado un nuevo título! <font color='#db186d'>"..titles[til].."</font> (<font color='#BABD2F'>!title "..til.."</font>)",n, 300, 175, nil)
  83.  
  84. end
  85. end
  86. end
  87.  
  88. function have(x,tabla)
  89. for _,objetc in pairs(tabla) do
  90. if objetc == x then return true end
  91. end
  92. return false
  93. end
  94.  
  95.  
  96. function changeTitle(change, playerName)
  97.  
  98. if have(tonumber(change),data[playerName].titles) then
  99.  
  100. data[playerName].title = tonumber(change)  
  101. ui.addPopup(0, 0, "<VP>Ahora tienes el título: <J>"..titles[tonumber(change)].." <VP>", playerName,300, 175, nil)
  102. else
  103. ui.addPopup(0, 0, "<n>No tienes ese título :(",playerName, 300, 175, nil)
  104.  
  105. end
  106.  
  107. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement