Setting a players model only works til they die

fixed

[lua]function CitizenSetModel( ply, command, args )

for k, v in pairs( citizenmodels ) do

	if tostring( args[1] ) == v then
	
	ply:SetModel( args[1] )
            ply:GetTable().Model = args[1]

	end	
		
		
	end
	
end

concommand.Add(“rpCitizenSetModel”, CitizenSetModel)[/lua]
[/lua]

I’d store the model in a variable that changes every time the player changes his model.

Then on every spawn, change it to whatever the variable is holding.

[lua]
function ChangeModelOnSpawn( ply )

if( ply:GetTable().Model ) then
ply:SetModel( ply:GetTable().Model )
end

end
hook.Add( “PlayerSpawn”, “ChangeModelOnSpawn”, ChangeModelOnSpawn )
[/lua]

That didn’t work, is it because the player first spawned with his original model?

Don’t use GetTable, just use ply.Model and it should work.

[editline]06:13PM[/editline]

[lua]
function CitizenSetModel( ply, command, args )
for k, v in pairs( citizenmodels ) do
if tostring( args[1] ) == v then
ply:SetModel( args[1] )
ply.Model = args[1]
end
end
end
concommand.Add(“rpCitizenSetModel”, CitizenSetModel)

function ChangeModelOnSpawn( ply )
if ply.Model then
ply:SetModel( ply.Model )
end
end
hook.Add( “PlayerSpawn”, “ChangeModelOnSpawn”, ChangeModelOnSpawn )
[/lua]

Didn’t work

Override the gamemode’s playerspawn function with your own. (Don’t just hook to it)

maybe you can try adding [lua]function GM:PlayerLoadout( ply )[/lua] inside of Init, i think there is something for SetModel (to strip weapons its [lua]ply:StripWeapons()[/lua] and for giving a specific weapon it’s [lua] ply:Give( “weapon_crowbar” )[/lua]) im sure there is a SetModel type thing

I don’t think you understand what I mean.

Thanks it worked!