Raised This Month: $ Target: $400
 0% 

GetNumAttributes


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
thesupremecommander
Member
Join Date: Apr 2012
Old 05-07-2013 , 20:10   GetNumAttributes
Reply With Quote #1

I'm having an issue with TF2Items where GetNumAttributes is returning values way above the bounds of 0 and 15, which is preventing me from iterating through all of the attributes.

Is this me just screwing up my code like normal or am I hitting some other real problem?

Here's the code I'm using:
Code:
public Action:TF2Items_OnGiveNamedItem(client, String:classname[], iItemDefinitionIndex, &Handle:hItem)
{
	hItem = TF2Items_CreateItem(PRESERVE_ATTRIBUTES|OVERRIDE_ATTRIBUTES);
	
	new iItemIndex = TF2Items_GetItemIndex(hItem);
	new iNumAttributes = TF2Items_GetNumAttributes(hItem);
	LogMessage("Index: %i; Num attributes: %i", iItemIndex, iNumAttributes);

	// code that changes the attributes of items...

	return Plugin_Changed;
}
When this code is run, I get lines like these in my logs (mainly to debug the issues with this plugin not working):
Quote:
L 05/07/2013 - 19:32:14: [tf2xtreme.smx] Index: -2147483098; Num attributes: 131
L 05/07/2013 - 19:32:16: [tf2xtreme.smx] Index: 246; Num attributes: 135
L 05/07/2013 - 19:32:16: [tf2xtreme.smx] Index: 259; Num attributes: 101
L 05/07/2013 - 19:32:16: [tf2xtreme.smx] Index: 259; Num attributes: 105
L 05/07/2013 - 19:32:29: [tf2xtreme.smx] Index: 4194304; Num attributes: 0
L 05/07/2013 - 19:32:36: [tf2xtreme.smx] Index: 4; Num attributes: 0
L 05/07/2013 - 19:32:36: [tf2xtreme.smx] Index: 2147483647; Num attributes: 248
L 05/07/2013 - 19:32:48: [tf2xtreme.smx] Index: -1; Num attributes: 255
L 05/07/2013 - 19:32:48: [tf2xtreme.smx] Index: 8192; Num attributes: 16
L 05/07/2013 - 19:33:00: [tf2xtreme.smx] Index: 819180; Num attributes: 254
L 05/07/2013 - 19:33:09: [tf2xtreme.smx] Index: 16777216; Num attributes: 0
L 05/07/2013 - 19:33:09: [tf2xtreme.smx] Index: 536870916; Num attributes: 0
L 05/07/2013 - 19:33:34: [tf2xtreme.smx] Index: -1714789532; Num attributes: 9
L 05/07/2013 - 19:33:34: [tf2xtreme.smx] Index: 1228963968; Num attributes: 0
L 05/07/2013 - 19:33:34: [tf2xtreme.smx] Index: 3016; Num attributes: 0
L 05/07/2013 - 19:33:34: [tf2xtreme.smx] Index: 0; Num attributes: 0
L 05/07/2013 - 19:33:45: [tf2xtreme.smx] Index: 536870912; Num attributes: 0
L 05/07/2013 - 19:33:55: [tf2xtreme.smx] Index: -1630591512; Num attributes: 238
thesupremecommander is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 05-07-2013 , 20:41   Re: GetNumAttributes
Reply With Quote #2

It should be returning 0 for both of those calls, so I'm going to guess that TF2Items isn't initializing said memory so it contains whatever was in it before that.

In case it wasn't obvious from the "returning 0" bit, TF2Items can't be used to read existing item attributes. That's why FlaminSarge wrote the TF2Attributes plugin.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 05-07-2013 at 20:43.
Powerlord is offline
thesupremecommander
Member
Join Date: Apr 2012
Old 05-07-2013 , 20:50   Re: GetNumAttributes
Reply With Quote #3

I should have expected that... although PRESERVE_ATTRIBUTES was what was tricking me to believe otherwise. TF2Attributes doesn't allow iteration over attributes either, from my glance at the API, so I'm going to have to find some other way to make this work.
thesupremecommander is offline
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 05-08-2013 , 06:52   Re: GetNumAttributes
Reply With Quote #4

You need to make a new handle, and youll be able to get the values. At least that is what i do and it works.
__________________
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 20:59.


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