15.05.2016, 08:21
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.
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.
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
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.