Making Your first SWEP

-- Programs needed --

-- Notepad, or NotePad ++ -- -- Garrys Mod 10 --

  1. Ok first open notepad, or npp, and copy this into your program.

"if ( SERVER ) then

AddCSLuaFile( "shared.lua" )

SWEP.HoldType            = "ar2"

end"

This is just telling the server, if the game is a server not singleplayer, send this file to the client who is connecting. And the HoldType is just what kind of gun it is just make it ar2 for your first swep.

-- Look at Screen shot 'A' for details --

  1. Now after that copy this in and edit it how you want.

"if ( CLIENT ) then

SWEP.PrintName            = "Guns Name Here"            
SWEP.Author                = "Your Name Here"
SWEP.Slot                = 3
SWEP.SlotPos            = 1
SWEP.IconLetter            = "w"

killicon.AddFont( "weapon_ak47", "CSKillIcons", SWEP.IconLetter, Color( 255, 80, 0, 255 ) )

end"

Ok the SWEP.PrintName is what the gun is called, SWEP.Author is who made the swep.

SWEP.Slot is what slot the gun is in

0 = slot 1 1 = slot 2 2 = slot 3 etc... all the way up to 5 which = 6

i have no idea why it is that way

SWEP.SlotPos is were in the slot your gun is

if its set to 99 it will be on the bottom of the slot unless of course another swep is set to 100.

SWEP.IconLetter is just a letter that represents the swep.

Dont mess around with the killicon its set for css style.

  1. Ok after that once again copy and paste to your liking...

"SWEP.Base = "weapon_cs_base"

SWEP.Spawnable = true SWEP.AdminSpawnable = true

SWEP.ViewModel = "models/weapons/v_rif_ak47.mdl" SWEP.WorldModel = "models/weapons/w_rif_ak47.mdl"

SWEP.Weight = 5 SWEP.AutoSwitchTo = false SWEP.AutoSwitchFrom = false"

Alright SWEP.Base is what base the swep draws off.. dont mess with that yet

SWEP.Spawnable, and SWEP.AdminSpawnable is if the public can spawn this gun, or just the admin, change them between false and ture.

SWEP.ViewModel is what the V model is. SWEP.WorldModel is what the W model is, just use the ak47.

Leave every thing else the same.

  1. Almost done now but copy this and edit how you want.

" SWEP.Primary.Sound = Sound( "Weapon_AK47.Single" ) SWEP.Primary.Recoil = 1.5 SWEP.Primary.Damage = 40 SWEP.Primary.NumShots = 1 SWEP.Primary.Cone = 0.02 SWEP.Primary.ClipSize = 25 SWEP.Primary.Delay = 0.07 SWEP.Primary.DefaultClip = 50 SWEP.Primary.Automatic = true SWEP.Primary.Ammo = "smg1"

SWEP.Secondary.ClipSize = -1 SWEP.Secondary.DefaultClip = -1 SWEP.Secondary.Automatic = false SWEP.Secondary.Ammo = "none""

Ok now this looks harder, but is much easier i think.

SWEP.Primary.Recoil is the recoil on the primary attack. SWEP.Primary.Damage is how much damage the primary attack does. SWEP.Primary.NumShots is how many bullets come out of the gun. SWEP.Primary.Cone is how accurate the gun is. SWEP.Primary.ClipSize is well... the clipsize. SWEP.Primary.Delay is the delay between shots, 1.00 = 1 second. SWEP.Primary.DefaultClip is how much ammo you gain when you pickup the gun SWEP.Primary.Automatic is if the gun is automatic, false is no, true is yes. SWEP.Primary.Ammo is what type of amoo the swep uses

The secondary is set up so it doesnt do any thing, cause the ironsight is on secondary click.

  1. To finish it all off copy this in

"SWEP.IronSightsPos = Vector( 6.1, -7, 2.5 ) SWEP.IronSightsAng = Vector( 2.8, 0, 0 )"

those ironsights are set up for the ak47, they wont work for any other model.

after that, save the file as "shared.lua"

and place it in garrysmod/lua/weapons/"make a folder called sample" and save it there.

all done start up gmod it should be right in the sweps section on ur menu.

Have any questions send me a pm! >8)

Oh noes! You're not a Member!

Want access to cool stuff? As a member you can:

  • Post. Give the submitter your thoughts on this Tutorial.
  • Say Thanks. Show your appreciation by sending the submitter points.
  • Stamp Posts. Let other posters know what you think of their posts.
  • Rate. Give this Tutorial a rating out of 10.
  • Flag. Alert moderators and warn members of a problem with this Tutorial.
  • Vote. Vote the submitter for the Monthly Awards.
  • Subscribe. Get notified when this submitter submits again.

Interested? Register or Login

