Raised This Month: $51 Target: $400
 12% 

Removing All Default Attributes


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ReFlexPoison
☠☠☠
Join Date: Jul 2011
Location: ☠☠☠
Old 09-03-2014 , 21:35   Removing All Default Attributes
Reply With Quote #1

Several weapons that players get have custom attributes that aren't in the default list of attributes in the items_game.txt. Is there was to not preserve default attributes, but to allow those ones, ie: australiums, kill streaks.

Also, is there a way to actually remove an attribute rather than overwriting it with 0.0?

Edit:

Here's my solution. Solved using a check to tell if the attribute is inverted.
PHP Code:
public Action:TF2Items_OnGiveNamedItem(iClientString:strClassname[], iIndex, &Handle:hItem)
{
    static 
Handle:hNewItem INVALID_HANDLE;
    if(
hNewItem != INVALID_HANDLE)
    {
        
CloseHandle(hNewItem);
        
hNewItem INVALID_HANDLE;
    }

    if(
StrEqual(strClassname"tf_wearable_demoshield"false))
    {
        if(
hItem == INVALID_HANDLE)
        {
            
hItem TF2Items_CreateItem(OVERRIDE_ATTRIBUTES PRESERVE_ATTRIBUTES);
            
hNewItem hItem;
        }

        new 
iFlags TF2Items_GetFlags(hItem);
        if(!(
iFlags OVERRIDE_ATTRIBUTES)) iFlags |= OVERRIDE_ATTRIBUTES;
        if(!(
iFlags PRESERVE_ATTRIBUTES)) iFlags |= PRESERVE_ATTRIBUTES;
        
TF2Items_SetFlags(hItemiFlags);

        
TF2Items_RemoveDefaultAttributes(hItemiIndex);
        
TF2Items_ReplaceAttribute(hItem63950.0);

        return 
Plugin_Changed;
    }
}

stock TF2Items_ReplaceAttribute(Handle:hItemiAttributeFloat:flValue)
{
    new 
iNumAttributes TF2Items_GetNumAttributes(hItem);
    new 
bool:bChanged false;
    for(new 
0iNumAttributesi++)
    {
        if(
TF2Items_GetAttributeId(hItemi) == iAttribute)
        {
            
TF2Items_SetAttribute(hItemiiAttributeflValue);
            
bChanged true;
        }
    }

    if(!
bChanged)
    {
        if(
iNumAttributes <= 15)
        {
            
TF2Items_SetNumAttributes(hItemiNumAttributes 1);
            
TF2Items_SetAttribute(hItemiNumAttributesiAttributeflValue);
        }
    }
}

stock TF2Items_RemoveDefaultAttributes(Handle:hItemiIndex)
{
    
decl String:strAttributeName[56];
    
decl String:strAttributeFormat[56];
    for(new 
0TF2II_GetItemNumAttributes(iIndex); i++)
    {
        new 
iAttribute TF2II_GetItemAttributeID(iIndexi);
        
TF2II_GetItemAttributeName(iIndexiAttributestrAttributeNamesizeof(strAttributeName));
        if(
StrContains(strAttributeName"eater"false) != -1)
            continue;

        
TF2II_GetAttribDescrFormat(iAttributestrAttributeFormatsizeof(strAttributeFormat));
        if(
StrContains(strAttributeFormat"percent"false) != -1)
            
TF2Items_ReplaceAttribute(hItemiAttribute1.0);
        else
            
TF2Items_ReplaceAttribute(hItemiAttribute0.0);
    }


Last edited by ReFlexPoison; 09-13-2014 at 17:12.
ReFlexPoison is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 09-04-2014 , 09:53   Re: Removing All Default Attributes
Reply With Quote #2

https://forums.alliedmods.net/showthread.php?t=235010 <--Mind date of thread, if I recall, I read somewhere that the release now has the ability to remove attributes, but only asherkin can confirm or not confirm this.
__________________
WildCard65 is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 09-04-2014 , 10:30   Re: Removing All Default Attributes
Reply With Quote #3

Quote:
Originally Posted by WildCard65 View Post
https://forums.alliedmods.net/showthread.php?t=235010 <--Mind date of thread, if I recall, I read somewhere that the release now has the ability to remove attributes, but only asherkin can confirm or not confirm this.
As long as you're running one of the TF2Items 1.6 versions, you can remove all existing attributes by using OVERRIDE_ATTRIBUTES without using PRESERVE_ATTRIBUTES.

Edit: However, that's decidedly not what ReFlexPoison is asking for.

TF2Items doesn't have the ability to remove individual attributes... however, the TF2Attributes plugin can do that, but you need to manually remove attributes one by one as there's no indication of which attributes are there due to which weapon it is. Even if there was, some of the default attributes are still needed for Strange weapons.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 09-04-2014 at 10:34.
Powerlord is offline
ReFlexPoison
☠☠☠
Join Date: Jul 2011
Location: ☠☠☠
Old 09-04-2014 , 19:57   Re: Removing All Default Attributes
Reply With Quote #4

Quote:
Originally Posted by Powerlord View Post
TF2Items doesn't have the ability to remove individual attributes... however, the TF2Attributes plugin can do that, but you need to manually remove attributes one by one as there's no indication of which attributes are there due to which weapon it is. Even if there was, some of the default attributes are still needed for Strange weapons.
I talked to Sarge about this. I completely forgot about static attributes so removing attributes of created weapons with TF2Attributes wouldn't work.
ReFlexPoison is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 09-12-2014 , 16:15   Re: Removing All Default Attributes
Reply With Quote #5

You can use a plugin like tf2ii or that itemsapi i made ages ago and iterate over the known default attributes for the item, and remove them one by one.
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram 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 05:24.


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