I have some code for a MK17 I am trying to fix on the Steam Workshop but I cannot seem to get Tracers or the Muzzle Flash to work
The tracer seems to be bugged in some way as they never appear from the gun but after a few seconds I may see the flash go to the point of impact a few seconds later from a completely different direction.
Help and any ideas will be greatly appreciated
Edit: Also to note this is intended for Trouble in Terrorist Town
[QUOTE]SWEP.Icon = "VGUI/ttt/icon_mk17"
SWEP.MuzzleAttachment = "1" -- Should be "1" for CSS models or "muzzle" for hl2 models
SWEP.ShellEjectAttachment = "2" -- Should be "2" for CSS models or "1" for hl2 models
SWEP.DrawCrosshair = false
SWEP.ViewModelFOV = 70
SWEP.ViewModelFlip = true
SWEP.ViewModel = "models/weapons/v_snip_mk17m.mdl"
SWEP.WorldModel = "models/weapons/w_snip_mk17m.mdl"
SWEP.Base = "weapon_tttbase"
SWEP.Kind = WEAPON_HEAVY
SWEP.Spawnable = true
SWEP.AdminSpawnable = true
SWEP.AutoSpawnable = true
SWEP.HoldType = "ar2"
SWEP.Primary.Sound = Sound("weapons/fokku_mk17/shot-1.wav")
SWEP.Primary.Damage = 35
SWEP.Primary.NumShots = 1
SWEP.Primary.Recoil = 6
SWEP.Primary.KickDown = 2 // Maximum down recoil (skeet)
SWEP.Primary.KickHorizontal = 0.6
SWEP.Primary.Cone = 0.0001
SWEP.Primary.Delay = 1
SWEP.Primary.ClipSize = 10 // Size of a clip
SWEP.Primary.ClipMax = 20
SWEP.Primary.DefaultClip = 10 // Default number of bullets in a clip
SWEP.Primary.Tracer = 3
SWEP.Primary.TracerType = "AR2Tracer"
SWEP.Primary.Force = 2
SWEP.Primary.Automatic = false // Automatic/Semi Auto
SWEP.Primary.Ammo = "357"
SWEP.AmmoEnt = "item_ammo_357_ttt"
SWEP.HeadshotMultiplier = 5
SWEP.Secondary.ClipSize = 1 // Size of a clip
SWEP.Secondary.DefaultClip = 1 // Default number of bullets in a clip
SWEP.Secondary.Automatic = false // Automatic/Semi Auto
SWEP.Secondary.Ammo = ""
SWEP.Secondary.ScopeZoom = 10
SWEP.Secondary.UseRangefinder = true
SWEP.Secondary.UseMilDot = true
SWEP.Secondary.Sound = Sound("Default.Zoom")
SWEP.data = {} -- The starting firemode
SWEP.data.ironsights = 1
SWEP.ScopeScale = 0.7
SWEP.Velocity = 850
SWEP.IronSightsPos = Vector (-2.7031, -0-.5539, 1.6562)
SWEP.IronSightsAng = Vector (0, 0, 0)
SWEP.Offset = {
Pos = {
Up = 0,
Right = 1,
Forward = -3,
},
Ang = {
Up = 0,
Right = 0,
Forward = 0,
}
}
function SWEP:PrimaryAttack()
if ( !self:CanPrimaryAttack() ) then return end
local bullet = {} -- Set up the shot
bullet.Num = self.Primary.NumShots
bullet.Src = self.Owner:GetShootPos()
bullet.Dir = self.Owner:GetAimVector()
bullet.Spread = Vector( self.Primary.Cone / 90, self.Primary.Cone / 90, 0 )
bullet.tracer = self.Primary.Tracer
bullet.tracerName = self.Primary.TracerType
bullet.Force = self.Primary.Force
bullet.Damage = self.Primary.Damage
bullet.AmmoType = self.Primary.Ammo
self.Owner:FireBullets( bullet )
self.Owner:MuzzleFlash()
self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK )
self.Owner:SetAnimation( PLAYER_ATTACK1 )
self.Weapon:EmitSound(Sound(self.Primary.Sound))
self.Owner:ViewPunch(Angle( -self.Primary.Recoil, 0, 1 ))
if (self.Primary.TakeAmmoPerBullet) then
self:TakePrimaryAmmo(self.Primary.NumShots)
else
self:TakePrimaryAmmo(1)
end
self:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
end
function SWEP:DrawWorldModel( )
local hand, offset, rotate
if not IsValid( self.Owner ) then
self:DrawModel( )
return
end
if not self.Hand then
self.Hand = self.Owner:LookupAttachment( "anim_attachment_rh" )
end
hand = self.Owner:GetAttachment( self.Hand )
if not hand then
self:DrawModel( )
return
end
offset = hand.Ang:Right( ) * self.Offset.Pos.Right + hand.Ang:Forward( ) * self.Offset.Pos.Forward + hand.Ang:Up( ) * self.Offset.Pos.Up
hand.Ang:RotateAroundAxis( hand.Ang:Right( ), self.Offset.Ang.Right )
hand.Ang:RotateAroundAxis( hand.Ang:Forward( ), self.Offset.Ang.Forward )
hand.Ang:RotateAroundAxis( hand.Ang:Up( ), self.Offset.Ang.Up )
self:SetRenderOrigin( hand.Pos + offset )
self:SetRenderAngles( hand.Ang )
self:DrawModel( )
end
function SWEP:SetZoom(state)
if CLIENT then
return
elseif IsValid(self.Owner) and self.Owner:IsPlayer() then
if state then
self.Owner:SetFOV(20, 0.3)
else
self.Owner:SetFOV(0, 0.2)
end
end
end
-- Add some zoom to ironsights for this gun
function SWEP:SecondaryAttack()
if not self.IronSightsPos then return end
if self.Weapon:GetNextSecondaryFire() > CurTime() then return end
bIronsights = not self:GetIronsights()
self:SetIronsights( bIronsights )
if SERVER then
self:SetZoom(bIronsights)
else
self:EmitSound(self.Secondary.Sound)
end
self.Weapon:SetNextSecondaryFire( CurTime() + 0.3)
end
function SWEP:PreDrop()
self:SetZoom(false)
self:SetIronsights(false)
return self.BaseClass.PreDrop(self)
end
function SWEP:Reload()
if self.ReloadingTime and CurTime() <= self.ReloadingTime then return end
if ( self:Clip1() < self.Primary.ClipSize and self.Owner:GetAmmoCount( self.Primary.Ammo ) > 0 ) then
self.Weapon:DefaultReload( ACT_VM_RELOAD )
local AnimationTime = self.Owner:GetViewModel():SequenceDuration()
self.ReloadingTime = CurTime() + AnimationTime
self:SetNextPrimaryFire(CurTime() + AnimationTime)
self:SetNextSecondaryFire(CurTime() + AnimationTime)
self.Weapon:EmitSound("weapons/fokku_mk17/reload.wav")
self:SetIronsights( false )
self:SetZoom(false)
end
end
function SWEP:Holster()
self:SetIronsights(false)
self:SetZoom(false)
return true
end
if CLIENT then
local scope = surface.GetTextureID("sprites/scope")
function SWEP:DrawHUD()
if self:GetIronsights() then
surface.SetDrawColor( 0, 0, 0, 255 )
local x = ScrW() / 2.0
local y = ScrH() / 2.0
local scope_size = ScrH()
-- crosshair
local gap = 80
local length = scope_size
surface.DrawLine( x - length, y, x - gap, y )
surface.DrawLine( x + length, y, x + gap, y )
surface.DrawLine( x, y - length, x, y - gap )
surface.DrawLine( x, y + length, x, y + gap )
gap = 0
length = 50
surface.DrawLine( x - length, y, x - gap, y )
surface.DrawLine( x + length, y, x + gap, y )
surface.DrawLine( x, y - length, x, y - gap )
surface.DrawLine( x, y + length, x, y + gap )
-- cover edges
local sh = scope_size / 2
local w = (x - sh) + 2
surface.DrawRect(0, 0, w, scope_size)
surface.DrawRect(x + sh - 2, 0, w, scope_size)
surface.SetDrawColor(255, 0, 0, 255)
surface.DrawLine(x, y, x + 1, y + 1)
-- scope
surface.SetTexture(scope)
surface.SetDrawColor(255, 255, 255, 255)
surface.DrawTexturedRectRotated(x, y, scope_size, scope_size, 0)
else
return self.BaseClass.DrawHUD(self)
end
end
function SWEP:AdjustMouseSensitivity()
return (self:GetIronsights() and 0.2) or nil
end
end
if SERVER then
resource.AddFile("materials/VGUI/ttt/icon_mk17.vmt")
end[/QUOTE]
Sorry, you need to Log In to post a reply to this thread.