How would I go about making a player emit a sound in a function, and doing it every random time between 10-15 seconds? math.Rand( 10, 15) ?
[url]http://wiki.garrysmod.com/?title=Think[/url]
Use [b][url=http://wiki.garrysmod.com/?title=Surface.PlaySound]Surface.PlaySound[/url][/b] to play a sound clientside. (no one else but the client can hear it).
There is also [b][url=http://wiki.garrysmod.com/?title=Entity.EmitSound]Entity.EmitSound[/url][/b] where the entity emits a sound, relative to its location, and all other players can hear it within range.
How you call these is up to you. You could use a constant,repeating [b][url=http://wiki.garrysmod.com/?title=Timer]timer[/url][/b], or like [b][url=http://www.facepunch.com/showpost.php?p=17537387&postcount=2]Emz said[/url][/b], you could use a [b][url=http://wiki.garrysmod.com/?title=Gamemode.Think]Think hook[/url][/b] along with [b][url=http://wiki.garrysmod.com/?title=Curtime]Curtime[/url][/b].
How you get the player entity is again, varies with different methods.
How would I take Entity.EmitSound and have the player be selected as the entity?
[QUOTE=Kanshi;17537996]How would I take Entity.EmitSound and have the player be selected as the entity?[/QUOTE]
[lua]
ply:EmitSound("Path/To/Sound.wav", 500, 200)
[/lua]
Oh! hehe, that simple? Thanks Helix :D
[QUOTE=Helix Alioth;17538548][lua]
ply:EmitSound("Path/To/Sound.wav", 500, 200)
[/lua][/QUOTE]
The 500 and 200 are relative to the volume and pitch, remember that, they're optional though.
Sorry, you need to Log In to post a reply to this thread.