A question about ALS hooking. - 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: A question about ALS hooking. (
/showthread.php?tid=607140)
A question about ALS hooking. -
Sjn - 15.05.2016
I've been using this server sided weapon giving function for a while and I thought about hooking it.
This is my first time using a hook so I was wondering if this way is correct or not.
PHP код:
// Give weapon function
GivePlayerWeaponEx(playerid, weaponid, ammo)
{
g_PlayerData[playerid][p_Weapons][weaponid] = 1;
GivePlayerWeapon(playerid, weaponid, ammo);
}
#if defined _ALS_GivePlayerWeapon
#undef GivePlayerWeapon
#else
#define _ALS_GivePlayerWeapon
#endif
#define GivePlayerWeapon GivePlayerWeaponEx
// Reset weapon function
ResetPlayerWeaponEx(playerid)
{
for (new i = 0, j = 47; i < j; ++i)
{
g_PlayerData[playerid][p_Weapons][i] = 0;
}
return ResetPlayerWeapons(playerid);
}
#if defined _ALS_ResetPlayerWeapons
#undef ResetPlayerWeapons
#else
#define _ALS_ResetPlayerWeapons
#endif
#define ResetPlayerWeapons ResetPlayerWeaponEx
My system auto bans a player upon spawning a weapon. After using this hook, I didn't get a ban so it probably is working. My question here right now is, is the way I have hooked it, is right or not?
Also, can anyone give me more information about ALS hooking? I've read about ALS 4 or something like that somewhere on this forum but I can't seems to find it anymore.