StarfallEx icon indicating copy to clipboard operation
StarfallEx copied to clipboard

add setPlayerColor for cl holos

Open ZH-Hristov opened this issue 3 years ago • 7 comments

this method of doing it doesn't work on serverside

ZH-Hristov avatar Aug 05 '22 16:08 ZH-Hristov

Would be nice if the argument was just a normal color object.

adamnejm avatar Aug 05 '22 16:08 adamnejm

Also, how about this

lua/starfall/libs_sh/entities.lua#204

local playerColorWhitelist = {
	["prop_ragdoll"]       = true,
	["starfall_cnextbot"]  = true,
	["starfall_hologram"]  = true,
	["gmod_wire_hologram"] = true,
}
--- Sets the sheet color of a player-model
-- Can only be used on ragdolls, holograms and Starfall NextBots
-- @client
-- @param Color clr RGB color to use, alpha not supported
function ents_methods:setPlayerColor(clr)
	local ent = getent(self)
	if not playerColorWhitelist[ent:GetClass()] then SF.Throw("The entity isn't whitelisted", 2) end
	checkpermission(instance, ent, "entities.setRenderProperty")
	
	clr = cunwrap(clr)
	local vec = Vector(clr.r / 255, clr.g / 255, clr.b / 255)
	ent.GetPlayerColor = function() return vec end
end

Also also, maybe setPlayerModelColor, setPlayerSheetColor instead of setPlayerColor?

adamnejm avatar Aug 05 '22 16:08 adamnejm

Whitelist is good idea. The reason it's a Vector is because that's what the function expects.

ZH-Hristov avatar Aug 05 '22 19:08 ZH-Hristov

When might this get merged? working on code that could really use this

ReasonableScripts avatar Aug 09 '22 02:08 ReasonableScripts

I think player and bot support would be good to be added before it's merged.

thegrb93 avatar Aug 09 '22 03:08 thegrb93

I think player and bot support would be good to be added before it's merged.

https://github.com/ZH-Hristov/StarfallEx/pull/1

adamnejm avatar Aug 09 '22 03:08 adamnejm

yeah, that'd be best considering bots are what I intend to use it for

ReasonableScripts avatar Aug 09 '22 04:08 ReasonableScripts