autotrade.pl
Moderators: waferbaron, Moderators
Forum rules
This server is currently not maintained and tables folder (including connection info) is outdated. Read the wiki for instructions on how to update those information. Please contribute your updated info. Contact Cozzie to join the team as a regular server supporter.
This server is currently not maintained and tables folder (including connection info) is outdated. Read the wiki for instructions on how to update those information. Please contribute your updated info. Contact Cozzie to join the team as a regular server supporter.
-
- Noob
- Posts: 8
- Joined: 30 Oct 2010, 12:00
- Noob?: Yes
autotrade.pl
can anyone provide a copy of autotrade plugin?.. thx
-
- Noob
- Posts: 8
- Joined: 30 Oct 2010, 12:00
- Noob?: Yes
Re: autotrade.pl
is this forum alive?
-
- Noob
- Posts: 8
- Joined: 30 Oct 2010, 12:00
- Noob?: Yes
Re: autotrade.pl
hello.. i've found this autotrade.pl.. but it has a problem.. it kept saying undefined subroutine after dealing the bot..
hope anyone help.. O.o

Code: Select all
package autoTrade;
#ported from messykorexp by Joseph
#original code by systeman
use strict;
use Globals;
use Log qw(message warning error debug);
use AI;
use Misc;
use Network::Send;
use Utils;
Plugins::register('autoTrade', 'automated chat room dealing', \&Unload);
my $hook1 = Plugins::addHook('AI_pre', \&call);
my $hook2 = Plugins::addHook('parseMsg/pre', \&packet);
# load table file
our %trade_lut;
my $file = "$Settings::control_folder/autotrade.txt";
my $cfID = "$Settings::addConfigFile($file,\%trade_lut,\&FileParsers::parseDataFile_lc)";
"$Settings::load($cfID)";
undef $file;
sub Unload {
Plugins::delHook('AI_pre', $hook1);
Plugins::delHook('parseMsg/pre', $hook2);
Settings::delConfigFile($cfID);
}
my $dealTrade;
my $dealFinalize;
my $tradeDealAddItem;
my $itemAddTimeout;
# TIMEOUTS: you can change these if you want
# time to wait for them to add items before cancelling?
my $itemWaitTime = 10;
# time to wait before accepting deal request?
my $dealAcceptTime = 2;
# time to wait before adding zeny once they finalize their item choices?
my $zenyAddDelay = 2;
sub packet {
my $hookName = shift;
my $args = shift;
my $switch = $args->{switch};
my $msg = $args->{msg};
if ($switch eq "00E9") {
my $amount = unpack("L1", substr($msg, 2,4));
my $ID = unpack("S1", substr($msg, 6,2));
if ($ID > 0) {
# they added an item, so reset the timeout
$tradeDealAddItem = 1;
}
}
if ($switch eq "01F4") {
#deal request, wait before accepting
$itemAddTimeout = time;
}
if ($switch eq "00E5" || $switch eq "01F4") {
#deal request, wait before accepting
$itemAddTimeout = time;
}
if ($switch eq "00EC") {
my $type = unpack("C1", substr($msg, 2, 1));
if ($type == 1) {
#they finalize their item selections
$itemAddTimeout = time;
}
}
}
sub call {
AUTOTRADE: {
if (AI::is("","tradeAuto", "deal") && $config{tradeAuto} && $char->{skills}{NV_BASIC}{lv} > 4) {
if (AI::action ne "tradeAuto" && AI::action ne "deal" && $::currentChatRoom ne "") {
message "Begin auto-trade mode.\n", "autoTrade";
if ($config{dealAuto}) {
$config{dealAuto} = 0;
Misc::configModify("dealAuto", $config{dealAuto});
}
AI::queue("tradeAuto");
}
last AUTOTRADE if !AI::is("tradeAuto","deal");
if (Utils::timeOut($itemAddTimeout,$dealAcceptTime) && $::incomingDeal{name} && !$::currentDeal{name}) {
Network::Send::sendDealAccept(\$remote_socket);
undef $dealFinalize;
undef $dealTrade;
$itemAddTimeout = time;
message "Sent deal accept, begin trading\n", "autoTrade";
}
last AUTOTRADE if (!$::currentDeal{name});
if (!Utils::timeOut($itemAddTimeout,$itemWaitTime) && $tradeDealAddItem) {
$itemAddTimeout = time;
undef $tradeDealAddItem;
}
if (($::currentDeal{other_finalize} && Utils::timeOut($itemAddTimeout,$zenyAddDelay)) || Utils::timeOut($itemAddTimeout,$itemWaitTime)) {
if ($::currentDeal{other} eq ()) {
message "Other person didn't add any items, cancelling...\n", "autoTrade";
Network::Send::sendCurrentDealCancel(\$remote_socket);
$itemAddTimeout = time;
} elsif (!$dealFinalize) {
my $sumvalue;
my @currentDealOther;
foreach (keys %{$::currentDeal{other}}) {
push @currentDealOther, $_;
}
my $max = @currentDealOther;
for (my $i = 0;$i < $max;$i++) {
my $found = 0;
my $ID = $currentDealOther[$i];
my $name = lc main::itemName($::currentDeal{other}{$ID});
if (defined $trade_lut{$name}) {
message "Add ".$trade_lut{$name}."z x $::currentDeal{other}{$ID}{amount} to deal\n", "autoTrade";
$sumvalue += ($::currentDeal{other}{$ID}{amount} * $trade_lut{$name});
} else {
message "Other person added item which is not in buy list, cancelling...\n", "autoTrade";
Network::Send::sendCurrentDealCancel(\$remote_socket);
last AUTOTRADE;
}
}
message "Trading $sumvalue zeny and confirming\n", "autoTrade";
Network::Send::sendDealAddItem(\$remote_socket, 0, $sumvalue);
sleep(0.5);
Network::Send::sendDealFinalize(\$remote_socket);
$dealFinalize = 1;
$itemAddTimeout = time;
}
}
if ($::currentDeal{you_finalize} && Utils::timeOut($itemAddTimeout,$itemWaitTime)) {
message "Other person didn't accept the final trade, cancelling...\n", "autoTrade";
Network::Send::sendCurrentDealCancel(\$remote_socket);
$itemAddTimeout = time;
}
if (!$dealTrade && $::currentDeal{you_finalize} && $::currentDeal{other_finalize}) {
message "Accepting final trade\n", "autoTrade";
Network::Send::sendDealTrade(\$remote_socket);
$dealTrade = 1;
}
}
}
}
return 1;
-
- Noob
- Posts: 8
- Joined: 30 Oct 2010, 12:00
- Noob?: Yes
Re: autotrade.pl
bump*************
-
- Developers
- Posts: 1798
- Joined: 05 Dec 2008, 05:42
- Noob?: Yes
Re: autotrade.pl
Use sendDealReply(3) instead of sendDealAccept.
It seems like there is no old sendDeal functions in kRO serverType, you can look up changes in serverType0 where they're still left as interface to new ones.
It seems like there is no old sendDeal functions in kRO serverType, you can look up changes in serverType0 where they're still left as interface to new ones.
-
- Noob
- Posts: 8
- Joined: 30 Oct 2010, 12:00
- Noob?: Yes
Re: autotrade.pl
still not working
-
- Developers
- Posts: 1798
- Joined: 05 Dec 2008, 05:42
- Noob?: Yes
Re: autotrade.pl
See also porting plugins from 1.6 in the wiki.Network::Send::sendDealAccept(\$remote_socket);
-
- Plain Yogurt
- Posts: 52
- Joined: 16 Jan 2011, 03:06
- Noob?: Yes
Re: autotrade.pl
hi, i've tested this plugin in OpenKore version what-will-become-2.1
and i also got the same error.
change
to?
error.txt
and i also got the same error.
what do you mean by this?EternalHarvest wrote:Use sendDealReply(3) instead of sendDealAccept.
change
Code: Select all
Network::Send::sendDealAccept(\$remote_socket);
Code: Select all
Network::Send::sendDealReply(3)(\$remote_socket);
error.txt
Code: Select all
Died at this line:
if (Utils::timeOut($itemAddTimeout,$dealAcceptTime) && $::incomingDeal{name} && !$::currentDeal{name}) {
* Network::Send::sendDealAccept(\$remote_socket);
undef $dealFinalize;
-
- Moderators
- Posts: 403
- Joined: 25 Aug 2008, 14:56
- Noob?: No
- Location: CyberOne Building , Eastwood
Re: autotrade.pl
“The moon shines to both guilty and innocent alike..”
The Openkore Manual---Global Forum Rules--The Template
The Openkore Manual---Global Forum Rules--The Template
-
- Plain Yogurt
- Posts: 52
- Joined: 16 Jan 2011, 03:06
- Noob?: Yes
Re: autotrade.pl
benj1320 wrote:actually there is an easier version of this.
http://forums.openkore.com/viewtopic.ph ... cro#p52314
thanks benj for reffering me to gamenikko AutoTrade,
but when i download gamenikko Auto Trade Macro Application and when i run it
i got an error saying "The application failed to initialize properly"
so thats why i whant also to fix this plugin bcoz i know a little on this
