Check if the client has models

How can I check if the client has models, and if they don’t, use a replacement model?

Is that possible?

I have a big content pack, but if the client doesn’t have the models, I don’t want the game made unplayable with errors since the content is mostly asthetic.


util.IsValidModel, but the catch is the model has to be on the stringtable.

Wouldn’t you be able to use file.Exists?

You could do:

if !file.Exists("…/addons/phx3/info.txt") then

That’s right, and unless I’m mistaken you can get access to the list of installed addons. That’s one easy way to check if the player has your content pack properly installed or not.

file.Exists() only works on txt files.

Whoever doesn’t think so should read this:
It starts in the data directory because it’s designed only to handle text files.

Doesn’t that show otherwise?

Just because you happen to think that is its only purpose doesn’t mean that it can’t or wasn’t meant to look for files other than textfiles.

I’d also go as far to speculate that it wasn’t designed for only text files as even garry used it to look for other files. And no where on the wikipage does it say “this only works on text files”.

The fundamental problem is your assuming that the addons directory will always be the same or absolute. Addons do not have to have standardized naming to function properly. Checking with file.Exists is a bad idea or at minimal poor design.

Good suggestion… still just hacking away…

Oh right, I was thinking of file.Write/Read. Those go wacky without text files. Still, seems a bit ridiculous to start in the data directory in that case.


Using this you can probably figure out if clients have your content pack installed or not. Just give it a unique enough name.

Actually I think this only returns the folder name… But it’s still worth a try. And if you package your content and a folder and explicitely tell your clients they need to keep the name for it to work then it should be fine.

Even better, just do file.Find and parse the table for a model filename. file.Find is not restricted to txt files.

file.Read works on all files based on text - including Lua files.

It technically works on all files, except Lua will convert it into a Lua string which does not support multibyte and it’ll be useless :v: