Making SWEP attachments

How would I go about making SWEP attachments? The easy part would be networking them as I already have some networking set up for my other customizations. I was just wondering what I would have to use for making and positioning the attachments (probably SWEP construction kit) and how to make them toggle.

It depends on how deeply you want them integrated. Simply having things “attach” is as simple as setting up a table of models, setting the attachment point for each model for each weapon you want it to attach to, plus the angles. Then you just need to draw them as a client-side model.

If you want them to alter the behavior, then in the same database where you list the models, add any type of data structure to hold the alterations that it will do… You could have enums such as ATTACHMENT_REDDOT, ATTACHMENT_MONOCULAR, and then functionality enums such as ZOOM_4X_STATIC, ZOOM_1X_TO_3X_DYNAMIC, etc…

The best way to set up a system like this is to sit down, write down on paper what type of attachments you want, what type of functionality systems you want, and start designing it after you have the ground-work laid. So based on functionality, you could set up your swep-base to use hooks and functionality would use the hooks when an attachment is added, or you could just hard-code everything ( bad way to do it because then it makes it more difficult to add more functionality and also more code to execute, etc… )

As for making them toggle, you could use a menu, you could use button presses, you could use key combinations, etc…

There are thousands of ways to set up a system like this, it really just depends on what you want to do with it.

I will be releasing my swep base soon which will have modular functionality… For example for my terrortown rewrite I may or may not use the magazine system and theoretical bullet system which just means less to include. In Crime City I will, and the magazine system will be able to hook into the inventory system via hooks, etc.

If you start working on a system without first designing it on paper by setting up fixed goals and how everything should function, you may get in over your head. Writing abstractly isn’t always the easiest thing, but if you have everything defined then you’re essentially transcribing from English to Logic to Lua.