SA-MP Forums Archive
[hook problem] hook OnVehDamageStatusUpd - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [hook problem] hook OnVehDamageStatusUpd (/showthread.php?tid=652453)



[hook problem] hook OnVehDamageStatusUpd - RedGun2015 - 11.04.2018

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?


Re: [hook problem] hook OnVehDamageStatusUpd - denNorske - 11.04.2018

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?


Re: [hook problem] hook OnVehDamageStatusUpd - RedGun2015 - 11.04.2018

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


Re: [hook problem] hook OnVehDamageStatusUpd - denNorske - 11.04.2018

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. 




Re: [hook problem] hook OnVehDamageStatusUpd - RedGun2015 - 12.04.2018

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