Skin changer tool


How do I apply the skin for all clients in my skin changer gmod_tool?

ent:SetSkin( currentSkin + 1 );

this only does it for the client who uses it.

for in loop

I have tried this before I made the thread, and it doesn’t work:

	for i,v in pairs( player.GetAll() ) do
		ent:SetSkin( currentSkin + 1 );

what exactly are you setting the skin of?

Are you kidding me? Replace ent with v.

My skin changer tool changes the skin of entities, vehicles, props - not players.
It works fine except for the fact that only the client sees the skin change, not any other players.

Well, why didn’t you tell that from the beginning? Anyways, you must set the skin SERVERSIDE for other players to see it updated.

Oh, and by the way, there are already such tools.

I’ve tried to find them but I haven’t succeeded, except for one which required the C menu which I’ve disabled.
Should I send with net.Send the entity index to server? Or is there a better way?

Just set the skin on server, thats it. It will be networked automatically.

To set it on the server, should I use net.Send to the server?

if SERVER then
	ent:SetSkin( currentSkin + 1 );

this didn’t work, nothing happens.

Show the whole file so I can see what’s wrong.

I know there’s some differences in the two functions, maybe some styling errors, I’ll make sure it’s good when it all works. Thank you.
edit: I see the currentSkin wont be set to 0 before it’s 1 above max.

TOOL.Category		= "Construction"		// Name of the category
TOOL.Name			= "#Skin changer"		// Name to display
TOOL.Command		= nil				// Command on click (nil for default)
TOOL.ConfigName		= ""				// Config file name (nil for default)

	language.Add("", "Skin Changer")
	language.Add("Tool.skinchanger.desc", "Change skin.")
	language.Add("Tool.skinchanger.0", "Left click to go to next skin, right click to go to the previous skin.")
	shot = false;
	shotR = false;
function TOOL:LeftClick( trace )
ent = trace.Entity;
if ent:IsWorld() then
	return false;

if shot == true then
	return false;
totalSkins = ent:SkinCount( );
currentSkin = ent:GetSkin( );
if currentSkin > totalSkins then
	currentSkin = 0;
if SERVER then
	ent:SetSkin( currentSkin + 1 );
	shot = true;
	timer.Simple(0.1, function() shot = false; end);

function TOOL:RightClick( trace )

if trace.Entity:IsWorld() then
	return false;

if shotR == true then
	return false;
totalSkins = trace.Entity:SkinCount( );
currentSkin = trace.Entity:GetSkin( );
if currentSkin < 1 then
	currentSkin = 16;
		trace.Entity:SetSkin( currentSkin - 1 );

	shotR = true;
	timer.Simple(0.1, function() shotR = false; end);

Left click changes nothing.
Right click changes for client only.