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

TF2 Get all attributes from item


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
marih
Junior Member
Join Date: Aug 2013
Old 02-27-2015 , 20:28   TF2 Get all attributes from item
Reply With Quote #1

I'm making a plugin that change player item's unusual effect(attribute 134), quality, index.
In the plugin, there is "g_hItem = TF2Items_CreateItem(OVERRIDE_ITEM_DEF | OVERRIDE_ITEM_QUALITY | OVERRIDE_ATTRIBUTES | PRESERVE_ATTRIBUTES)" and change player's item to g_hItem which is given replacement index, unusual attribute, item quality using

PHP Code:
TF2Items_OnGiveNamedItem(clientString:classname[], iItemDefinitionIndex, &Handle:hItem);
hItem g_hItem
I can get myitem that changed index and so on. But the new item's attributes(except unusual because i added) are same as old one.
I wanna make the new item have new attributes that replacement item index has not the original index has.

Sorry for my bad english.
marih is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 02-27-2015 , 20:32   Re: TF2 Get all attributes from item
Reply With Quote #2

Quote:
Originally Posted by marih View Post
I'm making a plugin that change player item's unusual effect(attribute 134), quality, index.
In the plugin, there is "g_hItem = TF2Items_CreateItem(OVERRIDE_ITEM_DEF | OVERRIDE_ITEM_QUALITY | OVERRIDE_ATTRIBUTES | PRESERVE_ATTRIBUTES)" and change player's item to g_hItem which is given replacement index, unusual attribute, item quality using

PHP Code:
TF2Items_OnGiveNamedItem(clientString:classname[], iItemDefinitionIndex, &Handle:hItem);
hItem g_hItem
I can get myitem that changed index and so on. But the new item's attributes(except unusual because i added) are same as old one.
I wanna make the new item have new attributes that replacement item index has not the original index has.

Sorry for my bad english.
Remove the preserve_attributes flag if you want TF2Items to dispose of the stock attributes, then using the natives add your own
__________________
WildCard65 is offline
marih
Junior Member
Join Date: Aug 2013
Old 02-27-2015 , 21:28   Re: TF2 Get all attributes from item
Reply With Quote #3

Quote:
Originally Posted by WildCard65 View Post
Remove the preserve_attributes flag if you want TF2Items to dispose of the stock attributes, then using the natives add your own
What i wanna do is Get All attributes from an item.(original index has)
And apply on new item

Last edited by marih; 02-27-2015 at 21:29.
marih is offline
Wliu
Veteran Member
Join Date: Apr 2013
Old 02-27-2015 , 21:45   Re: TF2 Get all attributes from item
Reply With Quote #4

Code:
int attributeCount=TF2Items_GetNumAttributes(hItem); int attributeIds[16]; float attributeValues[16]; for(int attributeSlot; attributeSlot<attributeCount; attributeSlot++) {     attributeIds[attributeSlot]=TF2Items_GetAttributeId(hItem, attributeSlot);     attributeValues[attributeSlot]=TF2Items_GetAttributeValue(hItem, attributeSlot); }
This will only compile using the 1.7 compiler.
__________________
~Wliu
Wliu is offline
marih
Junior Member
Join Date: Aug 2013
Old 02-28-2015 , 06:43   Re: TF2 Get all attributes from item
Reply With Quote #5

Quote:
Originally Posted by Wliu View Post
Code:
int attributeCount=TF2Items_GetNumAttributes(hItem); int attributeIds[16]; float attributeValues[16]; for(int attributeSlot; attributeSlot<attributeCount; attributeSlot++) {     attributeIds[attributeSlot]=TF2Items_GetAttributeId(hItem, attributeSlot);     attributeValues[attributeSlot]=TF2Items_GetAttributeValue(hItem, attributeSlot); }
This will only compile using the 1.7 compiler.
um thanks but the hItem is not the replacement one. that is original item's handle.
i wanna get attributes from item that i want, not the original's.
the g_hItem doesn't have all information about replacement one. it's just handle which is including replacement item index. quality, unusual effect (attribute code 134) and which is created by plugin.

sorry for my bad english.

Last edited by marih; 02-28-2015 at 06:45.
marih is offline
Wliu
Veteran Member
Join Date: Apr 2013
Old 02-28-2015 , 11:07   Re: TF2 Get all attributes from item
Reply With Quote #6

Ok so let me see if I understand you.
So you want to change the weapon (let's say Direct Hit) that you currently have to a new unusual-effected weapon (Air Strike) that has the same attributes as the Direct Hit?
__________________
~Wliu
Wliu is offline
marih
Junior Member
Join Date: Aug 2013
Old 02-28-2015 , 11:25   Re: TF2 Get all attributes from item
Reply With Quote #7

Quote:
Originally Posted by Wliu View Post
Ok so let me see if I understand you.
So you want to change the weapon (let's say Direct Hit) that you currently have to a new unusual-effected weapon (Air Strike) that has the same attributes as the Direct Hit?

the attributes must be same as the 'Air Strike'.

PHP Code:
    new attributeCount=TF2II_GetItemNumAttributes(Index);
    new 
attributeIds[16];
    new 
Float:attributeValues[16];
    
TF2Items_SetNumAttributes(g_hItem, (attributeCount+1)); // the g_hItem is the handle that will get new index, unusual attribute, quality, and other attributes that new one's has. because of unusual i added 1 (new + unusual)
    
    
if(Index == || (attributeCount == 0)) // the Index is from keyvalue that is new index.
    
{
        
Index iItemDefinitionIndex// if index is '0' (don't set). make index be original index.
        
TF2Items_SetNumAttributes(g_hItem1); // the unusual effect must be applied in any condition. so i added.
        
TF2Items_SetFlags(g_hItemOVERRIDE_ITEM_DEF OVERRIDE_ITEM_QUALITY OVERRIDE_ATTRIBUTES PRESERVE_ATTRIBUTES);
    }
    else
    {
        
TF2Items_SetFlags(g_hItemOVERRIDE_ITEM_DEF OVERRIDE_ITEM_QUALITY OVERRIDE_ATTRIBUTES);
        for(new 
attributeSlotattributeSlot<attributeCountattributeSlot++)
        {
            
attributeIds[attributeSlot]=TF2II_GetItemAttributeID(IndexattributeSlot);
            
attributeValues[attributeSlot]=TF2II_GetItemAttributeValue(IndexattributeSlot);
            
TF2Items_SetAttribute(g_hItemattributeSlotattributeIds[attributeSlot], attributeValues[attributeSlot]);
        }
    } 
i can get the new one's attribute id, but not value.
the value represent very large number that is over 1000000.
the attribute is not applied.

sorry for my bad english. what am i gonna do?
marih is offline
Wliu
Veteran Member
Join Date: Apr 2013
Old 02-28-2015 , 12:15   Re: TF2 Get all attributes from item
Reply With Quote #8

Try using TF2Items_GetNumAttributes(g_hItem) instead.
__________________
~Wliu
Wliu is offline
marih
Junior Member
Join Date: Aug 2013
Old 02-28-2015 , 12:47   Re: TF2 Get all attributes from item
Reply With Quote #9

Quote:
Originally Posted by Wliu View Post
Try using TF2Items_GetNumAttributes(g_hItem) instead.
g_hItem is not an new one. it just a empty handle and it will get new index,quality,unusual. (my bad english..)

but in my problem, i gotta insert new index's attributes to the g_hItem handle.

now i can get attributeid from new one by index number. but not the value.
marih 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 17:38.


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