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.
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
########################################################
# 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.