This in your current plugin will delete tasers since it share the same weapon slot than knives
PHP Code:
public void RemoveExtraKnives(int client)
{
int weapon = GetPlayerWeaponSlot(client, 2);
while (weapon!= -1)
{
RemovePlayerItem(client, weapon);
weapon = GetPlayerWeaponSlot(client, 2);
}
GivePlayerItem(client, "weapon_knife");
}
I made this code that should works better and without issues. It just remove extra knives when it necessary.
PHP Code:
public void RemoveExtraKnives(int client)
{
int size = GetEntPropArraySize(client, Prop_Send, "m_hMyWeapons");
bool haveKnife = false;
for (int i = 0; i < size; i++) // run for all the weapons that player have
{
int weapon = GetEntPropEnt(client, Prop_Send, "m_hMyWeapons", i);
if (IsValidEdict(weapon) && IsValidEntity(weapon))
{
char weaponClass[64];
if (!GetEdictClassname(weapon, weaponClass, sizeof(weaponClass)))continue; // if invalid entity then continue
if(StrContains(weaponClass, "weapon_knife", false) == 0 || StrContains(weaponClass, "weapon_bayonet", false) == 0) // knife entity
{
if(haveKnife) // player already have knife and this is other knife?
{
// delete extra knife because he only need one
RemovePlayerItem(client, weapon);
AcceptEntityInput(weapon, "Kill");
}
haveKnife = true; // set that player have knife
}
}
}
}
Also I recommend you to have the plugins in a github repository like I have, for allow others to make pulls requests for improve plugins if they want and for see the code changes easily. Cheers
__________________