Script not working : No errors, but no results

This is my code:

[lua]
local models = {}
models[1] = “models\player\group01\Female_01.mdl”
models[2] = “models\player\group01\Female_02.mdl”
models[3] = “models\player\group01\Female_03.mdl”
models[4] = “models\player\group01\Female_04.mdl”
models[5] = “models\player\group01\Female_06.mdl”
models[6] = “models\player\group01\Female_07.mdl”
models[7] = “models\player\group01\Male_01.mdl”
models[8] = “models\player\group01\Male_02.mdl”
models[9] = “models\player\group01\Male_03.mdl”
models[10] = “models\player\group01\Male_04.mdl”
models[11] = “models\player\group01\Male_05.mdl”
models[12] = “models\player\group01\Male_06.mdl”
models[13] = “models\player\group01\Male_07.mdl”
models[14] = “models\player\group01\Male_08.mdl”
models[15] = “models\player\group01\Male_09.mdl”

local admin_Models = { }
admin_Models[“STEAM_0:1:22894915”] = “models\player\breen.mdl”

function AdminModels( ply )
local r = math.random( 1, 15 )
ply:SetModel( models[r])
for k,v in pairs(admin_Models) do
if ply:SteamID() == k then
ply:SetModel(v)
end
end
end

hook.Add(“PlayerLoadout”, “AdminModels”, AdminModels)
[/LUA]

I am trying to set peoples models to the defaults, then i can chack if the player is in the database, then change him in function to that. No errors, but i am not breen!

[editline]11:40AM[/editline]

Bump-a cars

You cant bump within 6 hours of the thread being made.

[editline]05:31PM[/editline]

Anyways, hold on 2 seconds…

[editline]05:36PM[/editline]

Would this do?


local models = {}
models[1] = "models\player\group01\Female_01.mdl"
models[2] = "models\player\group01\Female_02.mdl"
models[3] = "models\player\group01\Female_03.mdl"
models[4] = "models\player\group01\Female_04.mdl"
models[5] = "models\player\group01\Female_06.mdl"
models[6] = "models\player\group01\Female_07.mdl"
models[7] = "models\player\group01\Male_01.mdl"
models[8] = "models\player\group01\Male_02.mdl"
models[9] = "models\player\group01\Male_03.mdl"
models[10] = "models\player\group01\Male_04.mdl"
models[11] = "models\player\group01\Male_05.mdl"
models[12] = "models\player\group01\Male_06.mdl"
models[13] = "models\player\group01\Male_07.mdl"
models[14] = "models\player\group01\Male_08.mdl"
models[15] = "models\player\group01\Male_09.mdl"


function AdminModels( ply )
	local r = math.random( 1, 15 )
	if not ply:SteamID == ("STEAM_0:1:22894915") then
	ply:SetModel( models[r])
		else 
	ply:SetModel("models/players/breen.mdl")
	end
end

hook.Add("PlayerLoadout", "AdminModels", AdminModels)


Wait, so you are trying to make it so that if the person isn’t admin it makes them a model from the table, otherwise they are breen?

It looks like it’s been solved, but if you want all admins to be breen and not just that steamid use:

[lua]
local models = {}
models[1] = “models\player\group01\Female_01.mdl”
models[2] = “models\player\group01\Female_02.mdl”
models[3] = “models\player\group01\Female_03.mdl”
models[4] = “models\player\group01\Female_04.mdl”
models[5] = “models\player\group01\Female_06.mdl”
models[6] = “models\player\group01\Female_07.mdl”
models[7] = “models\player\group01\Male_01.mdl”
models[8] = “models\player\group01\Male_02.mdl”
models[9] = “models\player\group01\Male_03.mdl”
models[10] = “models\player\group01\Male_04.mdl”
models[11] = “models\player\group01\Male_05.mdl”
models[12] = “models\player\group01\Male_06.mdl”
models[13] = “models\player\group01\Male_07.mdl”
models[14] = “models\player\group01\Male_08.mdl”
models[15] = “models\player\group01\Male_09.mdl”

function AdminModels( ply )
if !ply:IsAdmin() then
local r = math.random( 1, 15 )
ply:SetModel( models[r])
else ply:SetModel(“models\player\breen.mdl”)
end
end

hook.Add(“PlayerLoadout”, “AdminModels”, AdminModels)
[/lua]

I think that’s what he wants.

It’s the other way around, I believe, it should work, too.

Oh well, atleast the guy with the matching STEAM ID.

Well, I think he wants it so that multiple admins can have multiple different models :s

Yea, probably - if that’s what you want, use Sintwin’s code.

If I were you, I’d use


table.Random( table )

, not math.Random,

What’s the difference?

If you add more models, you won’t have to change the 15 to a different number.


local models = {}
models[1] = "models\player\group01\Female_01.mdl"
models[2] = "models\player\group01\Female_02.mdl"
models[3] = "models\player\group01\Female_03.mdl"
models[4] = "models\player\group01\Female_04.mdl"
models[5] = "models\player\group01\Female_06.mdl"
models[6] = "models\player\group01\Female_07.mdl"
models[7] = "models\player\group01\Male_01.mdl"
models[8] = "models\player\group01\Male_02.mdl"
models[9] = "models\player\group01\Male_03.mdl"
models[10] = "models\player\group01\Male_04.mdl"
models[11] = "models\player\group01\Male_05.mdl"
models[12] = "models\player\group01\Male_06.mdl"
models[13] = "models\player\group01\Male_07.mdl"
models[14] = "models\player\group01\Male_08.mdl"
models[15] = "models\player\group01\Male_09.mdl"


function ModelsLOL(ply)
if !ply:IsAdmin then
ply:SetModel(table.Random(models))
	else
ply:SetModel("models/player/breen.mdl")
end
end
hook.Add("PlayerLoadout", "Models", ModelsLOL)

^ table random

still not working

Where did you put the code?

Why are you doing this in PlayerLoadout?

Do it in PlayerSpawn (although it probably won’t make a difference).

I was going to suggest that but I thought I was probably wrong and would seem an idiot lol.

i was doing it in playerloadout cause its called AFTER the spawn, and therefor it might not fuc* things up

Same :smug:

Yea, I dont think you can set their model after they spawn.

Do it at PlayerSpawn

You can change model whenever you want, you never used a disguise on prison break?

The reason I said to do it in PlayerSpawn instead of PlayerLoadout is because PlayerLoadout could be overridden by a script that changes the default loadout.