Garry's Mod

Garry's Mod

165 ratings
Things about my Swep Creator
By Buu342
For those who clicked any of the Click Here links on my SWEP Creation Program
   
Award
Favorite
Favorited
Unfavorite
Whoa what is this?
THIS GUIDE IS WIP, I WILL ADD STUFF TO IT LATER
This is a guide for a recent program of mine. This program allows you create a gun for gmod with absolutely no experience in lua!

Holy crap thats awsome! How can i get started?

Simple!
Just download the program and run it! Currently it is windows only, so sorry mac users. However, sometime it will be mac compatible

HOWEVER

Please be aware that this guide isn't a tutorial on how to use the program, but rather a place where i can write extra information that i could not fit into the actual program.

(remove the space in the link)
http://www.media fire.com/download/3bbk2962ddpbt86/Swep%20Creator.exe
ChangeLog
COMING SOON
+Added Ironsights to the guide
+Added extra firetypes.

31 Dec @ 18:33 PM
+Added SWEP.CSSMuzzleflashes
~Fixed SWEP.Instructions being the same as SWEP.Author

16 Nov @ 22:08 PM
+Added Secondary Fire
+Added yet another secret

07 Jun @ 17:31 PM
+Added another secret
-Fixed issues regarding swep base's sounds.

12 Jan @ 23:06 PM
+Added new sprites to the buttons so that they are grayed out when unusable
+Added Click Here links to the worldmodel text.
+Added a secret
~Fixed the settings resetting
~Fixed the message box disappearing when changing room.
~Fixed errors regarding the input boxes
~Fixed swep.force not changing

12 Jan @ 18:13am
~Fixed the error regarding the base. (thanks -[FF]- Half-master.)

10 Jan @ 12:27am
+RELEASE!
ViewModels Explained
So what is a viewmodel exactly?

Viewmodels are basically the models that the player sees in their view. In this case, the gun.


Thats cool, but how can i find them?

Gmod and Half-Life 2 come with their own specific viewmodels. Those being the default ones you spawn with. There are 2 different types of viewmodels.

v_models are essencially the model with hands already put on them. these will usually be the default Half Life 2 hands or the Counter Strike Source hands, depending on what game the model is from

c_models are the same thing, but they have the hands removed, so you only get the gun. This allows for you to have different hands, depending on your character.


Ok Sweet, but what are you asking for in the box?

For the gun to work, you must have the filepath put into it for the game to know what gun you are using. Imagine i have a gun model in my garry's mod folder. The gun would essencially be somewhere in my models folder. Which is:

C:\Program Files (x86)\Steam\steamapps\steamname\garrysmod\garrysmod\models

Now i'm going to look for a model. and after browsing, i found a gun i might like. its called v_epicgun. After checking, i know that to find the gun, i had to open 2 folder. imagine one was called sexy and the other was god.

That means the model is in:

C:\Program Files (x86)\Steam\steamapps\steamname\garrysmod\garrysmod\models\sexy\god
But lua doesn't need all that filepath. If you pasted that then you are doing it wrong. Lua already recognizes the gmod folder, so you can shorten that down to:
models\sexy\god
Sweet. Now lua is very picky about when it comes to the direction of the slashes, so you must turn them around.
models/sexy/god
ALMOST DONE!

Now all you need is the model's name, which in our case is v_epicgun. Paste that at the end of the location, HOWEVER, since we want a model, we must put a .mdl at the end.

The final result is:
models/sexy/god/v_epicgun.mdl

And that's how the model system works.

If you want to know the list of models or how to use your own custom ones, look at the chapters below.
ViewModels List
V_MODELS


HALF-LIFE 2
models/weapons/v_357.mdl
models/weapons/v_bugbait.mdl
models/weapons/v_crossbow.mdl
models/weapons/v_crowbar.mdl
models/weapons/v_grenade.mdl
models/weapons/v_hands.mdl
models/weapons/v_IRifle.mdl
models/weapons/v_physcannon.mdl
models/weapons/v_Pistol.mdl
models/weapons/v_rpg.mdl
models/weapons/v_shotgun.mdl
models/weapons/v_smg1.mdl
models/weapons/v_stunbaton.mdl
models/weapons/v_superphyscannon.mdl

