Hey I was wondering if you had any idea on how to fix this issue.
We discussed it a little on steam.
This is important for servers that block some weapons in some rounds etc.
Plugin 1 using PTaH:
PHP Code:
public void OnPluginStart()
{
PTaH(PTaH_GiveNamedItemPre, Hook, GiveNamedItemPre);
PTaH(PTaH_WeaponCanUse, Hook, WeaponCanUse);
}
public void GiveNamedItemPre(int client, char classname[64], CEconItemView &item, bool &ignoredCEconItemView)
{
//Do anything here to ak47 here or do nothing
return Plugin_Changed;
}
public bool WeaponCanUse(int client, int ent, bool canuse)
{
//check if ent is the ak47 here etc
return true;
}
Other plugins
PHP Code:
public void OnClientPutInServer(int client)
{
SDKHook(client, SDKHook_WeaponCanUse, Hook_BlockPickup);
}
//Block AK47
public Action Hook_BlockPickup(int client, int weapon)
{
char weaponClass[64];
GetEntityClassname(weapon, weaponClass, sizeof(weaponClass));
if (StrEqual(weaponClass, "weapon_ak47"))
return Plugin_Handled;
return Plugin_Continue;
}
In this case, the AK47 will always be equipped even if other plugins use SDKHooks with SDKHook_WeaponCanUse to block it. A lot of plugins use this so it would be good if there was a solution for this.
Why does returning
Plugin_Changed in
GiveNamedItemPre without changing anything cause the weapon to not be able to be picked up? I'm sure this can be fixed so the weapon can still be picked up by default without needing to use the PTaH weaponcanuse. That way you can just use SDKHooks only for WeaponCanUse.
What does
removeIfNotCarried do?
https://github.com/komashchenko/PTaH...wards.cpp#L374
Maybe using
MRES_OVERRIDE here:
https://github.com/komashchenko/PTaH...wards.cpp#L398
I did some testing, will try some more stuff later.
Let me know if you have any ideas.
__________________