[hook problem] hook OnVehDamageStatusUpd
#1

I use

Код:
#include <YSI\y_hooks>

hook OnVehDamageStatusUpd(vehicleid, playerid)
{
        printf("[debug] hook OnVehDamageStatusUpd(%d, %d)", vehicleid, playerid);
	return 1;
}
And the function is not hooked. instead if i use

Код:
public OnVehicleDamageStatusUpdate(vehicleid, playerid)
{	
	printf("[debug] OnVehicleDamageStatusUpdate(%d, %d)", vehicleid, playerid);
	return 1;
}
everything works, but I need to hook this function.

Can someone help me?
Reply
#2

The functions are not named the same, and i think you need to have the public somewhere before you can hook it.

In which case do you need to it be hooked and not used directly?

Can you live with a function being called instead, inside the public?
Reply
#3

I'm trying to create an modular gamemode, and I already used public in the main include, and now, I create a personal vehicle system and i need to hook this function for store in vHealth[vehicelid] variable the last vehicle Health.

what you mean? Can you live with a function being called instead, inside the public?

And I know the name are not the same, because max. characters are 31 or 32*.
Reply
#4

What if you do this:

This will also keep it modular, and you will keep track of which includes is altering the public by seeing which functions you use. (name wisely, etc)

PHP код:
public OnVehicleDamageStatusUpdate(vehicleidplayerid)
{    
        
DamageStatus_VehicleInclude(vehicleidplayerid);
        return 
1;
}
//then inside the include you create a function:
forward DamageStatus_VehicleInclude(vehicleidplayerid);
public 
DamageStatus_VehicleInclude(vehicleidplayerid)
{
  
//Write whatever you want the include to do. 

Reply
#5

I definitely have the latest version.

But I was looking for more about this, and I found something (see below), and now the hook work:

Код:
DEFINE_HOOK_REPLACEMENT(Damage, Dmg);

hook OnVehicleDmgStatusUpd(vehicleid, playerid) 
{ 
    printf("[debug] hook OnVehicleDamageStatusUpdate(%d, %d)", vehicleid, playerid);
    return Y_HOOKS_CONTINUE_RETURN_1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)