Advertisement
Sayd

Untitled

Mar 10th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. package AvoidReset;
  2.  
  3. use encoding "utf8";
  4. use strict;
  5. use Log qw(message);
  6. use Globals qw($net %timeout);
  7.  
  8. my $dc = 0;
  9. my $max_dc = 10;
  10. my $timeout = {timeout => 3600};
  11.  
  12.  
  13. Plugins::register("AvoidReset", "disconnect count", \&unload);
  14.  
  15.  
  16. my $hooks = Plugins::addHooks(
  17. ['disconnected', \&disconnect, undef]
  18.  
  19. );
  20.  
  21. my $cmd = Commands::register(
  22. ['dc','disconnect infos',\&dcInfo],
  23. ['AI_pre', \&reseting, undef],
  24. );
  25.  
  26.  
  27. sub unload {
  28. Plugins::delHooks($hooks);
  29. Commands::unregister($cmd);
  30. undef $hooks;
  31. undef $cmd;
  32. }
  33.  
  34. sub dcInfo {
  35. my (undef, $args) = @_;
  36.  
  37. if ($args eq 'count') {
  38. message("[plugin:AvoidReset] VocΓͺ foi desconectado ".$dc." vez(es).\n","info");
  39. }
  40. }
  41.  
  42. sub disconnect {
  43. $dc ++;
  44. if ($dc < $max_dc) {
  45. message "[AvoidReset] O contador estΓ‘ atualmente em $dc.\n";
  46. } else {
  47. message "[AvoidReset] Deslogando por levar muitos dcs em 1 hora.\n";
  48. Misc::offlineMode();
  49. }
  50. }
  51.  
  52. sub reseting {
  53. return if $net->getState != Network::IN_GAME;
  54. return if !timeOut( $timeout );
  55. $timeout->{time} = time;
  56. message "[AvoidReset] Resetando Contador.\n";
  57. $dc = 0;
  58. }
  59. 1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement