Forcing Physgun colours on players dependant on their rank

On my server we want to have a forced Physgun colour to all regular players and remove the physgun glow and halo.
Staff members are to have different colours and are to have a glow but not a halo.
Is it possible to force the first one on the players and to also have the different colours.
if there is a plugin, i’d happily buy / download it.
Thanks!

Just Player:SetWeaponColor( Vector( 1, 0, 0 ) ) for RED. To get the values for the vector for SetWeaponColor and SetPlayerColor functions use: value / 255.

To make a player glow without using a halo in the PreDrawHalos hook, you can use stencils.

Where do i drop this?

You need to do it using the PlayerInitialSpawn hook and the PlayerSpawn hook.

[editline]20th April 2014[/editline]


-- sv_rankphysguncolours.lua
local ranks = {}
local function AddExtraRank(id,col)
	ranks[id] = {}
	ranks[id].Color = col
end
	
AddExtraRank("superadmin",Color(255,0,0))
AddExtraRank("admin",Color(0,0,255))
AddExtraRank("user",Color(0,128,255)) -- don't remove these three. just add more as necessary.

local function GetRankPhysgunColor(ply)
	if ucl then -- I took this code from a join colour thing I made in another thread a while back.
		if ranks[ply:GetUserGroup()] then
			return ranks[ply:GetUserGroup()].Color
		else
			return Color(255,255,255)
		end
	else
		if ply:IsSuperAdmin() then
			return ranks["superadmin"].Color
		elseif ply:IsAdmin() then
			return ranks["admin"].Color
		else
			return ranks["user"].Color
		end
	end
end

hook.Add( "PlayerSpawn", "AdminPhysgunCol", function( ply )
	local color = GetRankPhysgunColor(ply)
	timer.Create("setphysguncolour",0.1,1,function()
	ply:SetWeaponColor(Vector(color.r / 255, color.g / 255, color.b / 255))
	end)
end)

hook.Add( "PlayerInitialSpawn", "AdminPhysgunCol2", function( ply )
	local color = GetRankPhysgunColor(ply)
	timer.Create("setinitialphysguncolour",0.1,1,function()
	ply:SetWeaponColor(Vector(color.r / 255, color.g / 255, color.b / 255))
	end)
end)

Put this in an serverside file (lua/autorun/server), it should work.

Hi I was browsing around for a way to force physgun colors to ranks and came across this code that you made it works great for the three roles you have in it and I am wanting to add a few ranks to it but no matter what I do it either isn’t the appropriate color or it causes console errors if I just edit the color of the existing ranks it works fine it only breaks if I try to add ranks and I don’t know what to do when I tried just adding the ranks to the top with AddExtraRank(“rankhere”,Color(255,255,0)) it does not have that color but it has the color of the rank it is inheriting from. If you could help me code in a few ranks that would be great. I want to add trial moderator, moderator, event planner, head event planner, head admin, community manager and owner. I would greatly appreciate this thanks in advance.

so far I’ve been trying to edit this code for every rank on my server. right now the color isn’t important so long as I got this think properly edited. I’ll change the colors later. but is this how I would properly edit it to work for every ulx rank?

– sv_rankphysguncolours.lua
local ranks = {}
local function AddExtraRank(id,col)
ranks[id] = {}
ranks[id].Color = col
end

AddExtraRank(“owner”,Color(255,0,0))
AddExtraRank(“coowner”,Color(255,0,0))
AddExtraRank(“eventplanner”,Color(255,0,0))
AddExtraRank(“headadmin”,Color(255,0,0))
AddExtraRank(“superadmin”,Color(255,0,0))
AddExtraRank(“admin”,Color(0,0,255))
AddExtraRank(“operator”,Color(255,0,0))
– AddExtraRank(“jedi”,Color(255,0,0))
AddExtraRank(“mediamanager”,Color(255,0,0))
AddExtraRank(“builder”,Color(255,0,0))
AddExtraRank(“noaccess”,Color(255,0,0))
AddExtraRank(“user”,Color(0,128,255)) – don’t remove these three. just add more as necessary.

local function GetRankPhysgunColor(ply)
if ucl then – I took this code from a join colour thing I made in another thread a while back.
if ranks[ply:GetUserGroup()] then
return ranks[ply:GetUserGroup()].Color
else
return Color(255,255,255)
end
else
if ply:IsSuperAdmin() then
return ranks[“superadmin”].Color
elseif ply:IsAdmin() then
return ranks[“admin”].Color
else
return ranks[“user”].Color
end
end
end

hook.Add( “PlayerSpawn”, “AdminPhysgunCol”, function( ply )
local color = GetRankPhysgunColor(ply)
timer.Create(“setphysguncolour”,0.1,1,function()
ply:SetWeaponColor(Vector(color.r / 255, color.g / 255, color.b / 255))
end)
end)

hook.Add( “PlayerInitialSpawn”, “AdminPhysgunCol2”, function( ply )
local color = GetRankPhysgunColor(ply)
timer.Create(“setinitialphysguncolour”,0.1,1,function()
ply:SetWeaponColor(Vector(color.r / 255, color.g / 255, color.b / 255))
end)
end)

-snip, old post-

so would I remove the first one with PlayerSpawn in it or the one with PlayerInitialSpawn in it? also I did edit it correctly right?