Comments

  • thekiller2274 avatar
    thekiller2274
    Availability
    Offline
    Points Level
    Beggar Points Level icon
    Beggar
    6 points
    Account Age Level
    Tenderfoot Age Level icon
    Tenderfoot
    7 months old
    Clearance Level
    Member Clearance Level icon
    Member
    • Report icon
    7 months ago:

    Posted by JohnTheCactusBanana Notes:

    • I have a problem. I did everything and i got a text document.Can you help me?

    When making a it did you have (yourtitle).txt or (yourtitle).lua if you do not see these things or have no clue what im talking about ill explain more when your in your download folder do folder and search options then view then turn off/unclick hide extensions for known file types then when you see the extensions rename the extension .lua good luck:D

    Bananite
  • JohnTheCactusBanana avatar
    JohnTheCactusBanana
    Availability
    Offline
    Points Level
    Beggar Points Level icon
    Beggar
    53 points
    Account Age Level
    Tenderfoot Age Level icon
    Tenderfoot
    10 months old
    Clearance Level
    Member Clearance Level icon
    Member
    • Report icon
    10 months ago:

    Notes:

    • I have a problem. I did everything and i got a text document.Can you help me?
    Bananite
  • LOLPerson avatar
    LOLPerson
    Availability
    Offline
    Account Age Level
    Veteran Age Level icon
    Veteran
    4 years old
    Clearance Level
    Member Clearance Level icon
    Member
    • Report icon
    4 years ago:

    Pros: Very helpful Cons: Doesn't tell you a lot of info Improvements: Tell more ammo types

    Bananite
  • XDriver avatar
    XDriver
    Availability
    Offline
    Account Age Level
    Veteran Age Level icon
    Veteran
    4 years old
    Clearance Level
    Member Clearance Level icon
    Member
    • Report icon
    4 years ago:

    Where to find "{" ?!

    Bananite
  • Drakeowns avatar
    Drakeowns
    Availability
    Offline
    Points Level
    Beggar Points Level icon
    Beggar
    16 points
    Account Age Level
    Veteran Age Level icon
    Veteran
    4 years old
    Clearance Level
    Member Clearance Level icon
    Member
    • Report icon
    4 years ago:

    I need help

    Okay i finished but i downloaded a custom model and i want to use it as my weapon what folder do i put it in?

    Bananite
  • Chickencowman avatar
    Chickencowman
    Availability
    Offline
    Account Age Level
    Veteran Age Level icon
    Veteran
    5 years old
    Clearance Level
    Member Clearance Level icon
    Member
    • Report icon
    5 years ago:

    If I wanted my SWEP to shoot sawblades... in the ammo section would I just put "sawblade" or what?

    Bananite
  • simzboy avatar
    simzboy
    Availability
    Offline
    Points Level
    Beggar Points Level icon
    Beggar
    202 points
    Account Age Level
    Veteran Age Level icon
    Veteran
    6 years old
    Clearance Level
    Member Clearance Level icon
    Member
    • Report icon
    6 years ago:

    I did every thing in the tut, but my SWEP does not show up in game.

    1 SHOT 1 KILL
  • serioushans avatar
    serioushans
    Availability
    Offline
    Account Age Level
    Elder Age Level icon
    Elder
    6 years old
    Clearance Level
    Member Clearance Level icon
    Member
    • Report icon
    6 years ago:

    I can't find it!

    banana phone!
  • Wowzorz avatar
    Wowzorz
    Availability
    Offline
    Points Level
    Beggar Points Level icon
    Beggar
    730 points
    Account Age Level
    Elder Age Level icon
    Elder
    8 years old
    Clearance Level
    Member Clearance Level icon
    Member
    • Report icon
    6 years ago:

    Then remove the '{'.

    I'm done. avatar
    User Title
    I'm done.
  • serioushans avatar
    serioushans
    Availability
    Offline
    Account Age Level
    Elder Age Level icon
    Elder
    6 years old
    Clearance Level
    Member Clearance Level icon
    Member
    • Report icon
    6 years ago:

    I have a problem... The gmod console says: weapons/exploder_swep/shared.lua:1: unexpected symbol near '{'

    Please Help!!

    banana phone!

Credits

Key Authors
wowzorz1leeroy
Unknown

Submitter

Wowzorz avatar
Wowzorz
Availability
Offline
Points Level
Beggar Points Level icon
Beggar
730 points
Account Age Level
Elder Age Level icon
Elder
8 years old
Clearance Level
Member Clearance Level icon
Member

Wowzorz
(Creator/Co-creator)

Rating

Expert+
9.0/10
Based off 11 rating(s)

Details

Genre
Other/Misc
Difficulty Level
Beginner

Stats

Post Count
25
ViewCount
51,871
Date Added
7 years ago
Date Modified
3 years ago

Share

Code to use:

More embeddable images

Bookmark and Share