New Scripted Weapon Help

Hi I’m new to lua coding, so i need some help. My first one turned out pretty well. But my second one… well… lets just say its not too good. If anyone can help me with the following, Id be happy. On left click (i wanted it to launch you forward like the fast zombies from zombie survival, while swinging rapidly, and yelling.) On right click, (i wanted it to throw a crowbar, that spins and removes itself after hitting the target.) I usually take swep bases from garrysmod.org and then clear all the variables and start there. I’m pretty much a nub. I want to know how to make sweps like the throwing knife ect. that shoot AND melee. I still don’t know how to make a melee weapon. If anyone knows a program ( like a exe) that you put in what you want your swep to do, that would be great. ( like left click shoot and right click melee way. you could tell it what you wanted like if it should throw an entity or prop ect) Anyway, Here’s my hopeless code so far: SWEP.AdminSpawnable = true SWEP.ViewModelFOV = 64 SWEP.ViewModel = “models/weapons/v_crowbar.mdl” SWEP.WorldModel = “models/weapons/w_crowbar.mdl” SWEP.AutoSwitchTo = false SWEP.Slot = 0 SWEP.HoldType = “crowbar” SWEP.PrintName = “NoobsNewCrowbar” SWEP.Author = “Pikmin Red” SWEP.Spawnable = true SWEP.AutoSwitchFrom = false SWEP.FiresUnderwater = true SWEP.Weight = 5 SWEP.DrawCrosshair = false SWEP.Category = “Pikmins Sweps” SWEP.SlotPos = 2 SWEP.DrawAmmo = false SWEP.ReloadSound = “Weapon_Pistol.Reload” SWEP.Instructions = “Left click: Go crazy. Right click: Get rid of the crowbar” SWEP.Contact = “You can try, but it wont work” SWEP.Purpose = “For noobs to use” SWEP.base = “weapon_base” //General settings\ //PrimaryFire Settings\ SWEP.Primary.Sound = “noobsnewcrowbar\l4d_yell.wav” SWEP.Primary.Damage = 121 SWEP.Primary.TakeAmmo = 0 SWEP.Primary.ClipSize = 0 SWEP.Primary.Ammo = “none” SWEP.Primary.DefaultClip = 0 SWEP.Primary.Spread = 0.0 SWEP.Primary.NumberofShots = 23 SWEP.Primary.Automatic = false SWEP.Primary.Recoil = 0 SWEP.Primary.Delay = -20 SWEP.Primary.Force = 37 //PrimaryFire settings\ //SecondaryProp Settings\ SWEP.Secondary.NumberofShots = 1 SWEP.Secondary.Force = 43 SWEP.Secondary.Spread = 0.0 SWEP.Secondary.Sound = “Weapon_Crowbar.Single” SWEP.Secondary.DefaultClip = 1 SWEP.Secondary.Automatic = false SWEP.Secondary.AngVelocity = Angle(0,0,0) SWEP.Secondary.Ammo = “smg1” SWEP.Secondary.Model = “models/weapons/w_crowbar.mdl” – CHECK THIS SWEP.Secondary.Recoil = 1 SWEP.Secondary.Delay = 5 SWEP.Secondary.TakeAmmo = 1 SWEP.Secondary.ClipSize = 1 SWEP.Secondary.Damage = 500 //SecondaryProp Settings \ //SWEP:Initialize()\ function SWEP:Initialize() util.PrecacheSound(self.Primary.Sound) util.PrecacheSound(self.Secondary.Sound) if ( SERVER ) then self:SetWeaponHoldType( self.HoldType ) end end //SWEP:Initialize()\ //SWEP:PrimaryFire()\ function SWEP:PrimaryAttack() 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.Weapon:EmitSound(Sound(self.Primary.Sound)) self.Owner:ViewPunch( Angle( rnda,rndb,rnda ) ) self:TakePrimaryAmmo(self.Primary.TakeAmmo) self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay ) self.Weapon:SetNextSecondaryFire( CurTime() + self.Primary.Delay ) end //SWEP:PrimaryFire()\ //SWEP:SecondaryFire()\ function SWEP:SecondaryAttack() self:TakePrimaryAmmo(self.Secondary.TakeAmmo) self:Throw_Attack (self.Secondary.Model, self.Primary.Sound, self.Secondary.AngVelocity) self.Weapon:SetNextPrimaryFire( CurTime() + self.Secondary.Delay ) self.Weapon:SetNextSecondaryFire( CurTime() + self.Secondary.Delay ) end //SWEP:SecondaryFire()\ //SWEP:Throw_Attack(Model, Sound, Angle)\ function SWEP:Throw_Attack (Model, Sound, Angle) local tr = self.Owner:GetEyeTrace() self.Weapon:EmitSound (Sound) self.BaseClass.ShootEffects (self) if (!SERVER) then return end local ent = ents.Create (“prop_physics”) ent:SetModel (Model) ent:SetPos (self.Owner:EyePos() + (self.Owner:GetAimVector() * 16)) ent:SetAngles (self.Owner:EyeAngles()) ent:Spawn() local phys = ent:GetPhysicsObject() local shot_length = tr.HitPos:Length() phys:ApplyForceCenter (self.Owner:GetAimVector():GetNormalized() * math.pow (shot_length, 7)) phys:AddAngleVelocity(Angle) cleanup.Add (self.Owner, “props”, ent) undo.Create (“Thrown Crowbar”) undo.AddEntity (ent) undo.SetPlayer (self.Owner) undo.Finish() end If you helped, Id gladly put you in the credits

