Team Fortress 2

Team Fortress 2

Not enough ratings
How to create custom weapons
By Mickey Mouse and 1 collaborators
This guide will teach you the best way to create your own custom weapons for Team Fortress 2 and try them out ingame, including allowing other players to use them without downloading client-side mods and making a demonstration video for your weapon.

I have talked to multiple people regarding this topic, including Crafting, Top Kekkeroni, CHData, Karma Charger, WindPower. I hope to put as much information as possible in a central place.
2
   
Award
Favorite
Favorited
Unfavorite
Formatting custom weapon file
In addition to creating your own attributes, you can also use already existing attributes. You can use "tf2attributes" as the plugin file to use any attribute that already exists in TF2 (see here for a list. Keep in mind some of the "unused" attributes do not work). There are also Orionr's attributes[forums.alliedmods.net] and Yoner's attributes[forums.alliedmods.net].


Crafting has created a video tutorial on formatting this file as well. See some example weapons[forums.alliedmods.net].
Creating custom attributes
If you are not already experience in SourcePawn, you may have some difficulty creating custom attributes.

custom attributes can be read using the functions TF2CustAttr_GetString, TF2CustAttr_GetInt, and TF2CustAttr_GetFloat from tf_custom_attributes.inc ,i.e. TF2CustAttr_GetInt(WeaponIndex, "attribute name") with the weapon's text file containing something like this


"attribute name"
{
"plugin" "custom-attribute-adapter/plugin_name"
"value" "1"
}

Generally 0 will be returned if trying to pull an int from a string value, or if the weapon doesn't contain the attribute.

Here is an example[pastebin.com] of a custom attribute that prevents a weapon's primary fire from being used.
Custom models
Custom models can either be modelled yourself using a program such as Blender, or taken from another place such as GameBanana. Sometimes, models may not be visible to other players -- Valve has done this intentionally to hinder community modding instead of buying from the Mann Co. Store.

Custom models can be put as "viewmodel" or "world_model" - but you will need to use this plugin[forums.alliedmods.net] to ensure the model files are downloaded.
27 Comments
Xavier Dharmawan Mar 1 @ 9:29am 
Is this works on team fortress 2 Classic?
KitChaos Jan 31 @ 4:50am 
ahaaaaa thats where I went wrong, I don't seem to have any JSON files in the directory. I was just pointing out the path in downloads.ini (assuming tf was root) and that wasn't working where should I put/find such a json file?
Mickey Mouse  [author] Jan 31 @ 12:32am 
You can put them in any path you want-- you just need to set it in the JSON to point to the path you put them in.
KitChaos Jan 30 @ 10:48am 
Is there a more in-depth tutorial I can find on how to assign weapon models? or can you give me some advice such as on file placement?
thanks
(hopefully last thing)
KitChaos Jan 30 @ 5:12am 
thank you so much for all the help, this guide is really useful!
KitChaos Jan 30 @ 4:52am 
ah, my bad, I did not have custom weapons 3 installed, I will get that in
sorry!
KitChaos Jan 30 @ 4:49am 
Could you give me the syntax rq? Like if I was to give myself the afterburner weapon from the test weapons, how would I do that? as I don't seem to see a /c command anywhere
Mickey Mouse  [author] Jan 29 @ 8:30pm 
With the /c command!
KitChaos Jan 29 @ 6:40pm 
How can I actually give myself the weapon to use in game? for my local server
Mickey Mouse  [author] Dec 31, 2023 @ 8:47am 
addons/sourcemod/configs/customweapons