Right, so I'm attempting to build a utility plugin for TF2 that strips players of their weapons, then gives them a no-damage Conscientious Objector so they can still hit buttons in the level.
The problem is, no matter what I do, TF2Items_GiveNamedItem fails, and says the usual thing about "Item is NULL." The problem is, I've looked over this and can't find anything wrong with it. Is there something wrong with my code or is it a bug?
Code:
public Action:Command_BuildProtectOn(client, args)
{
StripWeapons(client);
new Handle:hItem = TF2Items_CreateItem(OVERRIDE_ALL|FORCE_GENERATION);
if (hItem != INVALID_HANDLE)
{
TF2Items_SetClassname(hItem, "saxxy");
TF2Items_SetItemIndex(hItem, 474);
TF2Items_SetLevel(hItem, 1);
TF2Items_SetQuality(hItem, 6);
TF2Items_SetNumAttributes(hItem, 2);
TF2Items_SetAttribute(hItem, 0, 137, 0.0);
TF2Items_SetAttribute(hItem, 1, 138, 0.0);
new weapon = TF2Items_GiveNamedItem(client, hItem);
EquipPlayerWeapon(client, weapon);
}
CloseHandle(hItem);
return Plugin_Handled;
}