Fixed... I made a silly mistake in the chat.AddText() (used "nick" instead of "name"). All fixed now - use this code.
[code]-- 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),"\tAdded an extra rank to the join script ("..id..", "..title..")\n")
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
MsgC(Color(0,255,0),"\tJoin script init\n")
net.Receive("colouredjoinmsg", function(len)
local name = net.ReadString()
local rank = net.ReadString()
local color = net.ReadTable()
chat.AddText(color,name,Color(255,255,255)," has spawned in the server with the rank ",color,rank,Color(255,255,255),".")
end)
end[/code]
[img]http://puu.sh/7aBYf/7de7e718e1.jpg[/img]
[editline]26th February 2014[/editline]
There's a moral to this thread...
Always test code before giving it to others. Especially on here :v:
[QUOTE=Mors Quaedam;44048355]Fixed... I made a silly mistake in the chat.AddText() (used "nick" instead of "name"). All fixed now - use this code.
[code]-- 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),"\tAdded an extra rank to the join script ("..id..", "..title..")\n")
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
MsgC(Color(0,255,0),"\tJoin script init\n")
net.Receive("colouredjoinmsg", function(len)
local name = net.ReadString()
local rank = net.ReadString()
local color = net.ReadTable()
chat.AddText(color,name,Color(255,255,255)," has spawned in the server with the rank ",color,rank,Color(255,255,255),".")
end)
end[/code]
[img]http://puu.sh/7aBYf/7de7e718e1.jpg[/img]
[editline]26th February 2014[/editline]
There's a moral to this thread...
Always test code before giving it to others. Especially on here :v:[/QUOTE]
works great now, thanx again for the 100th time! haha
Sorry, you need to Log In to post a reply to this thread.