know when staff has joined server

so ive been in a couple servers that when an admin or help or owner has entered the server it says their staff name beside their steam name also when they talk it shows up. so i was wondering which lua file would have to be edited to do this. im not asking for the lua coding for it i was just wanted someone to steer me in the right direction to do this.

Google search ‘chat tags’ if that’s what you mean.

make your own lua file in lua/autorun

or you can use the free addon here and just add an IsAdmin() check

awesome! ill give it a try. thank you so much for your help!

[editline]25th February 2014[/editline]

ok so this what ive got and i want it so that it says the admins name beside their name when they join

[lua]
if CLIENT then
local function Chat(um)
local ply = um:ReadString()
local mode = um:ReadString()
local id = um:ReadString()

	if mode == "1" then
		chat.AddText(Color(186, 117, 255),"(Server) ",Color(41,91,255),ply,Color(0, 0, 0)," is",Color(255, 237, 97)," joining ",Color(0, 0, 0),"the server!")
	end
end
usermessage.Hook("DispatchChatJoin", Chat)

end

local function PlyJoined( name )
if SERVER then
for k,v in pairs(player.GetAll()) do
SendUserMessage(“DispatchChatJoin”, v, name, “1”)
end
end
end
hook.Add( “PlayerConnect”, “PlyJoined”, PlyJoined )
[/lua]

[editline]25th February 2014[/editline]

i think i need to add this but i dont know where
[lua]
if ply:IsSuperAdmin() then
rank = “Superadmin”
elseif ply:IsAdmin() then
rank = “Admin”
else
rank = “User”
end
[/lua]

Do you want it to only say something if a staff joins?

-snip-
Put that in a shared file. I even wrote instructions for it.
There’s no reason for it to not work though I don’t have time to test it.

yes

[editline]25th February 2014[/editline]

awesome! thank you! ill test it now

I edited it… all the ranks have the title “Super Admin” so you may want to change that.

got too many lua erros it said at line 11

Can you post the full error from your server and/or client please?

[ERROR] addons/con anddis/lua/autorun/(dis)connect.lua:11: unexpected symbol nea
r ‘=’

  1. unknown - addons/con anddis/lua/autorun/(dis)connect.lua:0

Oh I know what I did wrong… I should have it fixed in a bit.

[editline]25th February 2014[/editline]


-- if you use ulx then just add your additional
-- usergroups below the ones that are in the
-- ranks table. you can also edit the existing
-- entries but don't remove them otherwise
-- the script won't work. if you don't use ulx
-- this should still work. it's untested.

if SERVER then
	util.AddNetworkString("colouredjoinmsg")
	AddCSLuaFile()
	local ranks = {}

	function AddExtraRank(id,title,col)
		ranks[id] = {}
		ranks[id].Title = title
		ranks[id].Color = col
		MsgC(Color(0,255,0),"	Added an extra rank to the join script ("..id..", "..title..")
")
	end
	
	AddExtraRank("superadmin","Super Admin",Color(255,0,0))
	AddExtraRank("admin","Admin",Color(0,0,255))
	AddExtraRank("user","Player",Color(0,128,255)) -- don't remove these three. just add more as necessary.
	
	hook.Add( "PlayerInitialSpawn", "Welcome", function(ply)
		local rank = "Player"
		local color = Color(0,128,255)
		if ucl then
			if ranks[ply:GetUserGroup()] then
				rank = ranks[ply:GetUserGroup()].Title
				color = ranks[ply:GetUserGroup()].Color
			else
				rank = "Unknown Rank"
				color = Color(255,255,255)
			end
		else
			if ply:IsSuperAdmin() then
				rank = ranks["superadmin"].Title
				color = ranks["superadmin"].Color
			elseif ply:IsAdmin() then
				rank = ranks["admin"].Title
				color = ranks["admin"].Color
			else
				rank = ranks["user"].Title
				color = ranks["user"].Color
			end
		end
		net.Start("colouredjoinmsg")
		net.WriteString(ply:Nick())
		net.WriteString(rank)
		net.WriteTable(color)
		net.Broadcast()
	end)
end

if CLIENT then
	net.Receive("colouredjoinmsg", function(len)
		local name = net.ReadString()
		local rank = net.ReadString()
		local color = net.ReadTable()
		chat.AddText(color,nick,Color(255,255,255)," has spawned in the server with the rank ",color,rank,Color(255,255,255),".")
	end)
end

Sorry - I’m not really concentrating… this code should work.

hey thank again for your help but its saying this now

[ERROR] addons/con anddis/lua/autorun/(dis)connect.lua:18: unexpected symbol nea
r ‘=’

  1. unknown - addons/con anddis/lua/autorun/(dis)connect.lua:0
    i notice the end part was in the wrong spot so i fixed and still got the same thing

[editline]25th February 2014[/editline]

im sorry my mistake its working great!!i didnt notice u corrected it. thaank again for all your help!

-snip- He fixed it!

yeah he was fast i didnt notice it the first time

The


 tags broke and put ="keyword"> into the code... nothing I can do about that.

no worries, thank again! your the man!

[editline]25th February 2014[/editline]

so this code works great but i just wanted to add one thing. so when someone joins the server i want it to say superadmin(name) has spawn into the server. ive added the print("("…id…")") to line 60 but i cant get it to work heres the code

[lua]
– if you use ulx then just add your additional
– usergroups below the ones that are in the
– ranks table. you can also edit the existing
– entries but don’t remove them otherwise
– the script won’t work. if you don’t use ulx
– this should still work. it’s untested.

if SERVER then
util.AddNetworkString(“colouredjoinmsg”)
AddCSLuaFile()
local ranks = {}

function AddExtraRank(id,title,col)
	ranks[id] = {}
	ranks[id].Title = title
	ranks[id].Color = col
	MsgC(Color(0,255,0),"	Added an extra rank to the join script ("..id..", "..title..")

")
end

AddExtraRank("superadmin","Super Admin",Color(255,0,0))
AddExtraRank("admin","Admin",Color(0,0,255))
AddExtraRank("user","Player",Color(0,128,255)) -- don't remove these three. just add more as necessary.

hook.Add( "PlayerInitialSpawn", "Welcome", function(ply)
	local rank = "Player"
	local color = Color(0,128,255)
	if ucl then
		if ranks[ply:GetUserGroup()] then
			rank = ranks[ply:GetUserGroup()].Title
			color = ranks[ply:GetUserGroup()].Color
		else
			rank = "Unknown Rank"
			color = Color(255,255,255)
		end
	else
		if ply:IsSuperAdmin() then
			rank = ranks["superadmin"].Title
			color = ranks["superadmin"].Color
		elseif ply:IsAdmin() then
			rank = ranks["admin"].Title
			color = ranks["admin"].Color
		else
			rank = ranks["user"].Title
			color = ranks["user"].Color
		end
	end
	net.Start("colouredjoinmsg")
	net.WriteString(ply:Nick())
	net.WriteString(rank)
	net.WriteTable(color)
	net.Broadcast()
end)

end

if CLIENT then
net.Receive(“colouredjoinmsg”, function(len)
local name = net.ReadString()
local rank = net.ReadString()
local color = net.ReadTable()
chat.AddText(color,rank,print("("…id…")"),Color(255,255,255)," has spawn into the server “,color,nick,Color(255,255,255),”.")

end)

end
[/lua]

would i use print to display the name?

Depends on what you want to do, add it to chat or add it to console.

Console, then yes use print.
Chat, then no, use chat.AddText( [ Color, text ]+ )

when someone joins the it says “player has spawn into the server” in the chat.i want it to say “player(steamname) has spawn into the server”.