get weapons icon in derma

So im looking for a way i can get the weapon icon on a derma/gui for example…

one of these images on a gui… Thanks!

You can find them in SteamApps/common/GarrysMod/garrysmod/garrysmod_dir.vpk/materials/entities.

You’ll need GCFScape to open the gmod .VPK file though

[editline]25th January 2017[/editline]

That particular one is materials/entities/weapon_357.png.

[editline]25th January 2017[/editline]

If you want to get the string of a weapon so you can find its image, I think you just need to use the weapon’s class like so:

local weaponclass = "weapon_stunstick" -- or any weapon class

local imagepath = "materials/entities/"..weaponclass..".png"

Note that not all weapons have images for them

Now this works however i need to be able to call like all weapons… for example the darkrp weapons…

these weapons when using that code you posted create a texture error…

i also assume that M9K or FAS weapons would do the same

It seems the DarkRP weapons are in materials/vgui/entities.

[editline]25th January 2017[/editline]

They also seem to all be .vtf files. I guess if you looked around in gmod’s menu code for a while you could find how it finds all the weapon icons, but I guess it must just search both directories

not really sure where that source code is on the github if someone could point me in the correct direction that would be great!

Seems DarkRP just searches both directories

[editline]25th January 2017[/editline]

GMod does pretty much the same thing as what I posted before

Kind of trying to use the code used in that file you sent however not sure how to make it expand to other weapon packs…

		-- Loop through the weapons and add them to the menu
		local Weapons = list.Get( "Weapon" )
		local Categorised = {}

		-- Build into categories
		for k, weapon in pairs( Weapons ) do
			if weapon.ClassName == v[5] then
				Categorised[ weapon.Category ] = Categorised[ weapon.Category ] or {}
				table.insert( Categorised[ weapon.Category ], weapon )

		Weapons = nil

		for CategoryName, v in SortedPairs( Categorised ) do
			for k, ent in SortedPairsByMemberValue( v, "PrintName" ) do
				theweaponent = "materials/entities/"..ent.ClassName..".png"

again it works for hl2 weapons but nothing outside of that

Hmm this could work but what are the ONLY possible files that can hold the spawnicons?