View Single Post
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 07-25-2011 , 14:38   Re: TF2Items - Items with custom attributes.
#1007

Quote:
Originally Posted by Pawn 3-pg View Post
How do we use FORCE_GENERATION? I see it defined in the .inc, but I don't see where I would use it. Am I correct to assume that this will allow us to replace a weapon at TF2Items_OnGiveNamedItem and have the player successfully spawn with it?
You use it just like any of the other item flags.
Actually, the trick to getting replacing weapons in OnGiveNamedItem is to /not/ use it. Prior to 1.4.3 (when bug 18 was "fixed"), force was always set to false, after it, it was always set to true. Now, it's only set if the flag is.

Some examples:
Give a weapon with the classname "saxxy":
With force: game will try and create an item with the classname "saxxy" and fail.
Without force: game will lookup the correct classname per-class and use that, it'll work fine.
Give a bottle to a soldier:
With force: will work fine.
Without force: game will lookup correct classname, and give a shovel instead.

You'll just need to experiment to find out when it's needed. Generally, not using it is better.

Quote:
Originally Posted by Pawn 3-pg View Post
Will this fix the Strange weapons not tracking kills? Or does it just allow us to create Strange weapons?
What issues are there with Strange weapons tracking kills?
Yes, but created strange weapons will not level up. I really don't advise adding the kill count item attribute to created strange weapons, or the game will try and inform the backend whenever a kill is made, which could be disastrous since the weapon doesn't really exist.
__________________
asherkin is offline