CSS
models/weapons/v_mach_m249para.mdl
models/weapons/v_pist_deagle.mdl
models/weapons/v_pist_elite.mdl
models/weapons/v_pist_fiveseven.mdl
models/weapons/v_pist_glock18.mdl
models/weapons/v_pist_p228.mdl
models/weapons/v_pist_usp.mdl
models/weapons/v_rif_ak47.mdl
models/weapons/v_rif_aug.mdl
models/weapons/v_rif_famas.mdl
models/weapons/v_rif_galil.mdl
models/weapons/v_rif_m4a1.mdl
models/weapons/v_rif_sg552.mdl
models/weapons/v_pist_deagle.mdl
models/weapons/v_pist_elite.mdl
models/weapons/v_pist_fiveseven.mdl
models/weapons/v_pist_glock18.mdl
models/weapons/v_pist_p228.mdl
models/weapons/v_shot_m3super90.mdl
models/weapons/v_shot_xm1014.mdl
models/weapons/v_smg_mac10.mdl
models/weapons/v_smg_mp5.mdl
models/weapons/v_smg_p90.mdl
models/weapons/v_smg_tmp.mdl
models/weapons/v_smg_ump45.mdl
models/weapons/v_snip_awp.mdl
models/weapons/v_snip_g3sg1.mdl
models/weapons/v_snip_scout.mdl
models/weapons/v_snip_sg550.mdl


C_MODELS


HALF-LIFE 2
models/weapons/c_357.mdl
models/weapons/c_bugbait.mdl
models/weapons/c_crossbow.mdl
models/weapons/c_crowbar.mdl
models/weapons/c_grenade.mdl
models/weapons/c_hands.mdl
models/weapons/c_IRifle.mdl
models/weapons/c_physcannon.mdl
models/weapons/c_Pistol.mdl
models/weapons/c_rpg.mdl
models/weapons/c_shotgun.mdl
models/weapons/c_smg1.mdl
models/weapons/c_stunbaton.mdl
models/weapons/c_superphyscannon.mdl

CSS
models/weapons/cstrike/c_mach_m249para.mdl
models/weapons/cstrike/c_pist_deagle.mdl
models/weapons/cstrike/c_pist_elite.mdl
models/weapons/cstrike/c_pist_fiveseven.mdl
models/weapons/cstrike/c_pist_glock18.mdl
models/weapons/cstrike/c_pist_p228.mdl
models/weapons/cstrike/c_pist_usp.mdl
models/weapons/cstrike/c_rif_ak47.mdl
models/weapons/cstrike/c_rif_aug.mdl
models/weapons/cstrike/c_rif_famas.mdl
models/weapons/cstrike/c_rif_galil.mdl
models/weapons/cstrike/c_rif_m4a1.mdl
models/weapons/cstrike/c_rif_sg552.mdl
models/weapons/cstrike/c_pist_deagle.mdl
models/weapons/cstrike/c_pist_elite.mdl
models/weapons/cstrike/c_pist_fiveseven.mdl
models/weapons/cstrike/c_pist_glock18.mdl
models/weapons/cstrike/c_pist_p228.mdl
models/weapons/cstrike/c_shot_m3super90.mdl
models/weapons/cstrike/c_shot_xm1014.mdl
models/weapons/cstrike/c_smg_mac10.mdl
models/weapons/cstrike/c_smg_mp5.mdl
models/weapons/cstrike/c_smg_p90.mdl
models/weapons/cstrike/c_smg_tmp.mdl
models/weapons/cstrike/c_smg_ump45.mdl
models/weapons/cstrike/c_snip_awp.mdl
models/weapons/cstrike/c_snip_g3sg1.mdl
models/weapons/cstrike/c_snip_scout.mdl
models/weapons/cstrike/c_snip_sg550.mdl
Custom ViewModels
What if i wanted to use a gun skin that isn't from a game?

Simple. First, you must download the skin from somewhere. I reccomend HERE[css.gamebanana.com] or HERE[hl2dm.gamebanana.com]

Now download a skin and extract the zip/rar file. Extract it to your desktop. Now you should get either a new folder, or some folders called models/materials/sounds etc...

What you want to do now is goto the models folder, and find the new gun model. If you downloaded an ak47 skin, then the file will be called v_rif_ak47.mdl

CHANGE THE FILE NAME!!!!

Why? because this is a skin, which means it will remove your garrysmod one and replace it with that skin. Thats not what you want to do.

Since its called v_rif_ak47.mdl, and imagine i got a skin that makes it look like a bazooka, i would rename it to v_rif_bazooka.mdl, or bazooka.mdl, whatever you feel like naming it. Just remember the name you gave it.

Once you are done, goto steam. Right-click garrysmod on your library, and press Propeties. Then press Local Files and click Browse Local Files. It should open a folder. That folder should contain a file called HL2.EXE. DONT PUT ANY FILES IN HERE! Instead, open the folder called garrysmod, and inside should be a bunch of folders, named lua, models, materials, sounds, addons, etc...

