Henrybk

zenyLog v1.0

Feb 14th, 2016
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 3.96 KB | None | 0 0
  1. ############################################################
  2. #
  3. # zenyLog
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU General Public License
  7. # as published by the Free Software Foundation; either version 2
  8. # of the License, or (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  18. #
  19. #
  20. # Plugin made by Henrybk from openkore Brasil
  21. #
  22. # What id does: Saves specific information on your zeny income, it
  23. # can save all your zeny income from the skill Steal Coin and items
  24. # sold to npcs and create a log of it.
  25. #
  26. # How to use: Configure your config txt as follows, 1 activates and
  27. # 0 deactivates.
  28. #
  29. # zenyLogStealCoin 1/0 #Saves zeny income of the skill Steal Coin
  30. # zenyLogNpcSell 1/0 #Saves zeny income of items sold to npcs
  31. # zenyLogSaveLog 1/0 #Creates a log on the log directory with the information
  32. #
  33. # To see your log and/or save it you must use the console command 'createZenyLog'.
  34. #
  35. # By Henrybk
  36. #
  37. ############################################################
  38. package zenyLog;
  39.  
  40. use strict;
  41. use Plugins;
  42. use Settings;
  43. use Globals;
  44. use Utils;
  45. use Misc;
  46. use Log qw(message error warning);
  47. use Network;
  48.  
  49. #########
  50. # startup
  51. Plugins::register('zenyLog', 'Creates a detailed zeny log', \&Unload, \&Unload);
  52.  
  53. my $hooks = Plugins::addHooks(
  54.     ['zeny_change',\&on_zeny_change, undef],
  55.     ['packet_pre/sell_result',\&on_sell_result, undef],
  56.     ['packet_pre/skill_used_no_damage',\&on_skill_used_no_damage, undef]
  57. );
  58.  
  59. my $chooks = Commands::register(
  60.     ['createZenyLog', "Creates the zeny log", \&commandHandler]
  61. );
  62.  
  63. my $lastZeny = 0;
  64. my $sellZeny = 0;
  65. my $stealCoinZeny = 0;
  66.  
  67. # onUnload
  68. sub Unload {
  69.     Plugins::delHooks($hooks);
  70.     Commands::unregister($chooks);
  71. }
  72.  
  73. sub on_zeny_change {
  74.     my ($self, $args) = @_;
  75.     if ($args->{change} > 0) {
  76.         $lastZeny = $args->{change};
  77.     }
  78. }
  79.  
  80. sub on_sell_result {
  81.     my ($self, $args) = @_;
  82.     $sellZeny += $lastZeny;
  83.     message "[zenyLog] Zeny added to sell log: $lastZeny\n";
  84.     message "[zenyLog] Total sell log zeny: $sellZeny\n";
  85.     $lastZeny = 0;
  86. }
  87.  
  88. sub on_skill_used_no_damage {
  89.     my ($self, $args) = @_;
  90.     if ($args->{skillID} = 211) {
  91.         $stealCoinZeny += $lastZeny;
  92.         message "[zenyLog] Zeny added to Steal Coin log: $lastZeny\n";
  93.         message "[zenyLog] Total Steal Coin log zeny: $stealCoinZeny\n";
  94.         $lastZeny = 0;
  95.     }
  96. }
  97.  
  98. sub commandHandler {
  99.     my ($endTime_EXP, $w_sec, $sellZenyPerHour, $stealCoinZenyPerHour);
  100.     $endTime_EXP = time;
  101.     $w_sec = int($endTime_EXP - $startTime_EXP);
  102.     message "[zenyLog] createZenyLog called\n";
  103.     if ($config{'zenyLogNpcSell'}) {
  104.         $sellZenyPerHour = int($sellZeny / $w_sec * 3600);
  105.         message "SellZeny: $sellZeny\n".
  106.         "SellZeny/Hour: $sellZenyPerHour\n";
  107.     }
  108.     if ($config{'zenyLogStealCoin'}) {
  109.         $stealCoinZenyPerHour = int($stealCoinZeny / $w_sec * 3600);
  110.         message "StealCoinZeny: $stealCoinZeny\n".
  111.         "StealCoinZeny/Hour: $stealCoinZenyPerHour\n";
  112.     }
  113.     if ($config{'zenyLogSaveLog'}) {
  114.         open(WRITE, ">:utf8", "$Settings::logs_folder/zenyLog.txt");
  115.         print WRITE "[zenyLog] Log of the plugin zenyLog\n".
  116.         "Log of the character: $char->{name}\n".
  117.         "Botting time: ".timeConvert($w_sec)."\n";
  118.         if ($config{'zenyLogNpcSell'}) {
  119.             print WRITE "SellZeny: $sellZeny\n".
  120.             "SellZeny/Hour: $sellZenyPerHour\n";
  121.         }
  122.         if ($config{'zenyLogStealCoin'}) {
  123.             print WRITE "StealCoinZeny: $stealCoinZeny\n".
  124.             "StealCoinZeny/Hour: $stealCoinZenyPerHour\n";
  125.         }
  126.         close(WRITE);
  127.         message "[zenyLog] Info saved to Log File\n";
  128.     }
  129.     message "[zenyLog] end of log\n";
  130. }
  131.  
  132.  
  133.  
  134. return 1;
Advertisement
Add Comment
Please, Sign In to add comment