This Autotrade plugins (autorade.pl) was made for collecting an items by using public chat,very useful for those who need to collecting an items or forging materials.
Requirements :
1. Latest Openkore Version (I'm using Openkore 2.0.5.1)
2. Latest Macro and Plugins Which Support OpenKore 2.0.5.1
For those who don't know how to install macro and plugins, I suggest you're visit the macro and plugins official website.
http://www.openkore.com/macro.php
Okay,first you need to create an autotrade plugins file called autotrade.pl Simply copy and paste the code in the line below with your favorite text editor (notepad,will works too),save this file to Openkore plugins folder and name it for autotrade.pl (remember to choose save as type : all files options)
package autoTrade;
#ported from messykorexp by Joseph
#original code by systeman
use strict;
use Plugins;
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 = "autotrade.txt";
#my $cfID = Settings::addConfigFile($file, \%trade_lut, \&FileParsers::parseDataFile_lc);
my $cfID = Settings::addControlFile($file, loader => [\&FileParsers::parseDataFile_lc, \%trade_lut]);
#Settings::load($cfID);
undef $file;
sub Unload {
Plugins::delHook('AI_pre', $hook1);
Plugins::delHook('parseMsg/pre', $hook2);
Settings::removeFile($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 = 12;
# time to wait before accepting deal request?
my $dealAcceptTime = 2;
# time to wait before adding zeny once they finalize their item choices?
my $zenyAddDelay = 3;
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}) {
$messageSender->sendDealAccept();
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";
$messageSender->sendCurrentDealCancel();
$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"; $messageSender->sendCurrentDealCancel();
last AUTOTRADE;
}
}
message "Trading $sumvalue zeny and confirming\n", "autoTrade";
$messageSender->sendDealAddItem(0, $sumvalue);
sleep(0.5);
$messageSender->sendDealFinalize();
$dealFinalize = 1;
$itemAddTimeout = time;
}
}
if ($::currentDeal{you_finalize} && Utils::timeOut($itemAddTimeout,$itemWaitTime)) {
message "Other person didn't accept the final trade, cancelling...\n", "autoTrade";
$messageSender->sendCurrentDealCancel();
$itemAddTimeout = time;
}
if (!$dealTrade && $::currentDeal{you_finalize} && $::currentDeal{other_finalize}) {
message "Accepting final trade\n", "autoTrade";
$messageSender->sendDealTrade();
$dealTrade = 1;
}
}
}
}
return 1;
You'll need to make some minor adjustment in your config.txt, Add this line tradeAuto 1 to your config and change the line dealAuto to 0 So the blocks will looks similar like this
dealAuto 0
tradeAuto 1
dealAuto_names
partyAuto 1
partyAutoShare 0
guildAutoDeny 1
Make the autotrade.txt files with your notepad then save it in your OpenKore control folder, we are using this file to configure which items we're need to trade,for example you want to buy Elunium for 100k Zeny.
# [item name] [price]
Elunium 100000
Next we're need to configure macros (don't forget to make macros.txt files in your OpenKore control folder, if you don't have it), Here an example for a simple macros to trigger openchat room
automacro openchatroom {
map payon
run-once 1
delay 10
call openchat
}
macro openchat {
do chat create "B>Elunium @100k" 2 0 password
}
Now your autotrade plugins ready to use (I have tested and it works well)
1. You can tweaks your macros by adding autoStorage procedure which allowed kore to using storage
2. Having a lag problems which result in disconnected Openkore will ruins this macros, In this case, you'll need to type reload macros in your Openkore console manually (to trigger the automacros)
3. Please forgive for my bad English
Original source available at :
http://forums.openkore.com
Requirements :
1. Latest Openkore Version (I'm using Openkore 2.0.5.1)
2. Latest Macro and Plugins Which Support OpenKore 2.0.5.1
For those who don't know how to install macro and plugins, I suggest you're visit the macro and plugins official website.
http://www.openkore.com/macro.php
Okay,first you need to create an autotrade plugins file called autotrade.pl Simply copy and paste the code in the line below with your favorite text editor (notepad,will works too),save this file to Openkore plugins folder and name it for autotrade.pl (remember to choose save as type : all files options)
package autoTrade;
#ported from messykorexp by Joseph
#original code by systeman
use strict;
use Plugins;
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 = "autotrade.txt";
#my $cfID = Settings::addConfigFile($file, \%trade_lut, \&FileParsers::parseDataFile_lc);
my $cfID = Settings::addControlFile($file, loader => [\&FileParsers::parseDataFile_lc, \%trade_lut]);
#Settings::load($cfID);
undef $file;
sub Unload {
Plugins::delHook('AI_pre', $hook1);
Plugins::delHook('parseMsg/pre', $hook2);
Settings::removeFile($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 = 12;
# time to wait before accepting deal request?
my $dealAcceptTime = 2;
# time to wait before adding zeny once they finalize their item choices?
my $zenyAddDelay = 3;
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}) {
$messageSender->sendDealAccept();
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";
$messageSender->sendCurrentDealCancel();
$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"; $messageSender->sendCurrentDealCancel();
last AUTOTRADE;
}
}
message "Trading $sumvalue zeny and confirming\n", "autoTrade";
$messageSender->sendDealAddItem(0, $sumvalue);
sleep(0.5);
$messageSender->sendDealFinalize();
$dealFinalize = 1;
$itemAddTimeout = time;
}
}
if ($::currentDeal{you_finalize} && Utils::timeOut($itemAddTimeout,$itemWaitTime)) {
message "Other person didn't accept the final trade, cancelling...\n", "autoTrade";
$messageSender->sendCurrentDealCancel();
$itemAddTimeout = time;
}
if (!$dealTrade && $::currentDeal{you_finalize} && $::currentDeal{other_finalize}) {
message "Accepting final trade\n", "autoTrade";
$messageSender->sendDealTrade();
$dealTrade = 1;
}
}
}
}
return 1;
You'll need to make some minor adjustment in your config.txt, Add this line tradeAuto 1 to your config and change the line dealAuto to 0 So the blocks will looks similar like this
dealAuto 0
tradeAuto 1
dealAuto_names
partyAuto 1
partyAutoShare 0
guildAutoDeny 1
Make the autotrade.txt files with your notepad then save it in your OpenKore control folder, we are using this file to configure which items we're need to trade,for example you want to buy Elunium for 100k Zeny.
# [item name] [price]
Elunium 100000
Next we're need to configure macros (don't forget to make macros.txt files in your OpenKore control folder, if you don't have it), Here an example for a simple macros to trigger openchat room
automacro openchatroom {
map payon
run-once 1
delay 10
call openchat
}
macro openchat {
do chat create "B>Elunium @100k" 2 0 password
}
Now your autotrade plugins ready to use (I have tested and it works well)
1. You can tweaks your macros by adding autoStorage procedure which allowed kore to using storage
2. Having a lag problems which result in disconnected Openkore will ruins this macros, In this case, you'll need to type reload macros in your Openkore console manually (to trigger the automacros)
3. Please forgive for my bad English
Original source available at :
http://forums.openkore.com
3 comments:
thanks it is working in 2.0.7 :) sir if you can give me a warper bot i will be the happiest person in this world. here's my email add mcer_dx@yahoo.com.ph
YOUR ROCK ! WORKING FOR ME :D ..
Sir can you tell me how to limit when buying? Thanks for your efforts! More power, CHEERS! :)
Post a Comment