How to tell GMod where to put addon files?

Hi, I’ve made a TTT traitor weapon, uploaded it to the workshop and everything, but then realised that gmod doesn’t know where to put the addon when someone downloads it.

How do I tell gmod to install the weapon addon into the ttt files?

I’m more than sure that the game knows where it needs to put workshop addons in order to load them. Can you explain your problem properly? What is making you think that gmod doesn’t know where to put addons? Can you tell us what you think should be happening, and what is happening instead?

did you put your weapon in the ttt gamemode folder, or did you make your own addon folder for it?

Don’t expect it to work if you didn’t make an addon folder ;o

I installed it to see if it worked, went into TTT and it wasn’t in the Traitor buy menu.

I’m sure gmod knows where to put addons, but I don’t know how gmod would know to make my weapon available in TTT. It doesn’t put every custom weapon I download into TTT, so there’s no reason for it to do so with this one as far as I can see.

Maybe I’m just really dumb, idk.

You should post the folder layout and the relevant code. This is a problem with your addon, not gmod.

Yeah I made an addon folder.
I followed these instructions on the gmod wiki for making an addon https://wiki.garrysmod.com/page/Workshop_Addon_Creation I didn’t bother making subfolders for materials, maps or scripts, just lua/weapons/customweapon so idk if that’s a problem, it didn’t complain when I compiled it so I assumed it was fine.

[editline]28th September 2017[/editline]

Yeah I assumed it was my addon not gmod
My addon folder looks like this:



GMod Addon/
    lua/
        weapons/
             ttt_teamchanger/
                   weapon_ttt_teamchanger.lua
    addon.json


The code for my addon is taken from the DNA Scanner and modified slightly

EDIT: Here is what I have in my addon.json, is my problem because I’ve set it as the wrong type perhaps?



{
	"title"		:	"TTT TeamChanger",
	"type"		:	"weapon",
	"ignore"	:
	[
		"*.psd",
		"*.vcproj",
		"*.svn*"
	]
}

I think it should be in the entities\weapons\folder

So instead of it being in Addon\lua\weapons tt_teamchanger the .lua file should be in Addon\entities\weapons tt_teamchanger ? Just tried it, that doesn’t work, it said that it wasn’t allowed by the whitelist

Addon\lua\weapons tt_teamchanger is correct. I’ve never played TTT But I assume the buy menu is a addon/gamemode you have to add your weapon to. You can try spawning it in via q menu instead to test its function

ok thanks, I tried going into sandbox to try it out but it wasn’t anywhere in the q menu :confused:
what do you mean about adding my weapon to an addon/gamemode?

TTT doesn’t have a spawn menu and adding an item to the buy menu takes 2-3 lines in the SWEP file

Also, if you have it on the workshop do you mind sending a link so I can sub to it and take a look?

Ah ok that sounds like my problem then, what 2-3 lines do I need to add?
the file is here http://steamcommunity.com/sharedfiles/filedetails/?id=1149640925

Well if it was working in singleplayer then it sounds like you’ve already added them. SWEP.CanBuy SWEP.EquipMenuData and SWEP.LimitedStock are the usual 3. I’ll post back here after I’ve had a look

[editline]28th September 2017[/editline]

I’ve had a quick look and found a few problems. First of all, your biggest problem is that your file is placed as lua/weapons/ttt_teamchanger/weapon_ttt_teamchanger.lua
It should be lua/weapons/weapon_ttt_teamchanger/shared.lua OR just lua/weapons/weapon_ttt_teamchanger.lua
This prevents the file from being loaded, and hence why it isn’t even showing in-game.

You’ve also got a problem with your variables SWEP.Kind and SWEP.Slot - AFAIK, WEAPON_EQUIP1 isn’t an equipment slot, and therefore doesn’t fit with your weapon slot (which is SWEP.Slot = 8 and is actually slot 9. Me personally, I would change SWEP.Kind to WEAPON_EQUIP2 (which exists) and change SWEP.Slot to 7. Also, a lot of unused code in there (due to it being a quick derivative to the DNA scanner), so you should try removing anything that isn’t used.

That worked! Thanks so much!