Anyone?

The problem is you’re not asking clear questions, what is it you need help with? Does your code produce errors? Is there a feature you’re having trouble implementing? Also placing your code between [noparse][lua][/lua][/noparse] tags will help people read your code and entice them to help you more.

OMG! It keeps removing my lua tags! and it wont let me put an enter! Lets see if it works here [lua] SWEP.AdminSpawnable = true SWEP.ViewModelFOV = 64 SWEP.ViewModel = “models/weapons/v_crowbar.mdl” SWEP.WorldModel = “models/weapons/w_crowbar.mdl” SWEP.AutoSwitchTo = false SWEP.Slot = 0 SWEP.HoldType = “crowbar” SWEP.PrintName = “NoobsNewCrowbar” SWEP.Author = “Pikmin Red” SWEP.Spawnable = true SWEP.AutoSwitchFrom = false SWEP.FiresUnderwater = true SWEP.Weight = 5 SWEP.DrawCrosshair = false SWEP.Category = “Pikmins Sweps” SWEP.SlotPos = 2 SWEP.DrawAmmo = false SWEP.ReloadSound = “Weapon_Pistol.Reload” SWEP.Instructions = “Left click: Go crazy. Right click: Get rid of the crowbar” SWEP.Contact = “You can try, but it wont work” SWEP.Purpose = “For noobs to use” SWEP.base = “weapon_base” //General settings\ //PrimaryFire Settings\ SWEP.Primary.Sound = “noobsnewcrowbar\l4d_yell.wav” SWEP.Primary.Damage = 121 SWEP.Primary.TakeAmmo = 0 SWEP.Primary.ClipSize = 0 SWEP.Primary.Ammo = “none” SWEP.Primary.DefaultClip = 0 SWEP.Primary.Spread = 0.0 SWEP.Primary.NumberofShots = 23 SWEP.Primary.Automatic = false SWEP.Primary.Recoil = 0 SWEP.Primary.Delay = -20 SWEP.Primary.Force = 37 //PrimaryFire settings\ //SecondaryProp Settings\ SWEP.Secondary.NumberofShots = 1 SWEP.Secondary.Force = 43 SWEP.Secondary.Spread = 0.0 SWEP.Secondary.Sound = “Weapon_Crowbar.Single” SWEP.Secondary.DefaultClip = 1 SWEP.Secondary.Automatic = false SWEP.Secondary.AngVelocity = Angle(0,0,0) SWEP.Secondary.Ammo = “smg1” SWEP.Secondary.Model = “models/weapons/w_crowbar.mdl” – CHECK THIS SWEP.Secondary.Recoil = 1 SWEP.Secondary.Delay = 5 SWEP.Secondary.TakeAmmo = 1 SWEP.Secondary.ClipSize = 1 SWEP.Secondary.Damage = 500 //SecondaryProp Settings \ //SWEP:Initialize()\ function SWEP:Initialize() util.PrecacheSound(self.Primary.Sound) util.PrecacheSound(self.Secondary.Sound) if ( SERVER ) then self:SetWeaponHoldType( self.HoldType ) end end //SWEP:Initialize()\ //SWEP:PrimaryFire()\ function SWEP:PrimaryAttack() 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.Weapon:EmitSound(Sound(self.Primary.Sound)) self.Owner:ViewPunch( Angle( rnda,rndb,rnda ) ) self:TakePrimaryAmmo(self.Primary.TakeAmmo) self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay ) self.Weapon:SetNextSecondaryFire( CurTime() + self.Primary.Delay ) end //SWEP:PrimaryFire()\ //SWEP:SecondaryFire()\ function SWEP:SecondaryAttack() self:TakePrimaryAmmo(self.Secondary.TakeAmmo) self:Throw_Attack (self.Secondary.Model, self.Primary.Sound, self.Secondary.AngVelocity) self.Weapon:SetNextPrimaryFire( CurTime() + self.Secondary.Delay ) self.Weapon:SetNextSecondaryFire( CurTime() + self.Secondary.Delay ) end //SWEP:SecondaryFire()\ //SWEP:Throw_Attack(Model, Sound, Angle)\ function SWEP:Throw_Attack (Model, Sound, Angle) local tr = self.Owner:GetEyeTrace() self.Weapon:EmitSound (Sound) self.BaseClass.ShootEffects (self) if (!SERVER) then return end local ent = ents.Create (“prop_physics”) ent:SetModel (Model) ent:SetPos (self.Owner:EyePos() + (self.Owner:GetAimVector() * 16)) ent:SetAngles (self.Owner:EyeAngles()) ent:Spawn() local phys = ent:GetPhysicsObject() local shot_length = tr.HitPos:Length() phys:ApplyForceCenter (self.Owner:GetAimVector():GetNormalized() * math.pow (shot_length, 7)) phys:AddAngleVelocity(Angle) cleanup.Add (self.Owner, “props”, ent) undo.Create (“Thrown Crowbar”) undo.AddEntity (ent) undo.SetPlayer (self.Owner) undo.Finish() end [/lua] Okay whats up with that!!

I’m just drawing something off of pastebin.

That is nicely spaced/indented code. Your code should look like that. The way you have it now it is illegible.

Also, what is your problem?

If your trying to make it throw a crowbar then just download my Crowbar thrower… It’s easier then what you have right there =/ If you are going to use this in a gamemode then give me credit.