Just for safe measures, I'll ask here too.

Hello. I don’t trust the What Do You Need Help With Thread V3. I’ve been having problems with this for a while. I am trying to create replicas of the HL2 weapons, but change some of how they act (as if a NPC were using them). They will also kick a little differently, and be more realistic.
Could someone please help me?

[lua]SWEP.Author = "LuaVirusFree"SWEP.Contact = “sabarbee@wccnet.edu”
SWEP.Purpose = “Aim, shoot, dispatch.”
SWEP.Instructions = “Primary shoots.”

SWEP.Spawnable = false
SWEP.AdminSpawnable = true

SWEP.ViewModel = “models/weapons/v_pistol.mdl”
SWEP.WorldModel = “models/weapons/w_pistol.mdl”

SWEP.Primary.ClipSize = 18
SWEP.Primary.DefaultClip = 0 – We don’t want to start loaded.
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = “AlyxGun”

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

local ShootSound = Sound( “Weapon_Pistol.NPC_Single” )
local ReloadSound = Sound( “Weapon_Pistol.NPC_Reload” )
local EmptySound = Sound( “Weapon_Pistol.Empty” )
local BurstSound = Sound( “Weapon_Pistol.Burst” )
local SwitchSingleSound = Sound( “Weapon_Pistol.Special1” )
local SwitchBurstSound = Sound( “Weapon_Pistol.Special2” )

/---------------------------------------------------------
Reload reloads.
---------------------------------------------------------
/
function SWEP:Reload()
if self:Clip1() == 18 then self.Clip1 = 19 end
self.Weapon:EmitSound( ReloadSound )
self:DefaultReload( ACT_VM_RELOAD )
end

local ReloadTime = CurTime()
/---------------------------------------------------------
Think reloads
---------------------------------------------------------
/
local ReloadTime = CurTime()
function SWEP:Think()
if self:Clip1() < 18 && CurTime() > ReloadTime then
self.Owner:SetAmmo( 19, “Pistol” )
self:Reload()
end
if self.Owner:KeyPressed( IN_ATTACK ) then
ReloadTime = CurTime() + 7
end
end

–function SWEP:CanPrimaryAttack()
– if self:Clip1 < 8 then return false end
–end

/---------------------------------------------------------
PrimaryAttack
---------------------------------------------------------
/
function SWEP:PrimaryAttack()

if !self:CanPrimaryAttack() then self.Weapon:EmitSound( EmptySound ) return end

– TODO: Make and shoot bullet entity. Reduce ammo.
if !BurstFireMode then
local Player = self.Owner
Player:TakePrimaryAmmo(1)
local Bullet = {}
if SERVER then
Bullet.Nine = ents.Create( “bullet_Nine” )
Bullet.Nine:SetPos( Player:GetShootPos() ) – TODO: Get the world model’s muzzle?
Bullet.Nine:SetAngles( self.Owner:GetAngles() )
Bullet.Nine:Spawn()
Bullet.Nine:Activate()
Bullet.Nine:SetOwner( Player )

local bulPhy = Bullet.Nine:GetPhysicsObject()
bulPhy:SetVelocity((self.Owner:GetAngles()+ Angle(1, 0, 0)):Forward() * 33600 ) – 5.7mm Muzzle Velocity.
Bullet.Nine:SetVar(“Velocity”,33600)
– Bullet.Nine:SetVar(“Acceleration”,accel)
– local Force = Angle:__add(Player:GetAimVector(), Angle(-30, 0, 0) )*256
– bulPhy:SetVelocity((self.Owner:GetAngles()+ Angle(45, 0, 0)):Forward() * 1 * CurTime() * 1)
end
– Bullet.AngTr = Angle(self.Owner:GetAngles()+ Angle(45, 0, 0))–:Forward()
– Bullet.AngTr2 = Angle(self.Owner:GetAngles()+Angle(-45, 0, 0))–:Forward()

self.Weapon:EmitSound( ShootSound )
self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
– timer.Simple( 0.3, self.Weapon.SendWeaponAnim, self, ACT_VM_IDLE )

self.Weapon:SetNextPrimaryFire( CurTime()+0.4 )
self.Weapon:SetNextSecondaryFire( CurTime()+2 )
self:ApplyRecoil(0.93,NewSpray)
elseif BurstFireMode then
local Player = self.Owner
local Bullet = {}
local function ShootBurret()
if self:Clip1() < 1 then return end
if self:Clip1() < 3 then
self:EmitSound( ShootSound )
end
Player:TakePrimaryAmmo(1)
if SERVER then
Bullet.Nine = ents.Create( “bullet_Nine” )
Bullet.Nine:SetPos( Player:GetShootPos() ) – TODO: Get the world model’s muzzle?
Bullet.Nine:SetAngles( self.Owner:GetAngles() )
Bullet.Nine:Spawn()
Bullet.Nine:Activate()
Bullet.Nine:SetOwner( Player )

