This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Random error that I can't figure out.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Warrior 7
Junior Member
Join Date: Aug 2012
Old 08-22-2012 , 21:54   Random error that I can't figure out.
Reply With Quote #1

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;
}

Last edited by Warrior 7; 08-22-2012 at 21:59.
Warrior 7 is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 08-22-2012 , 22:30   Re: Random error that I can't figure out.
Reply With Quote #2

You can't pass "saxxy" through FORCE_GENERATION.
It's not a real classname, but is translated by the game, which is exactly what FORCE_GENERATION skips.
__________________
asherkin is offline
Warrior 7
Junior Member
Join Date: Aug 2012
Old 08-22-2012 , 23:51   Re: Random error that I can't figure out.
Reply With Quote #3

Thanks for the prompt reply! I had no idea, I was simply using the classnames as given in items_game.txt because I thought they were the real classnames; most of them are actual classnames like you'd see elsewhere, like tf_weapon_bat. Thanks for the help!
Warrior 7 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 13:47.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode