Hi, everyone. I’ve been scouring search engines for help with coding this, but the results are all from years ago, so I think they might be obsolete now. Any help is appreciated!
I’m trying to take a material texture that is built into a map and write up a script to replace that loaded texture with another one. I would just recompile the map, but what I’m changing is a portrait that would need to be different for every round… so code that can replace the texture on the server map is ideal.
My server loads up a collection of addons and is set to autodownload them, so I’ve made sure to remove this map from the collection and autodownload list so that it doesn’t overwrite my changes with the online version. I’ve tried this so far in lua/autorun/server but even though the server console detects the file, it doesn’t seem to change anything.
The file paths for the materials I’m trying to replace came directly from VIDE, and they match the path for the file in the mat_texture_list command.
The files that I’m trying to replace the materials with are in both the garrysmod/materials folder and also in the garrysmod/materials/hopespeak folder. There are no typos in the file paths or filenames.
--[[ Replace Character Portraits ]]--
if SERVER then
resource.AddFile( "dangansonia.vmt" )
resource.AddFile( "dangansonia.vtf" )
resource.AddFile( "dangansoniavote.vmt" )
resource.AddFile( "dangansoniavote.vtf" )
else
local mat = Material ( "hopespeak/danganasahina" )
local met = Material ( "dangansonia" )
mat:SetTexture ( "$basetexture", met:GetTexture( "$basetexture" ))
local mat = Material ( "hopespeak/danganasahinavote" )
local met = Material ( "dangansoniavote" )
mat:SetTexture ( "$basetexture", met:GetTexture( "$basetexture" ))
end