get value from hook network receive packet_vender_strore2

Forum closed. All further discussion to be discussed at https://github.com/OpenKore/

Moderator: Moderators

Locked
Message
Author
xxstreme
Human
Human
Posts: 20
Joined: 03 Dec 2008, 15:46
Noob?: Yes

get value from hook network receive packet_vender_strore2

#1 Post by xxstreme »

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: Select all

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
	});

Kaspy
OpenKore Monk
OpenKore Monk
Posts: 401
Joined: 08 Jun 2012, 15:42
Noob?: No
Location: Brazil

Re: get value from hook network receive packet_vender_strore2

#2 Post by Kaspy »

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.
Image

xxstreme
Human
Human
Posts: 20
Joined: 03 Dec 2008, 15:46
Noob?: Yes

Re: get value from hook network receive packet_vender_strore2

#3 Post by xxstreme »

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: Select all

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

Locked