Openkore.com
http://forums.openkore.com/

get value from hook network receive packet_vender_strore2
http://forums.openkore.com/viewtopic.php?f=37&t=31092
Page 1 of 1

Author:  xxstreme [ 26 Mar 2013, 00:52 ]
Post subject:  get value from hook network receive packet_vender_strore2

my plugin code like this

print function for hook packet_vender_store2 just return in address memory of array
how should the method of data collection from array memory?

print "@itemList\n"; // this print quene just return in address memory of ARRAY(0x.......)

@itemList is a member of \@venderItemList in hook plugin from network receive servertype0

and how to extract data from @itemList in my plugin code?

@itemList should be containing the data from vender item list
as contains args:
$item->{price},
$item->{amount},
$index,
$item->{type},
$item->{nameID},
$item->{identified}, # should never happen
$item->{broken}, # should never happen
$item->{upgrade},
$item->{cards}

it's should be print item name if i print : just return empty string
print ("$itemList[$index]->{name}");
$index same with index in item vender

print for array addres memory didn't work
print "@{@itemList}\n";

#########################
Code:
package vender;

use strict;
use Plugins;
use Globals;
use Utils;
use Misc;
use Log qw(message warning error debug);
use AI;
use Misc;
use Network;
use Network::Send;

# startup
Plugins::register('vender', 'automatically buy items from merchant vendors', \&Unload, \&Reload);

my $venderItemList = Plugins::addHook('packet_vender_store2', \&itemList);

sub Unload {
   message "vender plugin unloading, ";
   Plugins::delHook('packet_vender_store2', $venderItemList);
}

my $delay = 0.8;
my $time = time;

sub itemList {

   my ($packet, $args) = @_;
   my $venderID = $args->{venderID};
   my @itemList = $args->{itemList};

   print "@itemList\n"; // this print quene just return in address memory of ARRAY(0x.......)

}

# from src network receive servertype0
   Plugins::callHook('packet_vender_store2', {
      venderID => $venderID,
      itemList => \@venderItemList
   });

Author:  Kaspy [ 26 Mar 2013, 14:05 ]
Post subject:  Re: get value from hook network receive packet_vender_strore2

I do not know if I understand right what you want... Could you explain better?

Why not use the hook packet_vender_store?
It will fire every item analysis of the store. If the store has 5 items, will fire 5 times, once for each item.

Author:  xxstreme [ 29 Mar 2013, 02:47 ]
Post subject:  Re: get value from hook network receive packet_vender_strore2

KeplerBR wrote:
I do not know if I understand right what you want... Could you explain better?

Why not use the hook packet_vender_store?
It will fire every item analysis of the store. If the store has 5 items, will fire 5 times, once for each item.


in my plugin sub :
Code:
sub itemList {

   my ($packet, $args) = @_;
   my $venderID = $args->{venderID};
   my @itemList = $args->{itemList};

   print "@itemList\n"; // this print quene just return in address memory of ARRAY(0x.......)

}


why my variable @itemList is filled with memory addres and it's not fill with vender itemList array data?

packet_vender_store next hook is too fast for my scanning item list for vender,
packet_vender_store2 just hooking after entering vender shop, it just hooking once, and hook time delay for next hooking can be setting with my timeout

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/