Ply:EmitSound?

1st off will this work and be locational to the person or will it come out omnipresent?
and 2nd If its omnipresent then how do I play it locational…and It would have to be a server/shared function…

Oh and also side question, If I wanted to do something on server/shared when a certain player shoots what would or could I hook to?

First you should know that “ply” is just an arbitrary name that someone used to keep a reference to an object, in this case an entity that is also a player. Entities have a number of methods which can be used on them including EmitSound. So to get a player to emit sound you will first need to grab a reference to it’s object and then use the method on it.

Now that this is out of the way, : **[Entity.EmitSound

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Entity.EmitSound)** emits sound from the entity and it is only audible within a certain radius.

As to detecting when a player shoots… well the closest and simplest thing would be detecting when they press Mouse 1, which can be accomplished with the following untested code :
[lua]hook.Add(“KeyPress”,“AttackDetection”,function(ply,key)
if key == IN_ATTACK then
– Code here
end
end)[/lua]

**[Gamemode.KeyPress

http://wiki.garrysmod.com/favicon.ico](wiki.garrysmod.com/?title=Gamemode.KeyPress)**