I would like to have a small script where if you're a traitor it plays a sound file when you get 3 kills and a different sound when you're a detective and you get 1 traitor kill but only the player can hear it. How would I do that? Where would I put the file anyway?
[code]-- lua/autorun/
local TSound = "items/ammo_pickup.wav" -- Sound for traitor; set relative to sound/
local DSound = "items/ammo_pickup.wav" -- Sound for detective; set relative to sound/
-----------------------
if ( SERVER ) then
util.AddNetworkString( "send_sound" )
local kills = kills or 0
function SendKillSound( ply )
net.Start( "send_sound" )
net.WriteEntity( ply )
net.Broadcast()
end
function KillSound( vic, wep, att )
if ( not IsValid( att ) or not IsValid( vic ) or vic == att or att:IsInnocent() ) then return end
if ( att:IsDetective() and vic:IsTraitor() ) then
SendKillSound( att )
return
end
if ( vic:IsTraitor() ) then return end
kills = kills + 1 or 0
if ( att:IsTraitor() and kills % 3 == 0 ) then
SendKillSound( att )
end
end
hook.Add( "PlayerDeath", "DeathSound", KillSound )
hook.Add( "TTTPrepareRound", "ResetKills", function() kills = 0 end )
end
if ( CLIENT ) then
function PlayKillSound( ply )
if ( not IsValid( ply ) or not ( LocalPlayer() == ply ) ) then return end
if ( ply:IsTraitor() ) then
surface.PlaySound( TSound )
else
surface.PlaySound( DSound )
end
end
net.Receive( "send_sound", function() PlayKillSound( net.ReadEntity() ) end )
end[/code]
Will only the traitor or detective hear it?
[QUOTE=piscaso;45529634]Will only the traitor or detective hear it?[/QUOTE]
Yes.
Didn't work
Post the sound paths you used.
local TSound = "sound/kira.mp3" -- Sound for traitor; set relative to sound/
local DSound = "sound/l.mp3" -- Sound for detective; set relative to sound/
I said relative to sound, meaning don't include sound/ in the path.
still nothing
Sorry about that. Thought I posted the updated code already, but it didn't seem to go through. Try now with the new code.
What new code?
Oh I see it
Nothing
Try now.
Can I change what the TSound and DSound are?
[editline]31st July 2014[/editline]
Still nothing
But I think it might be destroying my server for some reason.
Sorry, you need to Log In to post a reply to this thread.