SA-MP Forums Archive
Hooking functions - 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: Hooking functions (/showthread.php?tid=578485)



Hooking functions - Shetch - 19.06.2015

I want to hook CreateVehicle to print a console message every time it's called.

Код:
stock CreateVehicleEx(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawn_delay, addsiren=0)
{
	print("vehicle spawned from hook");
	return CreateVehicle(modelid, x, y, z, angle, color1, color2, respawn_delay, addsiren);
}

#define CreateVehicle CreateVehicleEx
This is my code now, but when I call CreateVehicle, the message is not printed in the console.

Any ideas?


Re: Hooking functions - X337 - 20.06.2015

Код:
stock Your_CreateVehicle(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawn_delay, addsiren=0)
{
	print("vehicle spawned from hook");
	return CreateVehicle(modelid, x, y, z, angle, color1, color2, respawn_delay, addsiren);
}
#if defined _ALS_CreateVehicle
    #undef CreateVehicle
#else
    #define _ALS_CreateVehicle
#endif
#define CreateVehicle Your_CreateVehicle
Tutorials here : Click