Global sound concommand.

Alright, for some reason I can’t get my sound file to play for everyone on the server. My code looks like this:



function PlaySound ( Ply, Cmd, Args )
		local sound = Args[1]
		
		if ( sound ) then
			if ( string.match( sound, "^[a-zA-Z0-9/]+.wav$" ) ) then
				if ( !file.Exists( "../sound/" .. sound ) ) then
					print( "Sound \"" .. sound .. "\" not found!" )
					return
				end
			end
			
			for k, v in pairs( player.GetAll() ) do
				v:ConCommand( "play " .. sound )
			end
			
		else
			print("No sound was specified yet!" )
		end
end
concommand.Add("testsound", PlaySound);


When I run type testsound <sound path> in console, only I can hear the file being played. Any idea why the others cannot hear it? The function is on a shared file.

Do the other players have the sound?

Yep, everyone downloads the file before joining. I could even try to play one of the HL2 sounds, but only I hear it.

I’ll write a similar function:
function random()
for k, v in pairs(player.GetAll()) do
v:Kick();
end;
end;
concommand.Add(“Kickall”, random);

This yet again, would only kick me, not the whole server. Perhaps concommand.Add is the culprit?

Well this works fine on my server. [lua]
function random()
for k, v in pairs(player.GetAll()) do
v:Kick(“To cool for school”)
end
end
concommand.Add(“KickAll”, random)
[/lua]

I put it server-side and it worked.

Thanks for the help.

**[G.WorldSound

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