Can anybody help me with a bit of scripting?

Hello! I know you guys must have a lot of lua-inept members come through here, but I would really appreciate a bit of help with an admin alert script.

What I would like is to have this following code be for individual admins, based off of steamID, instead of all admins who join (so that different admins get different sounds and some not at all).



function AdminAlert( pl )
	if pl:IsAdmin() then
	    for k, v in pairs(player.GetAll()) do
		    v:PrintMessage(HUD_PRINTCENTER,"Admin has joined the server!") 
		    v:ConCommand("play admin_alert.mp3")
			
		end
	end
end
	
hook.Add( "PlayerInitialSpawn", "playerInitialSpawn", AdminAlert )

Any help would be great!

i am not sure if it works or if it is even right since i am not next to my game but it doesn’t hurt to try.

[lua]
function AdminAlert( pl )

admin1 = “steamID”
admin2 = “steamID”
admin3 = “steamID”

if !pl:IsAdmin() then
for k, v in pairs(player.GetAll()) do
v:PrintMessage(HUD_PRINTCENTER,“Admin has joined the server!”)
v:ConCommand(“play guestsong.mp3”) // <======= this is for players not admins
end

if pl:IsAdmin() then
if pl:SteamID() == admin1 then 
	pl:ConCommand("play song1.mp3") end
	
if pl:SteamID() == admin2 then 
	pl:ConCommand("play song2.mp3") end
	
if pl:SteamID() == admin3 then 
	pl:ConCommand("play song3.mp3") end
	
   
		
	end
end

end
hook.Add( “PlayerInitialSpawn”, “playerInitialSpawn”, AdminAlert )
[/lua]

just change steamID to there actual steam id . example: amin1 = “STeamid:01:13:35:67”

Thanks a lot gravel! I’ll give it a whirl :slight_smile:

I made a script for this 3 weeks ago that you can use if you want.
[lua]
local Admins = {
[“STEAM_0:0:0000000”] = {Sound = “sound/mysound.mp3”, MSG = “has joined the party…”},
[“STEAM_0:0:0000000”] = {Sound = “sound/mysound.mp3”, MSG = “has joined the party…”}
}

function AdminIntro(ply)
local admin = Admins[ply:SteamID()]
if admin then
for k,v in ipairs(player.GetAll()) do
v:SendLua(“surface.PlaySound(”"…admin.Sound…"")")
v:ChatPrint("[Admin] “…ply:Nick()…” "…admin.MSG)
end
end
end
hook.Add(“PlayerInitialSpawn”, “AdminIntro”, AdminIntro)
[/lua]

Will these trigger on map changes? I wouldn’t want the users having to hear a flood of .mp3s every time the map changes haha.

They will unless you add some sort of check to prevent them from playing for the first 30 seconds of the map starting or so.

Thank you :slight_smile: Just found out in-game haha. I appreciate all the feedback and helping hands.