• Random skin groups?
    7 replies, posted
Is there a line to make a model spawn with a random skin group every time it's spawned?
table.Random.
Example: [lua]MaleModels = { "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" } ply:SetModel( MaleModels[math.random(1,#MaleModels)] )[/lua]
or... [lua]MaleModels = { "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" } ply:SetModel(table.Random(MaleModels))[/lua]
That's actual models though, if he wants multiple skins on a model, you could use Keyvalues + the skin value, though I don't know if there's a way to get the highest number of skins on a model. (Anything over the highest reverts back to the default)
You can get the number of skins clientside with NumModelSkins(mdl), but it's called from the engine on the client, so I aren't sure how you'd get it on the server. Here's a snippet though if anyone figures out how to get the NumModelSkins function working serverside. [lua] hook.Add("PlayerSpawnedProp", "RandomSkin", function(ply, mdl, ent) local iSkins = NumModelSkins(mdl) if iSkins > 0 then ent:SetSkin(math.random(0, iSkins)) end end) [/lua]
[b][url=http://wiki.garrysmod.com/?title=Util.GetModelInfo]Util.GetModelInfo [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
lol he Lua Halpered everyone
Sorry, you need to Log In to post a reply to this thread.