Entity:SetModel() client-side causes the player to stop updating?

Hi, I am rather sick of error models on shit gmod servers so I attempted to write a script to alleviate that annoyance

[lua]
CreateConVar(“min_models”, “0”, FCVAR_SERVER_CANNOT_QUERY, “If you have errors with the models”)
local models = {“models/player/kleiner.mdl”}

local function MinModels()
if GetConVarString(“min_models”) == “0” then
for k, v in pairs(player.GetAll()) do
if (v.OldModel != nil && IsValid(v) && v:GetModel() != v.OldModel) then
v:SetModel(v.OldModel)
–print(“setting model 1”)
end
end
return
end

for k, v in pairs(player.GetAll()) do
	if (IsValid(v) && !table.HasValue(models, v:GetModel()) && v:GetModel() != "models/player/kleiner.mdl") then
		v.OldModel = v:GetModel()
		v:SetModel("models/player/kleiner.mdl") -- use table depending on what do
		--print("setting model 2")
	end
end

end

hook.Add(“Tick”, “MinModels”, MinModels)
[/lua]

For some reason, when it sets the model, the player ceases to update. I do not know why. I have checked and it is NOT repeatedly setting the playermodel.

Does anyone know how to set a model completely client-side without it screwing up like this? A weird note is, if you speedhack, it starts to “Slightly” update. It’s animations dont change, but the player begins to move.

Thanks!

what do you mean by “the player stops updating”?

He doesnt move. You dont see animations anymore, he’s just frozen.

An example is when you start a demo, when you do that, everything syncs you know. if someone was lagging, he’s now in the correct position.

It’s the opposite, his player completely stops updating.

Try doing it in PrePlayerDraw

Same result. Even putting this on a 5 second timer yields the same result.

I just did this:

[lua]function GM:PrePlayerDraw( _p )
if ( !_p.__KLEINER ) then
_p.__KLEINER = true;

	local _sequence = _p:GetSequence( );
	_p:SetModel( "models/player/kleiner.mdl" );
	_p:ResetSequence( _sequence );
end

return false;

end

function GM:PostPlayerDraw( _p )
_p.__KLEINER = false;
end[/lua]

And it works, aside from this: SetupBones: invalid bone array size (68 - needs 69)

However; it is a start… The animation frames, etc just need to be stored and re-applied ( ResetSequence resets from start, so it doesn’t animate; the current frame needs to be grabbed and reapplied ). As for the bone error… I don’t know why it spams that. Weapons don’t always show up either; I think it has something to do with the bones.

What the fuck. Why does it fuck this badly just by setting a model.

Because it is clientside; translate activity etc handles animation and prediction. If it is changed midway through then what has already been processed for the visual needs to be reapplied to the model. That is my guess, anyways…

Instead of setting the model, you could draw the Kleiner model as ClientsideModel on top of the player and transfer bone positions, and return true in PrePlayerDraw to prevent drawing of the original model. That may be simpler…