Hook when HP or SP changed

All resolved question will be found here. It is recommended that you browse / search through this section first and see if your question has been answered before

Moderators: Moderators, Documentation Writers

Message
Author
Liposo
Plain Yogurt
Plain Yogurt
Posts: 59
Joined: 20 May 2013, 02:00
Noob?: No

Hook when HP or SP changed

#1 Post by Liposo »

I'm trying to write a plugin to hook when your HP/SP got changed.
I've found

Code: Select all

sub hp_sp_changed {...}
in ServerType0.pm. But somehow this function never triggers when your HP/SP got changed.

Please recommend how to know when HP/SP got changed using Plugin's hook.

Liposo
Plain Yogurt
Plain Yogurt
Posts: 59
Joined: 20 May 2013, 02:00
Noob?: No

Re: Hook when HP or SP changed

#2 Post by Liposo »

Any way?

c4c1n6kr3m1
The Way Of Human
The Way Of Human
Posts: 150
Joined: 24 Mar 2012, 04:13
Noob?: Yes

Re: Hook when HP or SP changed

#3 Post by c4c1n6kr3m1 »

usually i added this line

message("this line is working\n");

Liposo
Plain Yogurt
Plain Yogurt
Posts: 59
Joined: 20 May 2013, 02:00
Noob?: No

Re: Hook when HP or SP changed

#4 Post by Liposo »

c4c1n6kr3m1 wrote:usually i added this line

message("this line is working\n");
Yes I've added that line in the file. Still no message printed in console.

c4c1n6kr3m1
The Way Of Human
The Way Of Human
Posts: 150
Joined: 24 Mar 2012, 04:13
Noob?: Yes

Re: Hook when HP or SP changed

#5 Post by c4c1n6kr3m1 »

i am not familiar with this

i tried with my sitting bot with debug received
<< Received packet: 00B0 - Your Status Info [ 8 bytes]

so it is sub stat_info
you can see hash %stat_info_handlers


i don't know what is sub hp_sp_changed for
may be it is for warlock soul drain
because i remember a lot off complain about warlock here when they implement 0A27

vitriol
Plain Yogurt
Plain Yogurt
Posts: 61
Joined: 19 Apr 2011, 23:26
Noob?: No

Re: Hook when HP or SP changed

#6 Post by vitriol »

Plugins::addHooks(['packet/hp_sp_changed', \&doHookSubroutine]);

Liposo
Plain Yogurt
Plain Yogurt
Posts: 59
Joined: 20 May 2013, 02:00
Noob?: No

Re: Hook when HP or SP changed

#7 Post by Liposo »

vitriol wrote:Plugins::addHooks(['packet/hp_sp_changed', \&doHookSubroutine]);
I'm aware that I could add hook in line of code.

But if a simple code like

Code: Select all

message("this line is working\n");
is not printing any message in the console, that means the sub is never called therefore the hook shouldn't work either?

Locked