Just do a k,v loop through the table?
[CODE]
local Mats = theirVehicle:GetMaterials()
for key, value in pairs( Mats ) do -- this goes through the table's keys and values, it's a very simple loop
if value == "models/tdm/shared/glass.vtf" then
theirVehicle:SetSubMaterial( key - 1, "some_material.vtf" ) -- the wiki says to subtract 1 from the index
end
[/CODE]
[B]Edit: [/B]Why'd this get rated funny? Isn't this how you do it?
Already tried to loop once, and was returning nil.
I'll try this.
I have a feeling it wasn't working because you had
[CODE]
"models/tdm/shared/glass"
[/CODE]
Without .vtf at the end. Try adding the extension of the material, maybe then it'll work?
Also, just checked, and models/rendertarget is a .vmt, not a .vtf, so I have a feeling the SetSubMaterial function won't work with it, especially since the .vmt's $basetexture isn't a .vtf.
Try using a material that's actually a .vtf
Why would Render Target not work as it is included in the default Material tool, and SubMaterial tool.
Testing now though, thanks for the help.
Well, it might work, but I thought SetSubMaterial only worked with .vtf files?
-snip
[CODE]
local Mats = theirVehicle:GetMaterials()
PrintTable(Mats)
[/CODE]
You know you're printing ALL the materials with that, right?
-snip
If you want it to replace other materials like whatever material the Bugatti SS uses, you can just do
[CODE]
if value == "models/tdmcars/shared/glass" or value == "whatever other material" then
[/CODE]
By the way. You just need to do PrintTable(car:GetMaterials()) and then try to figure out what ones are the glass ones
Sorry, you need to Log In to post a reply to this thread.