Ive mad a swep but its broken can you help me:
SWEP.base = "weapon_physgun"
SWEP.Category = "Other";
SWEP.Author = "Eddidog8";
SWEP.Contact = "eddiedogcarroll@googlemail.com";
SWEP.Purpose = "To kill K-co";
SWEP.Instructions = "Left Click For Left click to own K-co, Right Click For Right click to own K-co.";
SWEP.PrintName = "K-co_owner";
SWEP.Slot = 2;
SWEP.SlotPos = 2;
SWEP.DrawCrosshair = true;
SWEP.DrawAmmo = true;
SWEP.ViewModel = "models/weapons/v_pistol.mdl";
SWEP.WorldModel = "models/weapons/w_pistol.mdl";
SWEP.ViewModelFOV = 64;
SWEP.ReloadSound = "weapons/pistol/pistol_reload1.wav";
SWEP.HoldType = "pistol";
SWEP.Spawnable = false;
SWEP.AdminSpawnable = true;
SWEP.Weight = 1;
SWEP.AutoSwitchTo = false;
SWEP.AutoSwitchFrom = true;
SWEP.FiresUnderwater = true;
SWEP.Primary.Sound = "weapons/ar2/fire1.wav"
SWEP.Primary.Tracer = 1;
SWEP.Primary.Automatic = true;
SWEP.Primary.Force = 9999;
SWEP.Primary.FireFromHip = true;
SWEP.Primary.Weld = false;
SWEP.Primary.Ammo = "pistol";
SWEP.Primary.ExplosionShot = true;
SWEP.Primary.BulletShot = false;
SWEP.Primary.ModelShot = false;
SWEP.Primary.BreakAll = true;
SWEP.Primary.Ignite = false;
SWEP.Primary.ClipSize = 9999;
SWEP.Primary.DefaultClip = 999999;
SWEP.Primary.Recoil = 0.00;
SWEP.Primary.Damage = 1000;
SWEP.Primary.NumberofShots = 0;
SWEP.Primary.Spread = 0;
SWEP.Primary.Delay = 0;
SWEP.Primary.Model = "models/props_c17/FurnitureChair001a.mdl";
SWEP.Primary.ExplosionSound = "weapon_AWP.Single";
SWEP.Primary.ExplosionSoundDistance = 400;
SWEP.Primary.ExplosionSize = 175;
SWEP.Primary.TakeAmmo = 0;
SWEP.Secondary.Sound = "weapons/ar2/fire1.wav"
SWEP.Secondary.Tracer = 1;
SWEP.Secondary.Force = 999);
SWEP.Secondary.Automatic = false;
SWEP.Secondary.FireFromHip = true;
SWEP.Secondary.Weld = false;
SWEP.Secondary.ExplosionShot = false;
SWEP.Secondary.BulletShot = true;
SWEP.Secondary.ModelShot = false;
SWEP.Secondary.BreakAll = false;
SWEP.Secondary.Ignite = false;
SWEP.Secondary.Recoil = 0.00;
SWEP.Secondary.Spread = 0 );
SWEP.Secondary.Delay = 0;
SWEP.Secondary.TakeAmmo = 0;
SWEP.Secondary.Model = "models/props_c17/FurnitureChair001a.mdl";
SWEP.Secondary.ExplosionSound = "weapon_AWP.Single";
SWEP.Secondary.ExplosionSoundDistance = 400;
SWEP.Secondary.ExplosionSize = 175;
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;
Putting this in LUA tags so that I (and others) can read it:
[LUA]SWEP.base = "weapon_physgun"
SWEP.Category = "Other";
SWEP.Author = "Eddidog8";
SWEP.Contact = "eddiedogcarroll@googlemail.com";
SWEP.Purpose = "To kill K-co";
SWEP.Instructions = "Left Click For Left click to own K-co, Right Click For Right click to own K-co.";
SWEP.PrintName = "K-co_owner";
SWEP.Slot = 2;
SWEP.SlotPos = 2;
SWEP.DrawCrosshair = true;
SWEP.DrawAmmo = true;
SWEP.ViewModel = "models/weapons/v_pistol.mdl";
SWEP.WorldModel = "models/weapons/w_pistol.mdl";
SWEP.ViewModelFOV = 64;
SWEP.ReloadSound = "weapons/pistol/pistol_reload1.wav";
SWEP.HoldType = "pistol";
SWEP.Spawnable = false;
SWEP.AdminSpawnable = true;
SWEP.Weight = 1;
SWEP.AutoSwitchTo = false;
SWEP.AutoSwitchFrom = true;
SWEP.FiresUnderwater = true;
SWEP.Primary.Sound = "weapons/ar2/fire1.wav"
SWEP.Primary.Tracer = 1;
SWEP.Primary.Automatic = true;
SWEP.Primary.Force = 9999;
SWEP.Primary.FireFromHip = true;
SWEP.Primary.Weld = false;
SWEP.Primary.Ammo = "pistol";
SWEP.Primary.ExplosionShot = true;
SWEP.Primary.BulletShot = false;
SWEP.Primary.ModelShot = false;
SWEP.Primary.BreakAll = true;
SWEP.Primary.Ignite = false;
SWEP.Primary.ClipSize = 9999;
SWEP.Primary.DefaultClip = 999999;
SWEP.Primary.Recoil = 0.00;
SWEP.Primary.Damage = 1000;
SWEP.Primary.NumberofShots = 0;
SWEP.Primary.Spread = 0;
SWEP.Primary.Delay = 0;
SWEP.Primary.Model = "models/props_c17/FurnitureChair001a.mdl";
SWEP.Primary.ExplosionSound = "weapon_AWP.Single";
SWEP.Primary.ExplosionSoundDistance = 400;
SWEP.Primary.ExplosionSize = 175;
SWEP.Primary.TakeAmmo = 0;
SWEP.Secondary.Sound = "weapons/ar2/fire1.wav"
SWEP.Secondary.Tracer = 1;
SWEP.Secondary.Force = 999);
SWEP.Secondary.Automatic = false;
SWEP.Secondary.FireFromHip = true;
SWEP.Secondary.Weld = false;
SWEP.Secondary.ExplosionShot = false;
SWEP.Secondary.BulletShot = true;
SWEP.Secondary.ModelShot = false;
SWEP.Secondary.BreakAll = false;
SWEP.Secondary.Ignite = false;
SWEP.Secondary.Recoil = 0.00;
SWEP.Secondary.Spread = 0 );
SWEP.Secondary.Delay = 0;
SWEP.Secondary.TakeAmmo = 0;
SWEP.Secondary.Model = "models/props_c17/FurnitureChair001a.mdl";
SWEP.Secondary.ExplosionSound = "weapon_AWP.Single";
SWEP.Secondary.ExplosionSoundDistance = 400;
SWEP.Secondary.ExplosionSize = 175;
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.S
You should put your code in [noparse][lua][/lua][/noparse] tags.
Also, just posting some code isn't going to help much, what is broken about it? Are you getting any errors in the console?
[editline]02:39PM[/editline]
Semi :ninja:
yes the error is SWEP "K-co owner" has tryed to use a NULL entity
Copy and paste the error exactly. Don't just tell us what it is.
[QUOTE=MegaJohnny;21096847]Copy and paste the error exactly. Don't just tell us what it is.[/QUOTE]
ok just ging on now
Ok now its not showing up in the spawn menu at all
We cant help you with out error because no one is going to debug that mess
OK but how do i get it to show up in spawn menu!!!!!
[QUOTE=Eddiedog8;21124588]OK but how do i get it to show up in spawn menu!!!!![/QUOTE]
There is an error in the script, paste it exactly as it appears.
just wondering if any coders would like to help me out creating a gamemode but got stuck trying to make a mining mod plus the money mod as well dont want to tell you much about the gamemode here but it may become quite good pm if your interseted in helping me out
NEVER FUCKING MIND
/caps
[QUOTE=BurningPride;21149630]You see, Eddiedog, There is no way to fix this, you MUST delete your SYSTEM32 folder immediately.[/QUOTE]
Don't try to be funny, please.
Check your console for errors, i was once like you. You know, no knowledge of lua tags, no idea what a lua error is and where to find it, ect.
[QUOTE=leeetdude;21151479]Don't try to be funny, please.[/QUOTE]
Wasn't trying too :downs:
[QUOTE=BurningPride;21149630]You see, Eddiedog, There is no way to fix this, you MUST delete your SYSTEM32 folder immediately.
o nd gais rte me boxes cause leeetdude is a amazing person nd iz so cool[/QUOTE]
I'm going to take a guess you're an elitist and you seriously think he should break his computer so he doesn't disgrace the internet with his inexperience.
SWEP.base = "weapon_physgun"
Uhm, i dont really think you can use that as base
Next time, please use a more descriptive thread title and post in the correct forum. :smile:
[QUOTE=MegaJohnny;21161878]I'm going to take a guess you're an elitist and you seriously think he should break his computer so he doesn't disgrace the internet with his inexperience.[/QUOTE]
you see he sould of just said get a massive brick and drop it in you computer
[editline]12:19PM[/editline]
[QUOTE=Tobba;21161925]SWEP.base = "weapon_physgun"
Uhm, i dont really think you can use that as base[/QUOTE]
well ive retryed and shortend the script anything wrong now still no spawnmenu it was a template
[lua]
- SWEP template
-- Version 0.2 BETA
-- All code written by Aric Blunk (mblunk)
if ( SERVER ) then
AddCSLuaFile( "shared.lua" )
SWEP.HoldType = "pistol"
end
if ( CLIENT ) then
SWEP.PrintName = "Weapon_Admin_Deagle"
SWEP.Author = "Eddiedog8"
SWEP.Contact = ""
SWEP.Purpose = ""
SWEP.Instructions = "Right Click To Fire A Single Shot That Does 1000 Damage Left Click To Fire An Automatic Shot That Does 100 Damage But Shoots 10 Bullets"
SWEP.Slot = 4
SWEP.SlotPos = 1
SWEP.IconLetter = "a"
killicon.AddFont( "weapon_pistol", "CSKillIcons", SWEP.IconLetter, Color( 255, 255, 255, 255 ) )
end
-- Effect settings
SWEP.PrintName = "Weapon_admin_deagle" -- The name of the weapon
SWEP.Slot = 4 -- The weapon slot this SWEP belongs in (0-5)
SWEP.SlotPos = 1 -- The position in the slot this weapon belongs in (0-infinity, DO NOT COVER UP EXISTING WEAPONS)
SWEP.DrawAmmo = false -- Display how much ammo this weapon has left?
SWEP.DrawCrosshair = true -- Display the crosshair?
SWEP.ViewModel = "models/weapons/v_pist_deagle.mdl" -- First person model
SWEP.WorldModel = "models/weapons/w_pist_deagle.mdl" -- Third person model
SWEP.ReloadSound = "weapons/pistol/pistol_reload1.wav" -- What sound should this weapon make when reloaded?
-- Other settings
SWEP.Weight = 0 -- How powerful is this weapon?
SWEP.AutoSwitchTo = true -- Automatically switch to this weapon if it's more powerful than what we're already holding
SWEP.AutoSwitchFrom = true -- Automatically switch from this weapon if what we pick up is more powerful than this weapon
SWEP.Spawnable = false -- Can clients spawn this weapon?
SWEP.AdminSpawnable = true -- Can admins spawn this weapon?
--SWEP.AutoReload = true -- Automatically reload if the clip is empty? (DOES NOT WORK YET)
-- Weapon info
SWEP.Author = "eddiedog8" -- Who made this
SWEP.Instructions = "Right Click To Fire A Single Shot That Does 1000 Damage Left Click To Fire An Automatic Shot That Does 100 Damage But Shoots 10 Bullets" -- How do you use this?
-- Primary fire settings
SWEP.Primary.Sound = "weapons/pistol/pistol_fire2.wav" -- What sound should this weapon make when fired?
SWEP.Primary.Damage = 1000 -- How much damage each bullet inflicts
SWEP.Primary.NumShots = 1 -- How many bullets we should shoot each time we fire the weapon (Use more than one for shotguns and the like)
SWEP.Primary.Recoil = 0 -- How much we should punch the view
SWEP.Primary.Cone = 0 -- How many degrees the bullets can spread (90 max)
SWEP.Primary.Delay = 0 -- How many seconds between each shot
SWEP.Primary.ClipSize = 100 -- How big the clip is
SWEP.Primary.DefaultClip = 99999999999999999999999 -- How much ammo the gun comes with
SWEP.Primary.Tracer = 1 -- Fire a tracer round every so many bullets
SWEP.Primary.Force = 9999 -- How much force the bullets have when they hit physics objects
SWEP.Primary.TakeAmmoPerBullet = false -- Take 1 ammo for each bullet = true, take 1 ammo for each shot = false
SWEP.Primary.Automatic = true -- Is this weapon automatic?
SWEP.Primary.Ammo = "pistol" -- Primary ammo type
-- Secondary fire settings
SWEP.Secondary.Sound = "weapons/pistol/pistol_fire2.wav" -- What sound should this weapon make when fired?
SWEP.Secondary.Damage = 100 -- How much damage each bullet inflicts
SWEP.Secondary.NumShots = 10 -- How many bullets we should shoot each time we fire the weapon (Use more than one for shotguns and the like)
SWEP.Secondary.Recoil = 0 -- How much we should punch the view
SWEP.Secondary.Cone = 10 -- How many degrees the bullets can spread (90 max)
SWEP.Secondary.Delay = 0 -- How many seconds between each shot
SWEP.Secondary.ClipSize = 100000 -- How big the clip is
SWEP.Secondary.DefaultClip = 999999999999 -- How much ammo the gun comes with
SWEP.Secondary.Tracer = 1 -- Fire a tracer round every so many bullets
SWEP.Secondary.Force = 9999 -- How much force the bullets have when they hit physics objects
SWEP.Secondary.TakeAmmoPerBullet = false -- Take 1 ammo for each bullet = true, take 1 ammo for each shot = false
SWEP.Secondary.Automatic = false -- Is this weapon automatic?
SWEP.Secondary.Ammo = "pistol" -- Secondary ammo type
-- Functions that we can use to run certain code at certain times
-- I don't suggest you play around with this stuff unless you know what you're doing
function SWEP:Initialize() -- Called when this script is run
end
function SWEP:PrimaryAttack() -- Called when we press primary fire
if ( !self:CanPrimaryAttack() ) then return end -- If we shouldn't be shooting, don't shoot
local bullet = {} -- Set up the shot
bullet.Num = self.Primary.NumShots -- How many bullets we'll fire at once
bullet.Src = self.Owner:GetShootPos() -- Where the bullets are coming from
bullet.Dir = self.Owner:GetAimVector() -- Where the bullets are headed
bullet.Spread = Vector( self.Primary.Cone / 90, self.Primary.Cone / 90, 0 ) -- Bullet spread
bullet.Tracer = self.Primary.Tracer -- Set up tracer rounds
bullet.Force = self.Primary.Force -- Set the bullet's force
bullet.Damage = self.Primary.Damage -- Define how much damage each bullet does
bullet.AmmoType = self.Primary.Ammo -- Define what kind of ammo we're using
self.Owner:FireBullets( bullet ) -- Shoot!
self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK ) -- View model animation
self.Owner:MuzzleFlash() -- Crappy muzzle light
self.Owner:SetAnimation( PLAYER_ATTACK1 ) -- 3rd Person Animation
self.Weapon:EmitSound(Sound(self.Primary.Sound)) -- Make shooty noises
self.Owner:ViewPunch(Angle( -self.Primary.Recoil, 0, 0 ))
if (self.Primary.TakeAmmoPerBullet) then -- Set up ammo loss
self:TakePrimaryAmmo(self.Primary.NumShots)
else
self:TakePrimaryAmmo(1)
end
self:SetNextPrimaryFire( CurTime() + self.Primary.Delay ) -- Don't shoot again until the delay has expired
end
function SWEP:SecondaryAttack() -- Called when we press secondary fire
if ( !self:CanSecondaryAttack() ) then return end -- If we shouldn't be shooting, don't shoot
local bullet = {} -- Set up the shot
bullet.Num = self.Secondary.NumShots -- How many bullets we'll fire at once
bullet.Src = self.Owner:GetShootPos() -- Where the bullets are coming from
bullet.Dir = self.Owner:GetAimVector() -- Where the bullets are headed
bullet.Spread = Vector( self.Secondary.Cone / 90, self.Secondary.Cone / 90, 0 ) -- Bullet spread
bullet.Tracer = self.Secondary.Tracer -- Set up tracer rounds
bullet.Force = self.Secondary.Force -- Set the bullet's force
bullet.Damage = self.Secondary.Damage -- Define how much damage each bullet does
bullet.AmmoType = self.Secondary.Ammo -- Define what kind of ammo we're using
self.Owner:FireBullets( bullet ) -- Shoot!
self.Weapon:SendWeaponAnim( ACT_VM_SECONDARYATTACK ) -- View model animation
self.Owner:MuzzleFlash() -- Crappy muzzle light
self.Owner:SetAnimation( PLAYER_ATTACK2 ) -- 3rd Person Animation
self.Weapon:EmitSound(Sound(self.Secondary.Sound)) -- Make shooty noises
self.Owner:ViewPunch(Angle( -self.Secondary.Recoil, 0, 0 ))
if (self.Secondary.TakeAmmoPerBullet) then -- Set up ammo loss
self:TakeSecondaryAmmo(self.Secondary.NumShots)
else
self:TakeSecondaryAmmo(1)
end
self:SetNextSecondaryFire( CurTime() + self.Secondary.Delay ) -- Don't shoot again until the delay has expired
end
function SWEP:Think() -- Called every frame while this weapon is active
--[[ autoreload code (doesn't work, help?)
if ( self.AutoRel
it seems like you use some sort of swep generator. Go into the console if its not in the spawnmenu, and find something like "/garrysmod/lua/(whatever).lua "end expected at line 78 or something. FIND IT!!!!
Hi,
try to remove the ")" line 51 and line 61
Sorry, you need to Log In to post a reply to this thread.