• Automating Collecting Playermodel Filepath
    4 replies, posted
So before I waist an hour or two getting over 300+ Playermodel filepath's I was wondering if anyone knew an easy way to get all Playermodel filepath's via console/chat command or a simple logging of playermodel path's upon joining. I have seen similar setups with automatically blacklisting big props on DarkRP servers, but that is called when it's spawned by a player so that's easy. But how would one get a playermodel's filepath, and adding it to a file/database if it's NOT already in the file/database. Hopefully I have explained this in a way that's understandable. Thanks, Chibby
I don't really know what you're asking for. If you want it to list player models you already have set up, you can do something like this [code] local ValidModelSimpleNames = { ["alyx"] = {"models/player/alyx.mdl"}, ["barney"] = {"models/player/barney.mdl"}, ["breen"] = {"models/player/breen.mdl"}, ["charple"] = {"models/player/charple.mdl"}, ["chell"] = {"models/player/p2_chell.mdl"}, ["corpse"] = {"models/player/corpse1.mdl"}, ["combine"] = {"models/player/combine_soldier.mdl"}, ["combineprison"] = {"models/player/combine_soldier_prisonguard.mdl"}, ["combineelite"] = {"models/player/combine_super_soldier.mdl"}, ["eli"] = {"models/player/eli.mdl"}, ["gman"] = {"models/player/gman_high.mdl"}, ["kleiner"] = {"models/player/kleiner.mdl"}, ["grigori"] = {"models/player/monk.mdl"}, ["mossman"] = {"models/player/mossman.mdl"}, ["mossmanarctic"] = {"models/player/mossman_arctic.mdl"}, ["police"] = {"models/player/police.mdl"}, ["girlpolice"] = {"models/player/police_fem.mdl"}, ["magnusson"] = {"models/player/magnusson.mdl"}, ["stripped"] = {"models/player/soldier_stripped.mdl"}, ["zombie"] = {"models/player/zombie_classic.mdl"}, ["fastzombie"] = {"models/player/zombie_fast.mdl"}, ["malerebel"] = { "models/player/Group03/Male_01.mdl", "models/player/Group03/Male_02.mdl", "models/player/Group03/Male_03.mdl", "models/player/Group03/Male_04.mdl", "models/player/Group03/Male_05.mdl", "models/player/Group03/Male_06.mdl", "models/player/Group03/Male_07.mdl", "models/player/Group03/Male_08.mdl", "models/player/Group03/Male_09.mdl"}, ["malecitizen"] = { "models/player/Group01/Male_01.mdl", "models/player/Group01/Male_02.mdl", "models/player/Group01/Male_03.mdl", "models/player/Group01/Male_04.mdl", "models/player/Group01/Male_05.mdl", "models/player/Group01/Male_06.mdl", "models/player/Group01/Male_07.mdl", "models/player/Group01/Male_08.mdl", "models/player/Group01/Male_09.mdl"}, ["girlrebel"] = { "models/player/Group03/Female_01.mdl", "models/player/Group03/Female_02.mdl", "models/player/Group03/Female_03.mdl", "models/player/Group03/Female_04.mdl", "models/player/Group03/Female_06.mdl", "models/player/Group03/Female_07.mdl"}, ["girlcitizen"] = { "models/player/Group01/Female_01.mdl", "models/player/Group01/Female_02.mdl", "models/player/Group01/Female_03.mdl", "models/player/Group01/Female_04.mdl", "models/player/Group01/Female_06.mdl", "models/player/Group01/Female_07.mdl"}, ["skeleton"] = {"models/player/skeleton.mdl"}, ["terrorist"] = { "models/player/leet.mdl", "models/player/guerilla.mdl", "models/player/arctic.mdl", "models/player/phoenix.mdl"}, ["counterterrorist"] = { "models/player/urban.mdl", "models/player/gasmask.mdl", "models/player/riot.mdl", "models/player/swat.mdl"} } local changedmodels = changedmodels or {} local function changemodel(ply, text) local exptext = string.Explode(" ", text) if (string.lower(exptext[1]) == "!model") then local wanted = exptext[2] if (ValidModelSimpleNames[wanted]) then ply:SetModel(table.Random(ValidModelSimpleNames[wanted])) changedmodels[ply:SteamID()] = ply:GetModel() return else ply:ChatPrint("Not a valid model! Type !models for a list of possible models.") return end end if (string.lower(exptext[1]) == "!models") then local getkeys = table.GetKeys(ValidModelSimpleNames) ply:ChatPrint("Type !model and then one of the following: \n"..table.concat(getkeys, ", ")) return end end hook.Add("PlayerSay", "changemodel", changemodel) [/code]
I need to get the filepath for all the playermodels I am subscribed too so I can add them to a similar setup you have at the top.
file.Find works wonders when used recursively. Addons load in a sort of "virtual directory" setting. So by listing models/ directory, you'll be able to grab all models. ] listdir models/ mdl true [url]https://dl.dropboxusercontent.com/u/26074909/work/output/listdir.txt[/url] This is part of my fileio which will be released soon ( slightly modified for you ) [code]// // Generates an array where the key is the directory, and values are files within the key directory. - Josh 'Acecool' Moser // This type of file-list is what the ReadFiles ( into memory ) fileio function requires. // function GenerateFileList( _folder, _filter, _files ) // Init if ( !_files ) then _files = { }; end // Grab files and folders for the directory which we're in. local files, folders = file.Find( _folder .. "*", "GAME" ); // Process folders... _files = ... isn't necessary because Pass-By-Reference which will modify the original list. for k, v in pairs( folders or { } ) do _files = GenerateFileList( _folder .. v .. "/", _filter, _files ); end // Go through all files for current folder for k, v in pairs( files or { } ) do // Filter is for extensions we are looking for; can be a table or a single one. Doesn't support patterns. if ( _filter ) then local _extension = string.GetExtensionFromFilename( v ); if ( istable( _filter ) ) then if ( !table.HasValue( _filter, _extension ) ) then continue; end else if ( _extension != _filter ) then continue; end end end // Only initialize the struct if files exist that we're targeting... if ( !_files[ _folder ] ) then _files[ _folder ] = { }; end // Insert into our table... table.insert( _files[ _folder ], v ); end return _files; end[/code] Creates a simple structure where _files = { }, elements of the table KEY is the folder, V is another table which will contain just the file-names. Usage is straight forward: [code]local _data = GenerateFileList( "models/", "mdl" ); PrintTable( _data )[/code] You may end up with more than can be displayed. I'd recommend saving the output to a file. You can easily modify to look for player in the file-name, but some player models may not contain that so outputting all may be the easiest way...
Acecool that works, but would there be a way to only list playermodels. Like searching for [I]player_manager.AddValidModel( "models/", "mdl" )[/I]
Sorry, you need to Log In to post a reply to this thread.