Loading the plugin, kore goes...
Code: Select all
Loading all plugins...
Loading plugin plugins/cartsell.pl...
This plugin cannot be loaded because of a problem in the plugin. Please notify
the plugin's author about this problem, or remove the plugin so OpenKore can
start.
The error message is:
Press ENTER to exit this program.
Here's my source code:
Code: Select all
package CartSell;
use strict;
use Globals;
use Log qw(message error);
use Utils;
use Network::Send;
use Misc;
use AI;
use AI::Corelogic;
use Translation;
Plugins::register('autocartsell', 'Sell items from cart', \&unload);
#my $hooks = Plugins::addHooks(['AI_pre', \&AI_hook]);
my $commandsID = Commands::register(["autocartsell", "Sell items from cart", \&cmdCartSell]);
my $cartSearch;
sub unload {
#Plugins::delHooks($hooks);
Commands::unregister($commandsID);
}
sub cmdCartSell {
my @getItems;
my @sellItems;
my $args = AI::args;
$args->{cartNextItem} = 0 unless $args->{cartNextItem};
for (my $i = $args->{cartNextItem}; $i < @{$cart{inventory}}; $i++) {
my $item = $cart{inventory}[$i];
next unless ($item && %{$item});
my $control = items_control($item->{name});
if ($control->{'sell'} && $item->{'amount'} > $control->{keep}) {
if ($args->{cartLastIndex} == $item->{index} &&
timeOut($timeout{'ai_sellAuto_giveup'})) {
return;
} elsif ($args->{cartLastIndex} != $item->{index}) {
$timeout{ai_sellAuto_giveup}{time} = time;
}
undef $args->{done};
$args->{cartLastIndex} = $item->{index};
my %cartObj;
$cartObj{index} = $i;
my $amount = $item->{amount} - $control->{keep};
$cartObj{amount} = $amount;
push @getItems, \%cartObj;
cartGet(\@getItems);
$timeout{ai_sellAuto}{time} = time;
$args->{cartNextItem} = $i + 1;
if ($char->{weight} > 89) {
processAutoSell();
$i = $i - 1;
}
}
}
}
Idea is that Kore should get items from cart until he goes overweight 90%, then Kore would do go autosell.
What's wrong with it or is it wrong as a whole. I removed $hooks though.