Change Player Model on Spawn

Hi, I’m having troubles on making it so that when a player spawns they are forced to be a certain player model. I didn’t have this problem in GM12, but with these lua changes in GM13 I am having difficulties. Here’s what I have so far:



function spawnmodel( ply )    
     if ply:SteamID() == "STEAM_0:1:14817695" then
        ply:SetModel("models/player/venom.mdl")
    elseif ply:IsUserGroup("superadmin") then
        ply:SetModel("models/player/combine_super_soldier.mdl")
    elseif ply:IsAdmin() then
        ply:SetModel("models/player/combine_soldier.mdl")
    elseif ply:IsUserGroup("vip") then
        ply:SetModel("models/player/gman_high.mdl")
    else
        ply:SetModel("models/player/Group01/male_07.mdl")
    end
end


hook.Add("PlayerSpawn", "setmodel", spawnmodel)

I’m also playing this on sandbox.

Any help is appreciated.

Try set the model in “PlayerSetModel” instead of “PlayerSpawn”, might have an effect.

Nope, didn’t work. Thx for trying to help though. Here’s the code in case I accidently messed something up:

You have to add:
[lua]util.PrecacheModel(Model)[/lua]

Is this inside another gamemode? You might have another hook changing the models after yours has been called.

This is in lua/autorun/server.

Run your code in a timer.Simple after a 0.1 of a second. Should overcome anything else setting the model.

I found the problem. I had to add the code in the init file of the Sandbox gamemode folder.

I would try simply returning true after your hook. That would prevent the gamemode’s select model hook from being called and thus overriding the model.