• Im trying to make a SWEP (I am a lua noob and I need help)
    4 replies, posted
Im following this tutorial and its not working https://steamcommunity.com/sharedfiles/filedetails/?id=600266572 SWEP.PrintName            = "Portal Gun Gun" -- This will be shown in the spawn menu, and in the weapon selection menu SWEP.Author                = "aster!sk" -- These two options will be shown when you have the weapon highlighted in the weapon selection menu SWEP.Instructions        = "Overpowered death machine!" SWEP.Spawnable = true SWEP.AdminOnly = true SWEP.Primary.ClipSize        = 32 SWEP.Primary.DefaultClip    = 32 SWEP.Primary.Automatic        = false SWEP.Primary.Ammo        = "Pistol" SWEP.Primary.Sound = Sound("weapons/357_fire2.wav") SWEP.Primary.TakeAmmo = 1 SWEP.Primary.Damage = 45 SWEP.Primary.Spread = 1 SWEP.Primary.NumberofShots = 4 SWEP.Primary.Recoil = 10 SWEP.Primary.Delay = 1 SWEP.Primary.Force = 1000 SWEP.Secondary.ClipSize        = -1 SWEP.Secondary.DefaultClip    = -1 SWEP.Secondary.Automatic    = false SWEP.Secondary.Ammo        = "none" SWEP.Weight            = 5 SWEP.AutoSwitchTo        = false SWEP.AutoSwitchFrom        = false SWEP.ViewModel            = "models/weapons/v_portalgun.mdl" SWEP.WorldModel            = "models/weapons/w_shotgun.mdl" SWEP.Slot            = 4 SWEP.SlotPos            = 1 SWEP.DrawAmmo            = true SWEP.DrawCrosshair        = true function SWEP:Initialize() A initialize code, mess with that only if you want to make a swep with swep creator.     util.PrecacheSound(self.Primary.Sound)     util.PrecacheSound(self.ReloadSound)     self:SetWeaponHoldType( self.HoldType ) end function SWEP:PrimaryAttack() Mess with this if you want a different attack function. Google is your best friend to have the knowledge for that.     if ( !self:CanPrimaryAttack() ) then return end     local bullet = {}     bullet.Num = self.Primary.NumberofShots     bullet.Src = self.Owner:GetShootPos()     bullet.Dir = self.Owner:GetAimVector()     bullet.Spread = Vector( self.Primary.Spread * 0.1 , self.Primary.Spread * 0.1, 0)     bullet.Tracer = 0     bullet.Force = self.Primary.Force     bullet.Damage = self.Primary.Damage     bullet.AmmoType = self.Primary.Ammo     local rnda = self.Primary.Recoil * -1     local rndb = self.Primary.Recoil * math.random(-1, 1)     self:ShootEffects()          self.Owner:FireBullets( bullet )     self:EmitSound(Sound(self.Primary.Sound))     self.Owner:ViewPunch( Angle( rnda,rndb,rnda ) )     self:TakePrimaryAmmo(self.Primary.TakeAmmo)     self:SetNextPrimaryFire( CurTime() + self.Primary.Delay )     self:SetNextSecondaryFire( CurTime() + self.Primary.Delay ) end function SWEP:SecondaryAttack() end function SWEP:Reload()     self:EmitSound(Sound(self.ReloadSound))     self.Weapon:DefaultReload( ACT_VM_RELOAD ); end
What isn't working? Are you getting any errors? You need to provide us more info if you want us to be able to help.
I can't give it to myself using the give command and it doesnt appear in the spawn menu.
Where did you place this swep? It should be in: "/garrysmod/addons/YourAddon/lua/weapons/ClassNameOfYourWeapon/shared.lua" And remember to add to the folder "YourAddon" file "addon.json". Here you have how "addon.json" should look like: Workshop Addon Creation
i mean just looking at the code, you have uncommented comments.
Sorry, you need to Log In to post a reply to this thread.