How do I add a song to my server and make it play when ever a admin joins?
Change your avatar. I can only stand so many assholes in one day. Oh…and I don’t know.
Use something like:
if not SERVER then return end hook.Add("PlayerAuthed", "SoundPlayOnAdminAuth", function(ply, SteamID, UniqueID) if ply:IsAdmin() or ply:IsSuperAdmin() then ply:EmitSound("music/HL2_song17.mp3") end end)
Written in 5 minutes and untested. This would play a sound when an admin first spawns (auths). You can make the sound play when a player connects (about 5 minutes before they actually get to the server) by changing the hook from “PlayerAuthed” to “PlayerConnect”.
To use the said code:
- Change the quoted string to the sound path. If the sound were located at “garrysmod/sound/adminjoin.mp3”, then you would change set the string to “adminjoin.mp3” (it’s relative to the sound directory)
- Paste it in a file, name it whatever you want, with a lua extension, then save it in garrysmod/lua/autorun/server/.
This emits the sound out of the player. Is there a way to emit it globally (so you can hear it from anywhere in the map)?
One way is to loop through every player and run it. surface.playsound works too