Revision of code above, better file.write on spawn rather than initial spawn plus cleaner code.
local function MakeEffect( ply )
local effectdata = EffectData()
effectdata:SetStart( ply:GetPos() )
effectdata:SetOrigin( ply:GetPos() )
effectdata:SetNormal( ply:GetPos() )
effectdata:SetMagnitude( 3 )
effectdata:SetScale( 2 )
effectdata:SetRadius( 5 )
effectdata:SetAngle( Angle( 0, 0, 0) )
util.Effect( "selection_indicator", effectdata, true, true )
end
function AdminJoin( ply)
if ( !ply:IsAdmin() ) then return end
timer.Simple( 3, game.ConsoleCommand, "ulx playsound admin.mp3 \n")
timer.Simple( 5, game.ConsoleCommand, "ulx csay admin " ..ply:Nick().. " has connected \n")
timer.Create( "Admin" ..ply:SteamID( ), 1, 0, MakeEffect, ply )
function PlyDisconnected( ply )
if ply:IsValid() then
timer.Destroy( "Admin" ..ply:SteamID( ) )
end
end
hook.Add( "PlayerDisconnected" , "PlyDisconnected" , PlyDisconnected )
end
hook.Add( "PlayerInitialSpawn", "AdminJoin", AdminJoin )
concommand.Add( "Ajoin", AdminJoin )
function AdminWrite( ply )
content = file.Read( "Umotd/admins.txt" )
if ply:IsUserGroup("admin") || ply:IsUserGroup("superadmin") then
if string.find( content, ply:Nick(), 1, true ) then
content = content
else
content = content.. "<li>" ..ply:Nick()
file.Write( "Umotd/admins.txt", content )
end
else
end
end
hook.Add( "PlayerSpawn", "AdminWrite", AdminWrite )