Checking if a mdl is a playermodel without spawning it.
4 replies, posted
Hello, i'm trying to determine if a .mdl (i only have the path) is a playermodel without spawning/caching it.
Here is what i tried :
reading the file with file.Read and checking with string.find if there is the bones : "valvebiped.bip01_head1", "valvebiped.bip01_spine" and \0eyes\0 in it but HL2 models have the same bones so it's not enough.
As far as i know, the simplest way would be to check the sequence, but i need to check if ~5000 models are playermodels so it would make the server crash because of the precache limit.
I may need to use a binary module to get the sequence list of the model without spawning it, since tools to build models can show the list of the animations, i tried to find the source code but i didn't find any.
Any help would be appreciated.
Just use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/player_manager/AllValidModels]player_manager.AllValidModels[/url]
[CODE]
local modelpath = 'models/player/kleiner.mdl' -- change this to whatever
if table.HasValue( player_manager.AllValidModels, modelpath ) then
-- it's a playermodel
end
[/CODE]
[editline]19th September 2016[/editline]
Of course, that only works if the playermodel is registered as a playermodel (which it is if you can select it to use as a playermodel). If it isn't then just check the model path to see if it includes models/player
i guess it will do the job, thanks.
I will still keep the slow system if people forget to register playermodels with lua.
If it comes up in the playermodel selection menu then it is registered though, which is what makes it a playermodel by definition
Nice to know i wasted two days of work :v:
Sorry, you need to Log In to post a reply to this thread.