Raised This Month: $32 Target: $400
 8% 

Problems with Effect/Color Attribute


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
pcmaster
AlliedModders Donor
Join Date: Sep 2009
Old 02-05-2013 , 13:35   Problems with Effect/Color Attribute
Reply With Quote #1

Hello,

I am having some Problems attaching Effects/Colors to Hats:

Whenever data[0] is Set (Effect) and data[1] not (Color), it attaches the Effect, but removes the existing Color.
When I try to Set data[1] without data[0], it doesn't do anything (Hat remaings unchanged).

What's wrong with the Code?

data[0] = Effect Index
data[1] = TF2 Color Code

PHP Code:
new Handle:hItem TF2Items_CreateItem(OVERRIDE_ALL);
        new 
numAttr 0;
        
        
TF2Items_SetItemIndex(hItemdefIndex);
        
TF2Items_SetLevel(hItemGetRandomInt(0100));
        
TF2Items_SetQuality(hItem5);
        
TF2Items_SetClassname(hItemclassName);
        
        if(
StringToInt(data[0]) > -1)
        {
            
TF2Items_SetAttribute(hItem0134StringToFloat(data[0]));
            
numAttr++;
            
        }
        
        if(
StringToInt(data[1]) > -1)
        {
            
TF2Items_SetAttribute(hItem1142StringToFloat(data[1]));
            
numAttr++;
        }
        
        
TF2Items_SetNumAttributes(hItemnumAttr);
        
itemOverride hItem;
        
        return 
Plugin_Changed
Any help would be appreciated.
__________________
Stopped hosting servers as of November 2018, no longer active around here.
pcmaster is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 02-05-2013 , 13:45   Re: Problems with Effect/Color Attribute
Reply With Quote #2

Quote:
Originally Posted by pcmaster View Post
Hello,

I am having some Problems attaching Effects/Colors to Hats:
Do I even need to point out that Valve doesn't like it when you do that?
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 02-05-2013 at 13:46.
Powerlord is offline
pcmaster
AlliedModders Donor
Join Date: Sep 2009
Old 02-05-2013 , 13:53   Re: Problems with Effect/Color Attribute
Reply With Quote #3

I am not going to release the Plugin in public, also the Attributes are there in the official List, so anyone could edit the TF2Items Config and do that...
__________________
Stopped hosting servers as of November 2018, no longer active around here.
pcmaster is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 02-05-2013 , 13:56   Re: Problems with Effect/Color Attribute
Reply With Quote #4

asherkin had this to say on a topic extremely similar to this one:

Quote:
Originally Posted by asherkin View Post
That completely undermines the spirit of this community. If you don't want to respect Valve's wishes, you shouldn't be running servers for their games.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Oshizu
Veteran Member
Join Date: Nov 2012
Location: Warsaw
Old 02-06-2013 , 18:51   Re: Problems with Effect/Color Attribute
Reply With Quote #5

Quote:
Originally Posted by pcmaster View Post
Hello,

I am having some Problems attaching Effects/Colors to Hats:

Whenever data[0] is Set (Effect) and data[1] not (Color), it attaches the Effect, but removes the existing Color.
When I try to Set data[1] without data[0], it doesn't do anything (Hat remaings unchanged).

What's wrong with the Code?

data[0] = Effect Index
data[1] = TF2 Color Code

PHP Code:
new Handle:hItem TF2Items_CreateItem(OVERRIDE_ALL);
        new 
numAttr 0;
 
        
TF2Items_SetItemIndex(hItemdefIndex);
        
TF2Items_SetLevel(hItemGetRandomInt(0100));
        
TF2Items_SetQuality(hItem5);
        
TF2Items_SetClassname(hItemclassName);
 
        if(
StringToInt(data[0]) > -1)
        {
            
TF2Items_SetAttribute(hItem0134StringToFloat(data[0]));
            
numAttr++;
 
        }
 
        if(
StringToInt(data[1]) > -1)
        {
            
TF2Items_SetAttribute(hItem1142StringToFloat(data[1]));
            
numAttr++;
        }
 
        
