• Play a sound when a player is near
    4 replies, posted
Hey ! I'm working on the Pedobear vs victims gamemode, and I would like to play a sound when the pedobear (who here is a people) on victims when he's approaching them. Like a taunt. How can I do that ? Sorry for my bad english, and thank you in advance ;)
If the "Pedobear" is an entity, you can do: local sSnd = "ambient/energy/zap6.wav" -- HL2 sounds local nDst = 100 -- A hundred Garry's mod distance units local tPly, vDir = player.GetAll(), Vector() for k, v in pairs(tPly) do local vPps = v:GetPos() vDir:Set(Pedobear:GetPos()); vDir:Sub(vPps) if(vDir:Length() < nDst) then sound.Play(sSnd, vPps, 50, 100, 1) end end
Thank you, but the pedobear is played by a people and is in a seperated team than the victims ^^
As long as it is an entity it will work ;) as every entity has a SetPos() method ^^
Ok thanks a lot !
Sorry, you need to Log In to post a reply to this thread.