If you don't have a models folder, then create one.

Now take the models and materials folder that you extracted and place them in this folder. A popup should appear saying: Do you want to replace this folder?

Click YES to ALL.

Now that your skin is installed, all you need to do is find its filepath. But since you (hopefully) remembered what you named it, all you really need to do is to put the models/weapons followed by the name you gave it and then .mdl.
For me, it would be
models/weapons/bazooka.mdl
Hopefully this is clear enough.
Worldmodels Explained
Worldmodels are the models that the people see you holding in your hand. Unlike v_models, they have a w instead. Viewmodels will not work as worldmodels however, and vice versa. Other than that, in terms of how you write the worldmodel's path is exactly the same as for the viewmodels.
WorldModels list
W_MODELS


HALF-LIFE 2
models/weapons/w_357.mdl
models/weapons/w_bugbait.mdl
models/weapons/w_crossbow.mdl
models/weapons/w_crowbar.mdl
models/weapons/w_grenade.mdl
models/weapons/w_hands.mdl
models/weapons/w_IRifle.mdl
models/weapons/w_physcannon.mdl
models/weapons/w_Pistol.mdl
models/weapons/w_rpg.mdl
models/weapons/w_shotgun.mdl
models/weapons/w_smg1.mdl
models/weapons/w_stunbaton.mdl
models/weapons/w_superphyscannon.mdl

CSS
models/weapons/w_mach_m249para.mdl
models/weapons/w_pist_deagle.mdl
models/weapons/w_pist_elite.mdl
models/weapons/w_pist_fiveseven.mdl
models/weapons/w_pist_glock18.mdl
models/weapons/w_pist_p228.mdl
models/weapons/w_pist_usp.mdl
models/weapons/w_rif_ak47.mdl
models/weapons/w_rif_aug.mdl
models/weapons/w_rif_famas.mdl
models/weapons/w_rif_galil.mdl
models/weapons/w_rif_m4a1.mdl
models/weapons/w_rif_sg552.mdl
models/weapons/w_pist_deagle.mdl
models/weapons/w_pist_elite.mdl
models/weapons/w_pist_fiveseven.mdl
models/weapons/w_pist_glock18.mdl
models/weapons/w_pist_p228.mdl
models/weapons/w_shot_m3super90.mdl
models/weapons/w_shot_xm1014.mdl
models/weapons/w_smg_mac10.mdl
models/weapons/w_smg_mp5.mdl
models/weapons/w_smg_p90.mdl
models/weapons/w_smg_tmp.mdl
models/weapons/w_smg_ump45.mdl
models/weapons/w_snip_awp.mdl
models/weapons/w_snip_g3sg1.mdl
models/weapons/w_snip_scout.mdl
models/weapons/w_snip_sg550.mdl
Custom WorldModels
Its basically the same as the v_models section, but instead of applying it to a weapon that starts with a v_, its applied to a weapon that starts with a w_.

NOT ALL SKINS HAVE WORLD MODELS!
Sounds and Sound paths
So how do sound paths work?

If you haven't read the how viewmodels work section, go do that now. It explains a lot of what you need. As you know, when putting a model path you dont need to put c:/steam/gmod etc... you just need to put relative to the gmod folder. With that being said,that is how the sound paths work. Also at the end of the path, you must indicate whether the sound you are trying to play is a .wav or a .mp3

How do i add custom sounds?

Simply put the sound you want in the sound folder. If you want, you can create a new folder inside and put the sound there. Imagine i create a sound and i call it "shootsound.wav". I decide to put that in the sounds folder but since i am going to have more than one custom sound, i will create a new folder inside called "gunsounds" and ill put my sound/s there. Now goto the program, and put the folder directory, which in my case would be:

sound/gunsounds

Now i need to put the sound i want to use, and since my sound is a .wav, i must put .wav at the end.

So in the end, i put this inside the program:

sound/gunsounds/shootsound.wav

HOWEVER

For some reason, EmitSound already puts the Sound folder's path. So you don't actually need it. This should be your final code:

gunsounds/shootsound.wav

Thats cool, but what if i want to use Sounds that come with gmod?


This list here contains all the sounds in the source engine.[maurits.tv] And this is the css sounds.[facepunch.com] But you might notice the sound names look differently. Instead of looking like this:
sound/gunsounds/shootsound.wav
they look like this:
Weapon_Pistol.Single
Thats fine. Just put that and it will work. The reason they look differently is because they are part of source and the engine gets the sounds in a different, more complex way that there is no point in me explaining here.
I have my code, what now?
Good stuff. Now do the following:

