koreping

Other plugins for extending OpenKore's functionality. This forum is only for posting new plugins and commenting on existing plugins. For support, use the Support forum.

Moderator: Moderators

Message
Author
Thrice
Noob
Noob
Posts: 15
Joined: 24 Dec 2011, 13:05
Noob?: No

koreping

#1 Post by Thrice »

Koreping adds a ping function to openkore.
It lets you dc or relog on a set ping.

Config:

Code: Select all

ping_host www.google.de # you probably want to enter your server ip here
ping_max 300 # Maximum ping you wish the plugin to trigger
ping_quit 0 # If set to 1 openkore will quit once ping is over ping_max
ping_relog 0 # If set to 1 openkore will relog for the duration of ping_relog_time
ping_relog_time 0 # relog time in seconds e.g. 3600 = 1 hour
ping_timeout 30 # timeout between koreping checks the ping
New console command:

Code: Select all

ping
Entering "ping" will display the current ping.

"Could not upload attachment to ./files/28660_bd979425d2f2d8e846ed629603d1cb23." therefore I uploaded it to zippyshare:
http://www65.zippyshare.com/v/99189703/file.html

EternalHarvest
Developers
Developers
Posts: 1798
Joined: 05 Dec 2008, 05:42
Noob?: Yes

Re: koreping

#2 Post by EternalHarvest »

Can be just inlined, not attached:

Code: Select all

########################################################
# This plugin is licensed under the GNU GPL            #
# Copyright 2012 by Thrice                             #
# Contact : - dthrice <AT> *NOSPAM* G*MAIL <DOT> COM   #
#                                                      #
# ---------------------------------------------------- #
# ---------------------------------------------------- #
# koreping.pl       								   #
# Pings server and enables you to dc / relog on 	   #
# high ping                             	   		   #
########################################################
package koreping;

use strict;
use Plugins;
use Log qw(message);
use Globals;
use Misc qw(relog);
use Utils;
use lib $Plugins::current_plugin_folder;
use koreping::External qw(ping);


Plugins::register("koreping", "koreping", \&on_unload, \&on_reload);
my $hook = Plugins::addHook('mainLoop_pre', \&pingcheck, undef);

my $ID = Commands::register(
     ["ping", "pings server", \&cmdPing],
);

sub on_unload {
	Plugins::delHook("mainLoop_pre", $hook);
}
sub on_reload {
	message "koreping, ";
	Plugins::delHook("mainLoop_pre", $hook);
}
my %time;

sub pingcheck {
$time{timeout} = $config{ping_timeout};

	if ($net->getState() == Network::IN_GAME && timeOut(\%time)) {
		my $maxping = $config{ping_max};
		my $host = $config{ping_host};
		my $ping_quit = $config{ping_quit};
		my $ping_relog = $config{ping_relog};
		my $ping_relog_time = $config{ping_relog_time};
		
		my $ping = ping(hostname => $host, count => 1, size => 1024, timeout => 3);
		my @pinged = split / /, $ping;
		
		if ($pinged[-1] >= $maxping) {
		
			if ($ping_quit) {
				message "Quitting due to high ping: $pinged[-1]\n";
				$quit = 1;
			}
			
			elsif ($ping_relog) {
				message "Relogging due to high ping: $pinged[-1]\n";
				relog ($ping_relog_time);
			}
			

			# else { message "I would dc now\n"; }
			
		}
		$time{time} = time;
			
	}
}

sub cmdPing {
	my $host = $config{ping_host};
	my $ping = ping(hostname => $host, count => 1, size => 1024, timeout => 3);
	my @pinged = split / /, $ping;

		message "Ping: $pinged[-1]\n";	
}

1;
However, if ping() call blocks for a while in main loop, it may lead to disconnect or slow reaction to ingame events.

Thrice
Noob
Noob
Posts: 15
Joined: 24 Dec 2011, 13:05
Noob?: No

Re: koreping

#3 Post by Thrice »

Code: Select all

else { message "I would dc now\n"; }
Should be outcommented or deleted (Somehow it didn't save properly).
=>

Code: Select all

# else { message "I would dc now\n"; }
I hope you don't mind changing this in your post, although this is quite a minor mistake.

In addition theres a subfolder containing Ping::External, which is needed by koreping, its included in my zip file.
EternalHarvest wrote: However, if ping() call blocks for a while in main loop, it may lead to disconnect or slow reaction to ingame events.
Any suggestions?

Post Reply