garrysmod-requests icon indicating copy to clipboard operation
garrysmod-requests copied to clipboard

game.MountGMA upgrade

Open censorry opened this issue 5 years ago • 3 comments

I would like the function to have a second argument that would allow filtering the types of files that do not need to be mount from addon.

For example, I need to get all the models and textures, but I don't need any possible malicious code from the addon to be run and I don't have time to check each such addon from workshop for the lua file, so it would be worth preventing them before mount.

censorry avatar May 24 '20 14:05 censorry

I imagine the best way would probably be through some sort of sequential array of strings/patterns to match (with wildcard support of course). It would also have to not filter anything by default when the argument isn't provided, so it doesn't break existing addons.

So when it's used without the filter argument, everything loads and it acts as normal:

steamworks.DownloadUGC( 104548572, function( name )
	game.MountGMA( name )
end )

Then when the filter argument is provided, it only loads what matches (or doesn't match?) the filter:

steamworks.DownloadUGC( 104548572, function( name )
	game.MountGMA( name, {
                "materials/*", -- All materials
                "models/*", -- All models
                "sound/*.mp3", -- only mp3 sound files
        } )
end )

Dunno if the filter should be a whitelist or blacklist tho. I'd personally prefer a whitelist, to make sure nothing slips through as this seems to be what you're after.

viral32111 avatar May 24 '20 15:05 viral32111

A callback function with a boolean return that passes every file would be better.

Kefta avatar May 24 '20 16:05 Kefta

Would be very useful

Dimentio avatar Sep 17 '24 01:09 Dimentio

Was just about to make a gmod request for it, this would be super useful Currently i have to manually parse the GMA and create a new one from scratch, store it in DATA. I do this to remove lua files and junk that isn't needed for my player model hotloader.

wrefgtzweve avatar May 02 '25 00:05 wrefgtzweve

It would also be great if GMAs could be loaded from memory

artemking4 avatar May 02 '25 00:05 artemking4