• Swep Making problem
    7 replies, posted
Hello. I've coded a swep and my weapon is not appearing in the spawn menu heres the script, sorry if something is completely messed up, im very new to scripting sweps and facepunch as a matter of fact ;.; (also my friend is helping me make the sweps for a gamemode of his ) : [lua] SWEP.base = "weapon_base" SWEP.Category = "pistol"; SWEP.Author = "TehSmoothKriminal"; SWEP.Contact = "tehsmoothkriminal@gmail.com"; SWEP.Purpose = "FOR BIOHAZARD GAME MODE USE ONLY"; SWEP.Instructions = "Left click to shoot, right click is iron sights."; SWEP.PrintName = "The 'Jumper' Pistol"; SWEP.Slot = 1; SWEP.SlotPos = 3; SWEP.DrawCrosshair = true; SWEP.DrawAmmo = true; SWEP.ViewModel = "models/weapons/v_pistol"; SWEP.WorldModel = "models/weapons/w_pistoll"; SWEP.ViewModelFOV = 64; SWEP.ReloadSound = "weapons/pistol/pistol_reload1.wav"; SWEP.HoldType = "pistol"; SWEP.Spawnable = true; SWEP.AdminSpawnable = true; SWEP.Weight = 1; SWEP.AutoSwitchTo = false; SWEP.AutoSwitchFrom = true; SWEP.FiresUnderwater = true; SWEP.Primary.Sound = "weapons/usp/usp_unsil-1.wav"; SWEP.Primary.Tracer = 1; SWEP.Primary.Automatic = false; SWEP.Primary.Force = 30; SWEP.Primary.FireFromHip = true; SWEP.Primary.Weld = false; SWEP.Primary.Ammo = "pistol"; SWEP.Primary.ExplosionShot = false; SWEP.Primary.BulletShot = true; SWEP.Primary.ModelShot = false; SWEP.Primary.BreakAll = true; SWEP.Primary.Ignite = false; SWEP.Primary.ClipSize = 25; SWEP.Primary.DefaultClip = 12; SWEP.Primary.Recoil = 0.2; SWEP.Primary.Damage = 30; SWEP.Primary.NumberofShots = 1; SWEP.Primary.Spread = 0; SWEP.Primary.Delay = ; SWEP.Primary.TakeAmmo = 1; function SWEP:Initialize() util.PrecacheSound(self.Primary.Sound); util.PrecacheSound(self.Secondary.Sound); if ( SERVER ) then self:SetWeaponHoldType( self.HoldType ); end end function SWEP:PrimaryAttack() if ( !self:CanPrimaryAttack() ) then return end //Default stuff, normally used in any condition. local trace = self.Owner:GetEyeTrace(); self.Weapon:EmitSound ( self.Primary.Sound ); self:ShootEffects(); self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay ); self.Weapon:SetNextSecondaryFire( CurTime() + self.Primary.Delay ); self:TakePrimaryAmmo(self.Primary.TakeAmmo); local rnda = -self.Primary.Recoil; local rndb = self.Primary.Recoil * math.random(-1, 1); self.Owner:ViewPunch( Angle( rnda,rndb,rnda ) ); //The attack mode, can vary from the user settings if ( self.Primary.ExplosionShot ) then local explode = ents.Create( "env_explosion" ); explode:SetPos( trace.HitPos ); explode:SetOwner( self.Owner ); explode:Spawn(); explode:SetKeyValue( "iMagnitude", self.Primary.ExplosionSize ); explode:Fire( "Explode", 0, 0 ); explode:EmitSound( self.Primary.ExplosionSound, self.Primary.ExplosionSoundDistance, self.Primary.ExplosionSoundDistance ); end if ( self.Primary.BreakAll ) then if( trace.Entity:IsValid() and trace.Entity:GetClass() == "prop_physics" ) then constraint.RemoveAll( trace.Entity ); local physobject = trace.Entity:GetPhysicsObject(); physobject:EnableMotion( true ); physobject:SetVelocity( self.Owner:GetAimVector() * 2 ); end end if ( self.Primary.Ignite ) then if (!trace.Entity) then return false end if (!trace.Entity:IsValid() ) then return false end if (trace.Entity:IsPlayer()) then return false end if (trace.Entity:IsWorld()) then return false end if ( CLIENT ) then return true end local Time = math.random(20); trace.Entity:Extinguish(); trace.Entity:Ignite( Time, 0 ); end if ( self.Primary.BulletShot ) then 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 = self.Primary.Tracer; bullet.Force = self.Primary.Force; bullet.Damage = self.Primary.Damage; bullet.AmmoType = self.Primary.Ammo; self.Owner:FireBullets( bullet ); end if ( self.Primary.ModelShot ) then if (!SERVER) then return end; local ent = ents.Create ("prop_physics"); ent:SetModel ( self.Primary.Model ); if ( self.Primary.FireFromHip ) then ent:SetPos (self.Owner:EyePos() + (self.Owner:GetAimVector() * 32)); else ent:SetPos (trace.HitPos + self.Owner:GetAimVector() * -16); end ent:SetAngles (self.Owner:EyeAngles()); ent:Spawn(); local phys = ent:GetPhysicsObject(); local shot_length = trace.HitPos:Length(); if ( self.Primary.Weld ) then local weld = constraint.Weld( trace.Entity, ent, trace.PhysicsBone, 0, 0 ); end phys:ApplyForceCenter (self.Owner:GetAimVector():GetNormalized() * math.pow (shot_length, 3)); cleanup.Add (self.Owner, "props", ent); undo.Create ("Thrown model"); undo.AddEntity (ent); undo.SetPlayer (self.Owner); undo.Finish(); end end function SWEP:SecondaryAttack() if ( !self:CanPrimaryAttack() ) then return end //Default stuff, normally used in any condition. local trace = self.Owner:GetEyeTrace(); self.Weapon:EmitSound ( self.Secondary.Sound ); self:ShootEffects(); self.Weapon:SetNextPrimaryFire( CurTime() + self.Secondary.Delay ); self.Weapon:SetNextSecondaryFire( CurTime() + self.Secondary.Delay ); self:TakePrimaryAmmo(self.Secondary.TakeAmmo); local rnda = -self.Secondary.Recoil; local rndb = self.Secondary.Recoil * math.random(-1, 1); self.Owner:ViewPunch( Angle( rnda,rndb,rnda ) ); //The attack mode, can vary from the user settings if ( self.Secondary.ExplosionShot ) then local explode = ents.Create( "env_explosion" ); explode:SetPos( trace.HitPos ); explode:SetOwner( self.Owner ); explode:Spawn(); explode:SetKeyValue( "iMagnitude", self.Secondary.ExplosionSize ); explode:Fire( "Explode", 0, 0 ); explode:EmitSound( self.Secondary.ExplosionSound, self.Secondary.ExplosionSoundDistance, self.Secondary.ExplosionSoundDistance ); end if ( self.Secondary.BreakAll ) then if( trace.Entity:IsValid() and trace.Entity:GetClass() == "prop_physics" ) then constraint.RemoveAll( trace.Entity ); local physobject = trace.Entity:GetPhysicsObject(); physobject:EnableMotion( true ); physobject:SetVelocity( self.Owner:GetAimVector() * 2 ); end end if ( self.Secondary.Ignite ) then if (!trace.Entity) then return false end if (!trace.Entity:IsValid() ) then return false end if (trace.Entity:IsPlayer()) then return false end if (trace.Entity:IsWorld()) then return false end if ( CLIENT ) then return true end local Time = math.random(20); trace.Entity:Extinguish(); trace.Entity:Ignite( Time, 0 ); end if (self.Secondary.BulletShot ) then local bullet = {}; bullet.Num = self.Secondary.NumberofShots; bullet.Src = self.Owner:GetShootPos(); bullet.Dir = self.Owner:GetAimVector(); bullet.Spread = Vector( self.Secondary.Spread * 0.1 , self.Secondary.Spread * 0.1, 0); bullet.Tracer = self.Secondary.Tracer; bullet.Force = self.Secondary.Force; bullet.Damage = self.Secondary.Damage; bullet.AmmoType = self.Primary.Ammo; self.Owner:FireBullets( bullet ); end if ( self.Secondary.ModelShot ) then if (!SERVER) then return end local ent = ents.Create ("prop_physics"); ent:SetModel ( self.Secondary.Model ); if ( self.Secondary.FireFromHip ) then ent:SetPos (self.Owner:EyePos() + (self.Owner:GetAimVector() * 32)); else ent:SetPos (trace.HitPos + self.Owner:GetAimVector() * -16); end ent:SetAngles (self.Owner:EyeAngles()); ent:Spawn(); local phys = ent:GetPhysicsObject(); local shot_length = trace.HitPos:Length(); if ( self.Secondary.Weld ) then local weld = constraint.Weld( trace.Entity, ent, trace.PhysicsBone, 0, 0 ); end phys:ApplyForceCenter (self.Owner:GetAimV
Sorry to tell you this mate, but you made this is a swep generator :crossarms:
yeah i did use a swep generate :/ im very new to swep making
Read the wiki's and don't say [QUOTE]Hello. I've coded a swep[/QUOTE]
[lua]SWEP.ViewModel = "models/weapons/v_pistol"; SWEP.WorldModel = "models/weapons/w_pistoll";[/lua] Add .mdl to the end of those, and get rid of the extra L. Also, post your error log and use lua tags.
[QUOTE=Archy;19059160][lua]SWEP.ViewModel = "models/weapons/v_pistol"; SWEP.WorldModel = "models/weapons/w_pistoll";[/lua] Add .mdl to the end of those, and get rid of the extra L. Also, post your error log and use lua tags.[/QUOTE] thanks. i never noticed that. sorry about the no lua tags thing. i am new to facepunch and dont know most of the tags. thanks again
Let us know if that fixes it :v: Also, what is your weapon supposed to do, and what generator are you using? I want to take a peak at its code :)
[QUOTE=Chad Mobile;19079182]Let us know if that fixes it :v: Also, what is your weapon supposed to do, and what generator are you using? I want to take a peak at its code :)[/QUOTE] It didn't fix it : /, I actually scrapped that script and made a new one. but it didnt work either.also i was using portalfreeks easy swep maker: [url]http://www.garrysmod.org/downloads/?a=view&id=83282[/url]
Sorry, you need to Log In to post a reply to this thread.