The ID's change every map start, so don't cache them for other maps.
Left4DHooks provides the native
PHP Code:
/**
* @brief Retrieve the index for a given melee weapon from the Melee Weapon Database.
* @remarks Index updated on OnMapStart - suggest using RequestFrame to find index.
* @remarks Index can change depending on available melee weapons each map.
*
* @param weaponName Weapon to lookup index id for
*
* @return The index id. Returns -1 if no match is found or melee unavailable.
*/
// L4D2 only.
native int L4D2_GetMeleeWeaponIndex(const char[] weaponName);
__________________