PDA

View Full Version : TF2_GiveNamedItem failed


DronElektron
06-30-2012, 14:23
Hi all. I have problem with creating a stock weapon, for example: I want to restrict The Beggar's Bazooka on my jm server (cos this is bugged weapon for jump mod, you can fly with it).

So this is my three functions:

-------------------------------------------------------------------------------
SetupWeapons()
{
g_hWeaponRocketLauncher = CreateStockWeapon("tf_weapon_rocketlauncher", 18);
}

Handle:CreateStockWeapon(String:classname[], index)
{
new Handle:hWeapon = TF2Items_CreateItem(OVERRIDE_ALL);

TF2Items_SetClassname(hWeapon, classname);
TF2Items_SetItemIndex(hWeapon, index);
TF2Items_SetFlags(hWeapon, 0);
TF2Items_SetLevel(hWeapon, 0);
TF2Items_SetQuality(hWeapon, 0);
TF2Items_SetNumAttributes(hWeapon, 0);

return hWeapon;
}

GiveWeaponToClient(client, Handle:hWeapon)
{
if (hWeapon == INVALID_HANDLE) return -1;
if ((client <= 0) || (client > MaxClients) || !IsClientInGame(client)) return -1;
if (!IsPlayerAlive(client)) return -1;

new iWeapon = TF2Items_GiveNamedItem(client, hWeapon);

EquipPlayerWeapon(client, iWeapon);

return iWeapon;
}
-------------------------------------------------------------------------------

In console I see: [SM] Native "TF2Items_GiveNamedItem" reported: item is NULL.

So, how I can create simple weapon, default rocketlauncher, minigun or any weapon and after it set it to player? I just want to make simple weapon restrictor for our servers.

Leonardo
07-01-2012, 10:30
use tf2items_manager and clear attributes

"custom_weapons_v3"
{
"*"
{
"730"
{
"preserve-attributes" "0"
}
}
}

DronElektron
07-01-2012, 13:05
use tf2items_manager and clear attributes

"custom_weapons_v3"
{
"*"
{
"730"
{
"preserve-attributes" "0"
}
}
}


This doesn't work :(
And with 18 index too...