AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   TF2Items (https://forums.alliedmods.net/forumdisplay.php?f=146)
-   -   Removing All Default Attributes (https://forums.alliedmods.net/showthread.php?t=247559)

ReFlexPoison 09-03-2014 21:35

Removing All Default Attributes
 
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);
    }



WildCard65 09-04-2014 09:53

Re: Removing All Default Attributes
 
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.

Powerlord 09-04-2014 10:30

Re: Removing All Default Attributes
 
Quote:

Originally Posted by WildCard65 (Post 2193797)
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.

ReFlexPoison 09-04-2014 19:57

Re: Removing All Default Attributes
 
Quote:

Originally Posted by Powerlord (Post 2193814)
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.

friagram 09-12-2014 16:15

Re: Removing All Default Attributes
 
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.


All times are GMT -4. The time now is 21:31.

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