Assigning unique models depending on join order

I have a table of a bunch of models and I was wondering if theres a way to assign each individual model to the players as they join, so the first person to join gets the first model and second gets the second and so on, but still making sure that there arent any models repeated so everyone on the server has a unique model to them. Any help is appreciated.

Try this:

[lua]
local joinorder = 1
hook.Add(“PlayerInitialSpawn”, “AssignUniqueModels”, function( pl )
pl.UniqueModel = tableofuniquemodels[ joinorder ]
joinorder = joinorder + 1
end)

hook.Add(“PlayerSetModel”, “UseUniqueModel”, function( pl )
pl:SetModel( pl.UniqueModel )
end)
[/lua]

Change line 3’s “tableofuniquemodels” to whatever the name of your table is.
I’m assuming you setup the model table like this for example:

table_list =
{
“somemodel”,
“anothermodel”,
“etc”
}

[lua]local tab = {
“models/hi.mdl”,
“models/hi2.mdl”,
“models/hi3.mdl”
}

ply:SetModel(tab[1 + ply:UserID() % #tab])[/lua]

That would be the simplest way to do it.