Plugin/Hook Question

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

Moderator: Moderators

Message
Author
leachim
Noob
Noob
Posts: 1
Joined: 16 Apr 2008, 11:36

Plugin/Hook Question

#1 Post by leachim »

Code from Receive.pm:

Code: Select all

if ($actor->isa('Actor::Player')) {
			my $domain = existsInList($config{friendlyAID}, unpack("V1", $actor->{ID})) ? 'parseMsg_presence' : 'parseMsg_presence/player';
			debug "Player Exists: " . $actor->name . " ($actor->{binID}) Level $actor->{lv} $sex_lut{$actor->{sex}} $jobs_lut{$actor->{jobID}} ($coordsFrom{x}, $coordsFrom{y})\n", $domain;
			
			Plugins::callHook('player', {player => $actor});  #backwards compatibailty
			Plugins::callHook('player_exist', {player => $actor});

Im already done with initialization..

now my question is how to get the value of $actor->name in my subroutine.

this code doesn't return the right value:
sub player_disp {
..
..
my $charname= Actor::get($newactor->{player});
$ownername = $charname->name;
..
..
}

Motivus
Developers
Developers
Posts: 157
Joined: 04 Apr 2008, 13:33
Noob?: Yes

Re: Plugin/Hook Question

#2 Post by Motivus »

Code: Select all

sub player_disp {
	my $args = @_; #Declare the variable for arguments passed to the function
	
	my $actor = $args{player}; #Declare local variable for the actor object

	my $charname = $actor->name; #Access the actor object's name
}
Oh no.

sli
Perl Monk
Perl Monk
Posts: 810
Joined: 04 Apr 2008, 17:26
Noob?: No

Re: Plugin/Hook Question

#3 Post by sli »

That +

Code: Select all

use Globals;
cs : ee : realist

Bibian
Perl Monk
Perl Monk
Posts: 416
Joined: 04 Apr 2008, 03:08

Re: Plugin/Hook Question

#4 Post by Bibian »

or if the hook passes it to your plugin:

Code: Select all

my ($self, $args) = @_;
my $myArg = $args->{myArgument};

Locked