Need some general LUA coding answers

Hey,

i was just wondering, the template for a SWEP on wiki.garrysmod.com give three things i don’t quite understand,

SWEP.ViewModel = “models/weapons/v_pistol.mdl”
SWEP.WorldModel = “models/weapons/w_pistol.mdl”
SWEP.ReloadSound = “weapons/pistol/pistol_reload1.wav”

And i was just wondering where they get these models and the sound from (where are the files), and if there is a list naming all the models and souns you can get for your SWEP.

Making two threads doesn’t get double the help every time :wink:

Anyways, create a folder called ‘Weapon’ (You can change it later)
Inside, create a folder called lua. Inside THAT create a folder called weapons, and inside that make a folder called weapon_gungun (you can change that later too.)Inside the weapon_gungun you put your weapons code.

Go back to the main folder there the lua folder is. Create a folder called models. Inside that create one called weapons. Your models go there ( “models/weapons/v/w_name.mdl” )
The ViewModel is what you see on your screen, and the WorldModel is what others see you holding.

If you want to use a custom model for your SWEP put it in models/weapons and copy the .mdl name for the v_ model. ( “v_name.mdl” ) and put that in the SWEP.ViewModel = " " part.

If there isn’t a world model then use the closest thing you can for a world model, (if it’s a pistol use w_pistol.mdl, if its an SMG use v_smg1.mdl, ect.)

SWEP.ReloadSound only works if you derive from weapon_base I think, I haven’t really checked, but this is the sound that plays when you reload. Usually I make my own sounds, (Like when I made a Deagle SWEP I loaded all the sounds from CS:S and combined them and tested to make sure the sounds matched the animations. I used Audacity.)

When you finish your sounds, create a folder inside the folder we called ‘Weapon’ named sound, create one inside that called weapons, and put your sound in there. For the path for SWEP.ReloadSound it would be, as you should know, sound/weapons/name.wav.
After you have all your lua done, models in the right places, and sounds in the right place, you need an info text file inside the main folder. Inside of this place this text:



"AddonInfo"
{
	"name"				"My weapon"
	"version"			"1"
	"up_date"			"Date Made"
	"author_name"			"Your name"
	"author_email"			"Your email, optional"
	"author_url"			"Optional"
	"info"				"BOOM!"
}


Hope this helps :downs:

Thank you for your reply, it is very hlpfull and is very useful!

I want to officially apolagies for creaing two threads saying the exact same thing, I also want to thank the guy from the other thread (which I can’t remembe his name (“Wizey!” I think), but anyway, both of your replies are both a good insite on how the game is working and how to improve my SWEP, thank you both.

And apolagies for the double post :slight_smile:

No problem, but now I feel I need to copy + paste my super long helpful mega reply :jihad: