• Model table
    2 replies, posted
Hello Facepunch, I wanted to ask if theres somehow an table, containing all models on the server(maybe if possible including the addon models too), where I can run an for loop on, if yes, how do I access it/What is its variable? Edit: I found [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/player_manager/AllValidModels]player_manager.AllValidModels[/url] but does it only store "default" models, or also addon ones?
Recursively loop through the models folder?
[QUOTE=Chessnut;48801188]Recursively loop through the models folder?[/QUOTE] Well, I actually did already what I wanted with a bit of testing, just wanted to close the thread but you replied, I was too lazy to write pointshop models myself, and therefore made an small script that loops through the "global" table of valid models - still dont know if it includes addons yet; and made it write text files in the data folder with each model name: [code] if not file.Exists("modelthing", "DATA") then file.CreateDir("modelthing") end for _, v in pairs(player_manager.AllValidModels()) do local path = player_manager.TranslatePlayerModel(v) local content = [[ ITEM.Name = '%s' ITEM.Price = 10000 ITEM.Model = '%s' function ITEM:OnEquip(ply, modifications) if not ply._OldModel then ply._OldModel = ply:GetModel() end timer.Simple(1, function() ply:SetModel(self.Model) end) end function ITEM:OnHolster(ply) if ply._OldModel then ply:SetModel(ply._OldModel) end end function ITEM:PlayerSetModel(ply) ply:SetModel(self.Model) end]] content = string.format(content, player_manager.TranslateToPlayerModelName(v), v) print(content) file.Write("modelthing/"..player_manager.TranslateToPlayerModelName(v)..".txt", content) end [/code] At the end, this is the result: [img]http://i.imgur.com/3c5H118.png[/img] Now I gotta rename them all to .lua :v: -Closed
Sorry, you need to Log In to post a reply to this thread.