So im looking for a way i can get the weapon icon on a derma/gui for example...
[IMG]http://i.imgur.com/q0UvzgT.jpg[/IMG]
[IMG]http://i.imgur.com/05pJC1y.png[/IMG]
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 [URL="http://nemesis.thewavelength.net/?p=26"]GCFScape[/URL] 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:
[CODE]
local weaponclass = "weapon_stunstick" -- or any weapon class
local imagepath = "materials/entities/"..weaponclass..".png"
[/CODE]
Note that not all weapons have images for them
[QUOTE=MPan1;51722483]You can find them in SteamApps/common/GarrysMod/garrysmod/garrysmod_dir.vpk/materials/entities.
You'll need [URL="http://nemesis.thewavelength.net/?p=26"]GCFScape[/URL] 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:
[CODE]
local weaponclass = "weapon_stunstick" -- or any weapon class
local imagepath = "materials/entities/"..weaponclass..".png"
[/CODE]
Note that not all weapons have images for them[/QUOTE]
Now this works however i need to be able to call like all weapons... for example the darkrp weapons..
[IMG]http://i.imgur.com/AFeDYdO.png[/IMG]
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 [URL="https://github.com/FPtje/DarkRP/tree/master/content/materials/vgui/entities"]materials/vgui/entities[/URL].
[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
[QUOTE=MPan1;51722564]It seems the DarkRP weapons are in [URL="https://github.com/FPtje/DarkRP/tree/master/content/materials/vgui/entities"]materials/vgui/entities[/URL].
[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[/QUOTE]
not really sure where that source code is on the [URL="https://github.com/garrynewman/garrysmod"]github[/URL] if someone could point me in the correct direction that would be great!
[URL="https://github.com/FPtje/DarkRP/blob/353dc3286092cdb2efade2cc0f2145db5a6c2e69/gamemode/modules/fadmin/fadmin/playeractions/giveweapons/cl_controls.lua#L58"]Seems DarkRP just searches both directories[/URL]
[editline]25th January 2017[/editline]
[URL="https://github.com/garrynewman/garrysmod/blob/784cd57576d85712fa13a7cea3a9523b4df966b0/garrysmod/gamemodes/sandbox/gamemode/spawnmenu/creationmenu/content/contenttypes/entities.lua#L43"]GMod does pretty much the same thing as what I posted before[/URL]
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...
[code]
-- 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
print(weapon.ClassName)
Categorised[ weapon.Category ] = Categorised[ weapon.Category ] or {}
table.insert( Categorised[ weapon.Category ], weapon )
end
end
Weapons = nil
for CategoryName, v in SortedPairs( Categorised ) do
for k, ent in SortedPairsByMemberValue( v, "PrintName" ) do
theweaponent = "materials/entities/"..ent.ClassName..".png"
end
end
[/code]
again it works for hl2 weapons but nothing outside of that
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/file/Exists]file.Exists[/url]
Use the wiki. That combined with a basic "if/elseif" check should get you what you need.
[QUOTE=TFA;51722689][img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/file/Exists]file.Exists[/url]
Use the wiki. That combined with a basic "if/elseif" check should get you what you need.[/QUOTE]
Hmm this could work but what are the ONLY possible files that can hold the spawnicons?
Generally, the two locations are:
"vgui/entities/classname.vtf"
and
"entities/classname.png"
There's no way to get all possible locations without a long file search. These, however, are what the spawnmenu supports.
Sorry, you need to Log In to post a reply to this thread.