I took a cloaking device and turned into a TTT traitor weapon but i'm having a problem with a sound that I want it to play.
It's the reload function that isn't working correctly.
[CODE]if( SERVER ) then
end
if( CLIENT ) then
SWEP.PrintName = "Cloaking Device";
SWEP.Slot = 7;
SWEP.DrawAmmo = false;
SWEP.DrawCrosshair = false;
SWEP.EquipMenuData = {
type = "item_weapon",
desc = "Cloak yourself!"
};
end
--- TTT ---
SWEP.HoldType = "normal"
SWEP.Kind = WEAPON_EQUIP2
SWEP.CanBuy = {ROLE_TRAITOR}
SWEP.Base = "weapon_tttbase"
--- TTT END ---
SWEP.Author= "Tenteran | Edited By BobKATT"
SWEP.ViewModelFOV= 60
SWEP.ViewModelFlip= false
SWEP.Spawnable= true
SWEP.AdminSpawnable= true
SWEP.ViewModel = "models/weapons/v_hands.mdl"
SWEP.WorldModel = "models/weapons/w_package.mdl"
resource.AddFile( "invis/clicking.wav" )
-------------Primary Fire Attributes----------------------------------------
function SWEP:PrimaryAttack()
self.Weapon:SetNextSecondaryFire( CurTime() + 1 )
local TauntSound = Sound( "npc/stalker/breathing3.wav" )
self.Weapon:EmitSound( TauntSound )
// The rest is only done on the server
if (!SERVER) then return end
self.Weapon:EmitSound( TauntSound )
end
-------------Secondary Fire Attributes-------------------------------------
SWEP.Secondary.Delay= 0.5
SWEP.Secondary.Recoil= 0
SWEP.Secondary.Damage= 0
SWEP.Secondary.NumShots= 1
SWEP.Secondary.Cone= 0
SWEP.Secondary.ClipSize= -1
SWEP.Secondary.DefaultClip= -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"
function SWEP:SecondaryAttack() // conceal yourself
if ( !self.conceal ) then
self:Cloak()
else
self:UnCloak()
end
end
function SWEP:Cloak()
self.Owner:SetMaterial("models/effects/vol_light001")
self.Weapon:SetMaterial("models/effects/vol_light001")
self.Owner:PrintMessage( HUD_PRINTCENTER, "Cloak On" )
self.conceal = true
end
function SWEP:UnCloak()
self.Owner:SetMaterial("models/glass")
self.Weapon:SetMaterial("models/glass")
self.Owner:PrintMessage( HUD_PRINTCENTER, "Cloak Off" )
self.conceal = false
end
function SWEP:Reload() -- Not playing sound.
if (!SERVER) then return end
self.Weapon:EmitSound( "npc/stalker/go_alert2a.wav" )
end
function SWEP:OnDrop()
self:UnCloak()
end[/CODE]
Isn't there a SWEP.ReloadSound property?
The "if (!SERVER)" thing is probably causing the sound to not play on the client at all too, now that I think about it, sue me if I'm wrong but it could be worth omitting that line and seeing what happens
Ok I ended up removing the reloading function. Thanks for the help anyway! Here's the code now.
[CODE]if( SERVER ) then
end
if( CLIENT ) then
SWEP.PrintName = "Cloaking Device";
SWEP.Slot = 7;
SWEP.DrawAmmo = false;
SWEP.DrawCrosshair = false;
SWEP.EquipMenuData = {
type = "item_weapon",
desc = "Cloak yourself!"
};
end
--- TTT ---
SWEP.HoldType = "normal"
SWEP.Kind = WEAPON_EQUIP2
SWEP.CanBuy = {ROLE_TRAITOR}
SWEP.Base = "weapon_tttbase"
--- TTT END ---
SWEP.Author= "Tenteran | Edited By BobKATT"
SWEP.ViewModelFOV= 60
SWEP.ViewModelFlip= false
SWEP.Spawnable= true
SWEP.AdminSpawnable= true
SWEP.ViewModel = "models/weapons/v_hands.mdl"
SWEP.WorldModel = ""
-------------Primary Fire Attributes----------------------------------------
function SWEP:PrimaryAttack()
self.Weapon:SetNextSecondaryFire( CurTime() + 1 )
self:SetNextPrimaryFire(CurTime()+5)
local result = math.random(1, 2)
if result == 1 then
TauntSound = Sound("npc/stalker/breathing3.wav")
else
TauntSound = Sound("npc/stalker/go_alert2a.wav")
end
self:SetNextPrimaryFire(CurTime()+2)
self.Weapon:EmitSound( TauntSound )
// The rest is only done on the server
if (!SERVER) then return end
self.Weapon:EmitSound( TauntSound )
end
-------------Secondary Fire Attributes-------------------------------------
SWEP.Secondary.Delay= 0.5
SWEP.Secondary.Recoil= 0
SWEP.Secondary.Damage= 0
SWEP.Secondary.NumShots= 1
SWEP.Secondary.Cone= 0
SWEP.Secondary.ClipSize= -1
SWEP.Secondary.DefaultClip= -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"
function SWEP:SecondaryAttack() // conceal yourself
if ( !self.conceal ) then
self:Cloak()
else
self:UnCloak()
end
end
function SWEP:Cloak()
self.Owner:SetMaterial("models/effects/vol_light001")
self.Weapon:SetMaterial("models/effects/vol_light001")
self.Owner:PrintMessage( HUD_PRINTCENTER, "Cloak On" )
self.conceal = true
end
function SWEP:UnCloak()
self.Owner:SetMaterial("models/glass")
self.Weapon:SetMaterial("models/glass")
self.Owner:PrintMessage( HUD_PRINTCENTER, "Cloak Off" )
self.conceal = false
end
function SWEP:OnDrop()
self:UnCloak()
end[/CODE]
Although, when people die while cloaked or cloaked when round ends. They stay cloaked.
Make an if like
if ply is dead uncloak if rounds end uncloak.
Use the "PlayerDeath" and "TTTEndRound" hooks.
Sorry, you need to Log In to post a reply to this thread.