TF2Items_SetNumAttributes(hItemnumAttr);
        
itemOverride hItem;
 
        return 
Plugin_Changed
Any help would be appreciated.
Use TF2Items_SetFlags thingy and add flag 'PRESERVE_ATTRIBUTES'
TF2items.inc
PHP Code:
/**
 * Sets the flags to determine what the item will override on the GiveNamedItem.
 * Use the OVERRIDE_ defines to set what you will be changing.
 *
 * @param hItem   Handle to the TF2Items object that we'll be operating with.
 * @param iFlags  Flags used to specify what to override.
 * @noreturn
 */
native TF2Items_SetFlags(Handle:hItemiFlags); 
PRESERVE_ATTRIBUTES allows you add attributes to items with attributes example item with unusual effect or item with paint or item with 100% more damage.

I've used in my plugin smiliar to your this.
PHP Code:
  hItem TF2Items_CreateItem(OVERRIDE_ALL);
  
TF2Items_SetClassname(hItemclassname);  
  
TF2Items_SetItemIndex(hItemiItemDefinitionIndex);
  
TF2Items_SetQuality(hItemquality[client]);
  
TF2Items_SetLevel(hItemlevel[client]);
  
TF2Items_SetNumAttributes(hItem1);
  
TF2Items_SetAttribute(hItem0134particle[client]);
  
TF2Items_SetFlags(hItemOVERRIDE_ATTRIBUTES|OVERRIDE_CLASSNAME|OVERRIDE_ITEM_QUALITY|OVERRIDE_ITEM_DEF|PRESERVE_ATTRIBUTES);
  return 
Plugin_Changed
particle[client] = number of particle
quality[client] = number of quality
They are both floats
level[client] = level of item
__________________
...

Last edited by Oshizu; 02-06-2013 at 18:55.
Oshizu is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 02-06-2013 , 18:53   Re: Problems with Effect/Color Attribute
Reply With Quote #6

Just use this instead of calling TF2Items_SetFlags at all.

Code:
TF2Items_CreateItem(OVERRIDE_ALL|PRESERVE_ATTRIBUTES);
__________________
asherkin is offline
pcmaster
AlliedModders Donor
Join Date: Sep 2009
Old 02-07-2013 , 07:43   Re: Problems with Effect/Color Attribute
Reply With Quote #7

The Problem with Preserve Attributes is that if I only attach an Effect, nothing happens - the Hat remains unaffected.
Only when I define a color too, it's working ...
__________________
Stopped hosting servers as of November 2018, no longer active around here.
pcmaster is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 02-07-2013 , 08:14   Problems with Effect/Color Attribute
Reply With Quote #8

Then you're doing something else wrong.
__________________
asherkin is offline
pcmaster
AlliedModders Donor
Join Date: Sep 2009
Old 02-07-2013 , 13:24   Re: Problems with Effect/Color Attribute
Reply With Quote #9

Might it be that another Plugin is using the TF2Items_OnGiveNamedItem Forward and manipulating Items?
__________________
Stopped hosting servers as of November 2018, no longer active around here.
pcmaster is offline
Oshizu
Veteran Member
Join Date: Nov 2012
Location: Warsaw
Old 02-08-2013 , 04:44   Re: Problems with Effect/Color Attribute
Reply With Quote #10

Quote:
Originally Posted by pcmaster View Post
Might it be that another Plugin is using the TF2Items_OnGiveNamedItem Forward and manipulating Items?
Type in console

sm plugins unload_all
later
sm plugins load (.smx file name of your unusuals plugin)

Tell us after you do so if same thing happens or not.
__________________
...
Oshizu is offline
Reply


Thread Tools
Display Modes

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 11:19.


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