about autotrade macro w/ autostorage

All about the macro plugin can be found in this forum. This forum is intended for the macro plugin only.

Moderator: Moderators

sitoyoman
Noob
Noob
Posts: 1
Joined: 31 Mar 2014, 11:48
Noob?: Yes

about autotrade macro w/ autostorage

#1 Post by sitoyoman »

I need help guys about autobuy macro. please help!!

my autobuy/trade is working fine, the problem is that when my character overweight above 50% it wont go in autostorage.
can someone post their autobuy macro that has an autostorage fuction. thanks!! really appreciate it.

btw, here are my macro and config,

plugins folder (autotrade.pl)

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 = 20;
# 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;

=========================================================================================

config folder (macros.txt)

#Toggle console - macro trigger
#check / uncheck open equipment window to public
#default - console /Other players are not allowed to view your Equipment./i

automacro openchatroom {
console /Other players are not allowed to view your Equipment./i
#console /Other players are allowed to view your Equipment./i
run-once 1
call openchat
}

macro openchat {
do move prontera 156 71
pause 0.5
do chat create "whtChoco90k|straw30k|gukak3m" 2 0 "fafaf"
pause 0.5
do look 4
pause 0.5
release openchatroom
}

============================================================================

config folder (autotrade.txt)

White Chocolate 90000
Strawberry 30000
Steamed Tongue 60 50000000
Dragon Breath Cocktail 60 50000000
Hwergelmir's Tonic 60 50000000
Stew Of Immortality 60 50000000
Guyak Pudding 3000000

==============================================================================

config folder (config.txt)

itemsTakeAuto 1
itemsTakeAuto_party 0
itemsGatherAuto 0
itemsMaxWeight 49
itemsMaxWeight_sellOrStore 49
itemsMaxNum_sellOrStore 99
cartMaxWeight 7900
itemsTakeAuto_new 0


storageAuto 1
storageAuto_AfterDeath 1
storageAuto_npc prontera 146 89
storageAuto_distance 5
storageAuto_npc_type 1
storageAuto_npc_steps c r1 n
storageAuto_password 00000000
storageAuto_keepOpen 0
storageAuto_useChatCommand
relogAfterStorage 0
minStorageZeny 50

==================================================================================

thanks in advance for those who will reply and help!! i've been working for this macro and finding solotion for 5+ hour already!!
I really appreciate it if you guys will help! :D
gelo2012
Plain Yogurt
Plain Yogurt
Posts: 58
Joined: 17 Sep 2012, 13:54
Noob?: Yes
Location: Sa Puso Mo

Re: about autotrade macro w/ autostorage

#2 Post by gelo2012 »

What I did is, I used gamenikko's auto-trade macro (use at your own risk) and fixed some major exploits like triggering the automacro from shout and talkie box, ignoring all pm, setting the chat in private mode and changing the item name(s) I want to trade in the tables.txt(this way the low-life players won't know what to trigger if they use shout and talkie box.
It is not very complicated.
Try the search command and put some time with it. :D