Having a playermodel set to default for TTT roles

Hello.

How would i go about making a playermodel default for specific roles on TTT?

Say i have 3 skins. I do not want them in pointshop. I want them defaulted for Innocents and Traitors at random. (meaning not only 1 skin is used, it picks a random skin per player)

I have a detective only skin and i’m playing with the code. Help with this would be great.

On the round start hook, loop through all players, use GetRole to check ROLE_INNOCENT/etc and then SetModel(“string”)

[editline]28th October 2015[/editline]

Oh, and have a table of filepaths, then use table.Random to pick

I’m trying this through the model’s lua and it’s working with IsActiveTraitor and detective. I know IsActiveInnocent isn’t a thing, so what can i do in replace of that?

Either GetRole or use not operators on the traitor and detective checks.

Where would a GetRole hook go?

It’s a function, not a hook.

Would this be correct?:


hook.Add("TTTBeginRound", "BeginRoundInnocentSkin", function()
    for k,v in pairs(player.GetAll()) do
        if v:GetRole()  == "ROLE_INNOCENT" then
            v:SetModel("models/player/skeleton.mdl")
        end
    end
end)

This works fine:


hook.Add("TTTBeginRound", "BeginRoundTraitorSkin", function()
    for k,v in pairs(player.GetAll()) do
        if v:IsActiveTraitor() then
            v:SetModel("models/player/skeleton.mdl")
        end
    end
end)

Yes

If you’re checking if a player is a Traitor or Detective, you might as well use ‘else’ because there are no other roles left (Make sure the player is alive)

How would it look with else? I’m not too great with lua.

[lua] if /Check if player is Traitor/ then
–Traitor stuff
elseif /Check if player is Detective/ then
–Detective stuff
elseif /Check if player is alive/ then
–Innocent stuff
end[/lua]

Not sure what i did wrong here but there’s no script errors. It’s just not everyone is having the skin equip to them.


hook.Add("TTTBeginRound", "BeginRoundTraitorSkin", function()
    for k,v in pairs(player.GetAll()) do
        if v:IsActiveTraitor() then
            v:SetModel("models/player/skeleton.mdl")
	   elseif v:GetRole()  == "ROLE_INNOCENT" then
            v:SetModel("models/player/skeleton.mdl")
        end
    end
end)

ROLE_INNOCENT isn’t a string, it’s an enum. Also, make sure it’s not conflicting with TTT’s PlayerSetModel