local bulPhy = Bullet.Nine:GetPhysicsObject()
bulPhy:SetVelocity((self.Owner:GetAngles()+ Angle(1, 0, 0)):Forward() * 33600 )
end
self:ApplyRecoil(0.73,NewSpray) – Lil less kick for burst.
end
ShootBurret()
timer.Simple(0.1, ShootBurret())
timer.Simple(0.2, ShootBurret())
if self:Clip1() >= 3 then
self.Weapon:EmitSound( BurstSound )
end
self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK )

self.Weapon:SetNextPrimaryFire( CurTime()+0.4 )
self.Weapon:SetNextSecondaryFire( CurTime()+2 )
end
if self:Clip1()-1 <= 0 then timer.Simple(0.4, self:Reload()) end

eBullet:SetPos(PlayerPos)
eBullet:SetVar(“Velocity”,Velocity)
eBullet:SetVar(“Acceleration”,accel)

local tBullet = {} – This is the bullet our bullet SENT will be firing when it hits something. Everything except force and damage is determined by the bullet SENT
tBullet.Force = 0.15*3
tBullet.Damage = 3

local tTrace = {} --This is the trace the bullet SENT uses to see if it has hit something
tTrace.filter = filter or {self.Owner,eBullet}
tTrace.mask = mask

eBullet:SetVar(“Bullet”,tBullet)
eBullet:SetVar(“Trace”,tTrace)
eBullet:SetVar(“Owner”,self.Owner)
eBullet:Spawn()

eBullet:Spawn()
end
function SWEP:ApplyRecoil(recoil) – Kick your view.

if self.OwnerIsNPC or (SERVER and not self.Owner:IsListenServerHost()) then return end

local EyeAng = Angle(
recoilmath.Rand(-1,-0.7), – Up/Down recoil
recoil
math.Rand(-0.4,0.4), – Left/Right recoil
0)

– Punch the player’s view
self.Owner:ViewPunch(EyeAng) – This smooths out the player’s screen movement when recoil is applied
self.Owner:SetEyeAngles(self.Owner:EyeAngles() + EyeAng)

end
–[[
function SWEP:DoDMG(EntHit)
local OldHealth = EntHit:GetHealth()
local dmginfo = DamageInfo()
local DMGToDo=math.min(OldHealth-1,ATKPower)
local LostDmg = OldHealth-DMGToDo
dmginfo:SetDamage( DMGToDo ) – 7 damage or whatever is left-1
dmginfo:SetDamageType( DMG_STUN ) --Stun damage
dmginfo:SetAttacker( self.Owner ) --You.
dmginfo:SetSetInflictor( self )
dmginfo:SetDamageForce( self.Owner:EyeAngles()*20 ) --Launch away

local HealSteps=OldHealth-LostDmg
EntHit:TakeDamageInfo( dmginfo )
Player:GiveAmmo( ATKPower, “GaussEnergy”, true )
for i=1,HealSteps do
timer.Simple(0.05i,function() EntHit:SetHealth( OldHealth + 1i end ) ) – In at most 0.65 seconds, replenish health damage. TODO? Is it dead?
end
end
]]–
/---------------------------------------------------------
SecondaryAttack switches fire mode.
---------------------------------------------------------
/
local BurstFireMode = false
function SWEP:SecondaryAttack()
if !BurstFireMode then
BurstFireMode = true
self.Weapon:EmitSound( SwitchBurstSound )
end
if BurstFireMode then
BurstFireMode = false
self.Weapon:EmitSound( SwitchSingleSound )
end
self.Weapon:SetNextPrimaryFire( CurTime()+0.4 )
self.Weapon:SetNextSecondaryFire( CurTime()+2 )
end

function SWEP:Initialize()
– self:EmitSound( Activated )
local Player=self.Owner
self.Owner:SetAmmo( math.max(19, Player:GetAmmoCount(“Pistol”)), “Pistol” ) – The REAL line 202
end[/lua]

The line numbers are wrong after a certain point, so I labeled the actual line “The Real Line”.



[ERROR] addons/combinification/lua/weapons/pistol/shared.lua:201: attempt to call method 'GetAmmoCount' (a nil value)
1. unknown - addons/combinification/lua/weapons/pistol/shared.lua:201

[editline]20th January 2013[/editline]

My old helper got perma-banned, but he would’ve already given me a solution. If that didn’t work, another one. His name was, I believe, Ninjas. Maybe he made a new account?

[editline]20th January 2013[/editline]

I will have these weapons: Stun Baton, USP Match Pistol, MP7 SMG, Buckshot Shotgun and 2x AR2 Pulse Rifle, one that alt-fires and one that can’t.