Skin for cars?

So this is probably a really shitty question but is there a way to set skins to your cars you download from workshop permanently? I downloaded some police cars from workshop and they all use different kind of skins, I downloaded a skin pack from workshop and I can change the skins but when I delete the car and respawn it, the car uses the default skin again. I want it so when you spawn the car in, the skin I downloaded is applied to the car by default, so if i have a police dealer police can spawn cars in and that is the custom skin, so all the cars use the same skin once you spawn it in. Again, really dumb question but its bugging me.

You could use lua



hook.Add("PlayerSpawnedVehicle", "skinadder", function(ply, ent)
	if ent:GetModel() == "MODEL OF CAR YOU WANT THE SKIN FOR" then
		ent:SetSkin(2) -- The number of skin you want
	end
end)


Where would I stick this in?

In a lua file of your choice. Put it in lua/autorun/server

Thank you I’ll try this shortly

[editline]2nd March 2016[/editline]

This doesnt work apparently

Did you add the model of the car?

Yes

Any errors at all?

No, can you give me an example on how im suppose to fill this out? im really confused. Just stick a random car in there and a random skin number.

I am also wondering how would I have multiple cars in that code

Yep. So for example you are using a tdm car. You put the model of the car in the ent.GetModel section and for skin you can make it 1 - the max number. If you want to find the skin number spawn the car, hold c, right click the car and find the skin context menu. Grab the number from there.

To make multiple cars I suggest maybe using a table soo…



hook.Add("PlayerSpawnedVehicle", "skinadder", function(ply, ent)
	if ent:GetModel() ={ "MODEL OF CAR YOU WANT THE SKIN FOR",
"MODEL OF CAR YOU WANT THE SKIN FOR",
"MODEL OF CAR YOU WANT THE SKIN FOR",
"MODEL OF CAR YOU WANT THE SKIN FOR"
} then
		ent:SetSkin(2) -- The number of skin you want
	end
end)


So I replace “MODEL OF CAR YOU WANT THE SKIN FOR” with the model of a car? Like car.MDL right?

And each car uses a different skin, so how would I set that up, I’m assuming this table works of every car uses the same skin number but it doesn’t

Yes, each line is the “/path/to/car.mdl” Im not sure with the skins and multiple cars.

Anyone else know how to do this?

[editline]2nd March 2016[/editline]

Did this to test with a single car

hook.Add(“PlayerSpawnedVehicle”, “skinadder”, function(ply, ent)
if ent:GetModel() ={ “models/tdmcars/emergency/dod_charger12.mdl”} then
ent:SetSkin(3) – The number of skin you want
end
end)

This did not change the cars skin when I spawned it from the car dealer