This frame you have created 152056384 entities!

[lua]
/-----------------------------------------------------------------
This replaces prop_physics with multiplayer ones
------------------------------------------------------------------
/
function DoPhysicsMultiplayer()
local phys = ents.FindByClass(“prop_physics”)
local collision, movetype

for k, v in pairs(phys) do
	//Save the original values
	local name = tostring ( v )
	movetype = v:GetMoveType()
	collision = v:GetCollisionGroup()
	
	//Remove the entity
	v:Remove()
	
	//Respawn the entities at multiplayer physics with same properties
	local ent = ents.Create("prop_physics_multiplayer")
	if not ent:IsValid() then return end
	
	// Add the old values
	ent:SetMoveType( movetype )
	ent:SetCollisionGroup ( collision )
		
	//Set the new keyvalues from the table init-ed in GM:EntityKeyValue
	for key, val in pairs ( tbKeyValues[name] ) do
		if key != "classname" then
			ent:SetKeyValue ( key, val )
		end
	end
		
	//Spawn the new entity
	ent:Spawn()
end

end
hook.Add(“InitPostEntity”,“MultiplayerReplace”,DoPhysicsMultiplayer)
[/lua]

Hello. I have a small issue with replacing prop_physics with prop_physics_multiplayer. On map load, this message appears into the console : [ents.Create( “prop_physics_multiplayer” )] This frame you have created 152056384 entities! (Lua Error!?).
Obviously, I haven’t created so many entites. Can I just ignore the message or does anybody know what is causing this? Thanks in advance.

You might want to put a counter inside of the loop to count how many times the loop is looping, then print that out at the end of the function to see how many replacements were actually being made.

The thing is that this message isn’t always appearing in the console :confused:

It happens to me as well, as far as I know it shouldn’t cause any problem, so you can just ignore it.

Phew. Thanks

non-related question.

What is better / worse about prop_physics_multiplayer? more optimised? less detailed physics simulation?

“It is identical to prop_physics except that it bounces away from collision (if sv_turbophysics is enabled), which helps to avoid the prediction errors that normal physics objects typically generate.”

  • Valve Developer Wiki