[CODE]AddCSLuaFile()
if CLIENT then
SWEP.PrintName = "AWP"
SWEP.Slot = 2
SWEP.Icon = "vgui/ttt/icon_awp"
SWEP.IconLetter = "r"
end
-- Always derive from weapon_tttbase
SWEP.Base = "weapon_tttbase"
-- Standard GMod values
SWEP.HoldType = "ar2"
SWEP.Primary.Ammo = "357"
SWEP.Primary.Delay = 2
SWEP.Primary.Recoil = 10
SWEP.Primary.Cone = 0.001
SWEP.Primary.Damage = 65
SWEP.Primary.Automatic = false
SWEP.Primary.ClipSize = 5
SWEP.Primary.ClipMax = 10
SWEP.Primary.DefaultClip = 5
SWEP.Primary.Sound = Sound( "weapons/awp1.wav" )
SWEP.Secondary.Sound = Sound( "Default.Zoom" )
-- Model properties
SWEP.UseHands = true
SWEP.ViewModelFlip = false
SWEP.ViewModelFOV = 64
SWEP.ViewModel = Model( "models/weapons/cstrike/c_snip_awp.mdl" )
SWEP.WorldModel = Model( "models/weapons/w_snip_awp.mdl" )
SWEP.IronSightsPos = Vector( 5, -15, -2 )
SWEP.IronSightsAng = Vector( 2.6, 1.37, 3.5 )
-- TTT config values
-- Kind specifies the category this weapon is in. Players can only carry one of
-- each. Can be: WEAPON_... MELEE, PISTOL, HEAVY, NADE, CARRY, EQUIP1, EQUIP2 or ROLE.
-- Matching SWEP.Slot values: 0 1 2 3 4 6 7 8
SWEP.Kind = WEAPON_HEAVY
-- If AutoSpawnable is true and SWEP.Kind is not WEAPON_EQUIP1/2, then this gun can
-- be spawned as a random weapon.
SWEP.AutoSpawnable = true
-- The AmmoEnt is the ammo entity that can be picked up when carrying this gun.
SWEP.AmmoEnt = "item_ammo_357_ttt"
-- CanBuy is a table of ROLE_* entries like ROLE_TRAITOR and ROLE_DETECTIVE. If
-- a role is in this table, those players can buy this.
SWEP.CanBuy = { nil }
-- InLoadoutFor is a table of ROLE_* entries that specifies which roles should
-- receive this weapon as soon as the round starts. In this case, none.
SWEP.InLoadoutFor = { nil }
-- If LimitedStock is true, you can only buy one per round.
SWEP.LimitedStock = true
-- If AllowDrop is false, players can't manually drop the gun with Q
SWEP.AllowDrop = true
-- If IsSilent is true, victims will not scream upon death.
SWEP.IsSilent = false
-- If NoSights is true, the weapon won't have ironsights
SWEP.NoSights = false
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
function SWEP:PrimaryAttack( worldsnd )
self.BaseClass.PrimaryAttack( self, worldsnd )
self:SetNextSecondaryFire( CurTime() + 0.1 )
end
-- Add some zoom to ironsights for this gun
function SWEP:SecondaryAttack()
if not self.IronSightsPos then return end
if self:GetNextSecondaryFire() > CurTime() then return end
local bIronsights = not self:GetIronsights()
self:SetIronsights( bIronsights )
if SERVER then
self:SetZoom( bIronsights )
else
self:EmitSound( self.Secondary.Sound )
end
self: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:Clip1() == self.Primary.ClipSize or self.Owner:GetAmmoCount( self.Primary.Ammo ) <= 0 ) then return end
self:DefaultReload( ACT_VM_RELOAD )
self:SetIronsights( false )
self:SetZoom( false )
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 scrW = ScrW()
local scrH = ScrH()
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 )
-- Cover gaps on top and bottom of screen
surface.DrawLine( 0, 0, scrW, 0 )
surface.DrawLine( 0, scrH - 1, scrW, scrH - 1 )
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
-- Equipment menu information is only needed on the client
if CLIENT then
-- Text shown in the equip menu
SWEP.EquipMenuData = {
type = "Weapon",
desc = "Silenced AWP Sniper Rifle.\n\nOnly has two shots.\n\nVictims will not scream when killed."
}
end
[/CODE]
Thank you!
worldsnd is undefined. You need to use a valid sound string
[CODE]
function SWEP:PrimaryAttack()
self.Weapon:emitsound = Sound ( "weapons/awp1.wav" )
self:SetNextSecondaryFire( CurTime() + 0.1 )
end
[/CODE]
will this work?
No. Just send the string into the worldsnd parameter of the baseclass. That'll handle the EmitSound from there
I'm sorry but i don't know how to do that I'm new in glua
[editline]4th July 2015[/editline]
Thx so much for help!!
[editline]4th July 2015[/editline]
SWEP.Primary.Sound = Sound( "weapons/awp/awp1.wav" )
fixed it
Sorry, you need to Log In to post a reply to this thread.