Advertisement
VANPER

Code Online Time

Feb 6th, 2020
1,425
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.65 KB | None | 0 0
  1. Index: java/net/sf/l2j/Config.java
  2. ===================================================================
  3. --- java/net/sf/l2j/Config.java (revision 84)
  4. +++ java/net/sf/l2j/Config.java (working copy)
  5. @@ -1281,6 +1281,10 @@
  6.  
  7. +   public static int ID_REWARD;
  8. +   public static int MIN_PVP;
  9.  
  10.  
  11. +       ID_REWARD = players.getProperty("IdReward", 57);
  12. +       MIN_PVP = players.getProperty("MinPvp", 200);
  13.  
  14. ===================================================================
  15. --- java/net/sf/l2j/gameserver/handler/IUserCommandHandler.java (revision 84)
  16. +++ java/net/sf/l2j/gameserver/handler/IUserCommandHandler.java (working copy)
  17. @@ -25,6 +25,7 @@
  18.  
  19. +   import net.sf.l2j.gameserver.handler.usercommandhandlers.SocialTime;
  20.  
  21.  
  22. -   registerHandler(new Loc());
  23. +   registerHandler(new Loc());
  24. +   registerHandler(new SocialTime());
  25.  
  26. ===================================================================
  27. --- java/net.sf.l2j.gameserver.model.actor.Player.java  (revision 84)
  28. +++ java/net.sf.l2j.gameserver.model.actor.Player.java  (working copy)
  29. @@ -2448,6 +2448,11 @@
  30.  
  31. +   public long getOnlineTime()
  32. +   {
  33. +       return _onlineTime;
  34. +   }
  35.  
  36. ===================================================================
  37. --- java/net/sf/l2j/gameserver/handler/usercommandhandlers/SocialTime.java  (revision 0)
  38. +++ java/net/sf/l2j/gameserver/handler/usercommandhandlers/SocialTime.java  (working copy)
  39. @@ -0,0 +1,84 @@
  40.  
  41.  
  42. +   package net.sf.l2j.gameserver.handler.usercommandhandlers;
  43. +  
  44. +   import java.math.BigDecimal;
  45. +  
  46. +   import net.sf.l2j.Config;
  47. +   import net.sf.l2j.gameserver.handler.IUserCommandHandler;
  48. +   import net.sf.l2j.gameserver.model.actor.Player;
  49. +  
  50. +       /**
  51. +       * @author Juvenil Walker
  52. +       *
  53. +       */
  54. +   public class SocialTime implements IUserCommandHandler
  55. +   {
  56. +       private static final int[] COMMAND_IDS =
  57. +       {
  58. +           120,121
  59. +       };
  60. +      
  61. +       @Override
  62. +       public void useUserCommand(int id, Player activeChar)
  63. +       {
  64. +           int _calcule = (int) arredondaValor(1, activeChar.getOnlineTime() / 3600);
  65. +  
  66. +           if (id == 120)
  67. +           {
  68. +               if ((_calcule >= 1) && (activeChar.getPvpKills() >= Config.MIN_PVP))
  69. +               {
  70. +                   activeChar.addItem("Coins", Config.ID_REWARD, _calcule, activeChar, true);
  71. +                   activeChar.setOnlineTime(0);
  72. +               }
  73. +               else
  74. +               {
  75. +                   if (activeChar.getPvpKills() < Config.MIN_PVP)
  76. +                       activeChar.sendMessage("Você precisa de "+ Config.MIN_PVP +" pvp para prosseguir com a troca. Você só tem " + activeChar.getPvpKills() + " PvP'S");
  77. +                  
  78. +                   if (_calcule < 1)
  79. +                       activeChar.sendMessage("Você não tem 1 hora online agora.");
  80. +               }
  81. +           }
  82. +           else if(id == 121)
  83. +           {
  84. +               if (_calcule >= 1)
  85. +                   activeChar.sendMessage("Você tem atualmente "+ _calcule +" horas online.");
  86. +               else  if (_calcule < 1)
  87. +                   activeChar.sendMessage("Você tem atualmente " + activeChar.getOnlineTime() / 60 + " minutos online.");
  88. +           }
  89. +          
  90. +           return;
  91. +       }
  92. +  
  93. +  
  94. +       public double arredondaValor(int casasDecimais, double valor)
  95. +       {
  96. +           return new BigDecimal(valor).setScale(casasDecimais, 3).doubleValue();
  97. +       }
  98. +      
  99. +       @Override
  100. +       public int[] getUserCommandList()
  101. +       {
  102. +           return COMMAND_IDS;
  103. +       }
  104. +   }
  105.  
  106. ===================================================================
  107. --- java/net/sf/l2j/gameserver/config/player.propriet   (revision 0)
  108. +++ java/net/sf/l2j/gameserver/config/player.propriet   (working copy)
  109. @@ -0,0 +1,84 @@
  110.  
  111.  
  112. +   #============================================
  113. +   #        /tempo_online  /trocar_tempo
  114. +   #============================================
  115. +   IdReward = 57
  116. +   MinPvp = 200
  117.  
  118. ===================================================================
  119. +++ System/commandname-e.dat
  120. @@ -0,0 +1,84 @@
  121.  
  122. +   120 121 tempo_online
  123.  
  124.  
  125. +   121 120 trocar_tempo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement