-snip-
-snip snip snippety-
It doesn’t seem to work.
After enabling ammo display, it shows the ammo does indeed deplete whenever the player is flying, but after a certain amount of time it depletes to zero, but reloads despite being in the air. After 3 reloads or so, it stops reloading entirely (even when on the ground) and the player cannot fly at all despite there being more ammo to reload into the clip.
Thanks so much for the help, I’m sure you have better things to do than helping a lua newbie finish an SWEP;
[lua]AddCSLuaFile( “shared.lua” )
SWEP.Author = “Eagle with Garry’s laser dance SWEP and Zcom’s lua help.”
SWEP.Contact = “”
SWEP.Purpose = “”
SWEP.Instructions = “Left mouse flies, right click performs a stormy swipe which can send objects flying.”
if ( CLIENT ) then
SWEP.PrintName = “X” // ‘Nice’ Weapon name (Shown on HUD)
SWEP.Slot = 0 // Slot in the weapon selection menu
SWEP.SlotPos = 10 // Position in the slot
SWEP.DrawAmmo = false // Should draw the default HL2 ammo counter
SWEP.DrawCrosshair = false // Should draw the default crosshair
SWEP.DrawWeaponInfoBox = false // Should draw the weapon info box
SWEP.BounceWeaponIcon = false // Should the weapon icon bounce?
SWEP.SwayScale = 1.0 // The scale of the viewmodel sway
SWEP.BobScale = 1.0 // The scale of the viewmodel bob
SWEP.WepSelectIcon = surface.GetTextureID( “weapons/swep” )
SWEP.HoldType = “crowbar”
end
SWEP.ViewModelFOV = 62
SWEP.ViewModelFlip = false
SWEP.ViewModel = “”
SWEP.WorldModel = “”
SWEP.AnimPrefix = “python”
SWEP.Spawnable = false
SWEP.AdminSpawnable = false
SWEP.Primary.ClipSize = 1000 // Size of a clip
SWEP.Primary.DefaultClip = 1000 // Default number of bullets in a clip
SWEP.Primary.Automatic = true // Automatic/Semi Auto
SWEP.Primary.Ammo = “pistol”
SWEP.Primary.TakeAmmo = 1
SWEP.Secondary.ClipSize = -1 // Size of a clip
SWEP.Secondary.DefaultClip = -1 // Default number of bullets in a clip
SWEP.Secondary.Automatic = true // Automatic/Semi Auto
SWEP.Secondary.Ammo = “none”
/---------------------------------------------------------
Name: SWEP:PrimaryAttack( )
Desc: +attack1 has been pressed
---------------------------------------------------------/
function SWEP:Think()
end
function SWEP:PrimaryAttack( )
– Can’t fire if the clip is empty
if ( self.Weapon:Clip1( ) < 1 ) then return; end
-- How fast the player will be pushed forward
local vel = 20
self.Owner:SetVelocity( self.Owner:GetAimVector( ) * vel )
self.Weapon:TakePrimaryAmmo( 1 )
end
/---------------------------------------------------------
Name: SWEP:SecondaryAttack( )
Desc: +attack2 has been pressed
---------------------------------------------------------/
function SWEP:SecondaryAttack()
self.Weapon:SetNextSecondaryFire(CurTime() + .4)
local trace = self.Owner:GetEyeTrace()
if trace.HitPos:Distance(self.Owner:GetShootPos()) <= 75 then
self.Weapon:SendWeaponAnim(ACT_VM_HITCENTER)
bullet = {}
bullet.Num = 1
bullet.Src = self.Owner:GetShootPos()
bullet.Dir = self.Owner:GetAimVector()
bullet.Spread = Vector(0, 0, 0)
bullet.Tracer = 0
bullet.Force = 700
bullet.Damage = 100
self.Owner:FireBullets(bullet)
self.Owner:SetAnimation( PLAYER_ATTACK1 );
self.Weapon:EmitSound(“physics/flesh/flesh_impact_bullet” … math.random( 3, 5 ) … “.wav”)
else
self.Weapon:EmitSound(“weapons/iceaxe/iceaxe_swing1.wav”)
self.Weapon:SendWeaponAnim(ACT_VM_MISSCENTER)
end
end
function SWEP:Reload( )
if ( !SERVER ) then return; end
-- Cannot reload unless OnGround is true
if ( !self.Owner:OnGround( ) ) then return false; end
-- Gives the player exactly how many bullets he fired before reloading (Inf. Ammo)
self.Owner:GiveAmmo( self.Primary.ClipSize, "Pistol" )
end
/---------------------------------------------------------
Name: SWEP:ShootBullet( )
Desc: A convenience function to shoot bullets
---------------------------------------------------------/
function SWEP:ShootEffects()
self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK ) // View model animation
self.Owner:MuzzleFlash() // Crappy muzzle light
self.Owner:SetAnimation( PLAYER_ATTACK1 ) // 3rd Person Animation
end
/---------------------------------------------------------
Name: SWEP:ShootBullet( )
Desc: A convenience function to shoot bullets
---------------------------------------------------------/
function SWEP:ShootBullet( damage, num_bullets, aimcone )
local bullet = {}
bullet.Num = num_bullets
bullet.Src = self.Owner:GetShootPos() // Source
bullet.Dir = self.Owner:GetAimVector() // Dir of bullet
bullet.Spread = Vector( aimcone, aimcone, 0 ) // Aim Cone
bullet.Tracer = 1 // Show a tracer on every x bullets
bullet.Force = 10 // Amount of force to give to phys objects
bullet.Damage = damage
bullet.AmmoType = "Pistol"
bullet.HullSize = 2
bullet.TracerName = "LaserTracer"
self.Owner:FireBullets( bullet )
self:ShootEffects()
end
[/lua]