Are you able to check if the player has a model downloaded via lua?

Hey! As the title says I am wondering if you’re able to check via lua if the player has a model downloaded?
My idea with this is that you could check if the person has a particular game installed when they join.

Thanks :slight_smile:

Edit:
Or is there an easier way to do this?

Take a look at this: http://wiki.garrysmod.com/page/engine/GetGames

[editline]7th March 2014[/editline]

You will need to check if the game you are looking for also returns “mounted”

Thanks! :slight_smile:

Edit:
How do I put as solved?

You can also check if they have a specific file with file.Exists.
Something like [lua]if file.Exists(“models/mymodel.mdl”, “GAME”) then[/lua]

This is slightly useful if maybe you wanted to allow people to use downloaded models that aren’t actually mounted. (For some reason a lot of people just don’t buy CSS, this is especially true with second accounts and stuff like that.)

To close the thread, click Mark as Solved in the blue bar right above your post.

**[Lua/Libraries/util/IsValidModel

http://gmodwiki.net/favicon.ico](http://gmodwiki.net/Lua/Libraries/util/IsValidModel)**
**[Lua/Libraries/util/IsModelLoaded

http://gmodwiki.net/favicon.ico](http://gmodwiki.net/Lua/Libraries/util/IsModelLoaded)**

Potential alternatives, might be worth a look.

Those only work if you’ve precached/loaded the model. It doesn’t even work right then, you have to physically spawn the model.

[lua]local MOSSMAN = “models/mossman.mdl”
print(file.Exists(MOSSMAN, “GAME”), util.IsValidModel(MOSSMAN), util.IsModelLoaded(MOSSMAN))
Model(MOSSMAN)
print(util.IsValidModel(MOSSMAN), util.IsModelLoaded(MOSSMAN))
RunConsoleCommand(“gm_spawn”, MOSSMAN)
print(util.IsValidModel(MOSSMAN), util.IsModelLoaded(MOSSMAN))[/lua]

Outputs:



true	false	false
false	false
true	true