Goto steam. Right-click garrysmod on your library, and press Propeties. Then press Local Files and click Browse Local Files. It should open a folder. Now open the folder called garrysmod, and inside should be a bunch of folders, named lua, models, materials, sounds, addons, etc...

Open the lua folder and then the weapons folder.

Now create a new folder. You want to name this what your swep is going to be. I usually start with weapon_*. Imagine you were making a Pistol-Shotgun. It would be a good idea to call this folder
weapon_pistolshotty.

DO NOT INCLUDE SPACES AS THEY WILL CAUSE PROBLEMS. IF YOU WANT SPACES, USE UNDERSCORES!

Now open the folder. It should be empty.

Now open notepad. Paste the code inside it, and click save. Call the file shared.lua and BEFORE YOU CLICK SAVE, change the "Save as Type" from "Text document" to "ALL FILES".

Now save it to your desktop. Now go to your desktop and drag the new lua file you created and put it in the gun folder you created in your garrysmod folder.

Now start garrysmod and look for your gun. It should be in the same category as you put in the program.
Video tutorial
FAQ
I found out that i want to change some settings, how do I do that?

Simply open the lua file that you created with notepad, and change the settings there. Just be careful to not delete any Quotation Marks.


My gun isn't in the spawn list?

You probbably:

A: Didn't save the lua file correctly/in the correct place

B: Edited the lua and caused script errors to happen. If this is the case, Feel free to paste the code error on the comments + your code and i'll take a look at it


The program says: "Failed to initialize drawing surfaces" when i launch it!

Be sure that your computer supports this program. System Requirements:

Windows XP, Vista, 7 or 8
512MB RAM
128MB graphics


My anitvirus software says this is a virus!

Don't worry, It's a false positive. I coded this and it has no effect on your system whatsoever. I suggest you run it with online antivirus scanners. My avg doesnt complain about the file and I scanned it and it said the file is safe. Also if the file DID contain a virus, mediafire would have detected so.


Will you add support for firing rockets/other objects or melee weapons?

Yes, later


How do i add ironsights?

You will need to use another swep program for that. Check the video as I covered ironsights in it.


I want my gun to use m9k base or a different one, how do I change that?

Change the SWEP.Base line. I'll post a list of bases on workshop later.


The program says FATAL ERROR follwed by a bunch of code. What do I do?

Paste the code here then, and tell me what happened for the error to pop up.


I have a question that isn't on this list!

Then feel free to comment below. Don't be shy, it doesn't bite.


Whats with the teddy bear?

I honestly wish I knew...


What's the song name?
I don't know. I made the song but i have no idea what to name it.


The song is annoying, how can I mute it?
Press the speaker at the left corner, but doing so hurts my feelings </3


What did you code the program with?
I coded it with GML. Which is the coding language for a program called Game Maker, which I have over 5 years of experience with.
Bugs
None that i am aware of 8D
935 Comments
Buu342  [author] 26 Dec, 2022 @ 10:53am 
@average 15-30 FPS enjoyer 21 Get a program called GCFScape and use it to search the VPK files that are inside the cstrike folder.
76561199364996193 25 Dec, 2022 @ 12:52pm 
anyone know where the Glock 18 sound located? i'm trying to make an full-auto glock 18, but there is no shooting sound
Buu342  [author] 9 Sep, 2022 @ 1:08pm 
@kid named finger Just put it in addons/folder_name/lua/weapons instead, where folder_name is whatever name you want to give that folder.
Well-Rounded Wildcard 9 Sep, 2022 @ 12:51pm 
genuinely good way of getting your foot off the ground in learning and toying with glua without straight up robbing code or something, even if my abrasive and embarrassing past sometimes haunts me whenever a comment pops up in this feed, as they say hindsight is 20/20 even if you're legally blind, genuinely good work was done here for the community, 99.9% of it not from me, probably, just wanted this off my mind, good luck with your work and so on, whoever may happen to read this or whatever
ChilledKen 5 Jul, 2022 @ 7:44pm 
i fixed that issue and a couple other things but now it only fires once and then just clicks
Buu342  [author] 5 Jul, 2022 @ 11:21am 
@ChilledKen Line 48:

SWEP.Primary.DefaultClip =

You need to put a number after the equals
ChilledKen 5 Jul, 2022 @ 6:23am 
this is the code
Buu342  [author] 5 Jul, 2022 @ 4:57am 
@ChilledKen you didn't share enough code for me to be able to help.
Please post the code on pastebin and send the link
ChilledKen 4 Jul, 2022 @ 6:33pm 
help