how to freeze all props

i want a way of freezing everyones props on the server to help stop lag.

Use this http://wiki.garrysmod.com/page/ents/FindByClass to find props. Then use this http://wiki.garrysmod.com/page/Entity/GetPhysicsObject and http://wiki.garrysmod.com/page/PhysObj/EnableMotion to freeze them

Don’t know why you disagree, he’s linked you to all the right things. You won’t be getting spoonfed the respone you want.

Loop through all the prop_physics entities, get their physics object, check if it is valid and if it is set enable motion to false.

[lua]
function FreezeDemProps(ply)
for k, v in pairs( ents.FindByClass( “prop_*” ) ) do
local phys = v:GetPhysicsObject()
if (IsValid(phys)) then
phys:EnableMotion(false)
end
end
ply:ChatPrint(“All dem props froze!”)
end
concommand.Add(“freezedemprops”,FreezeDemProps)
[/lua]

bottom line should it be rconcommand

…what?


rconcommand.Add("rcon_password",function() end) 

_(シ)_/

wouldnt work even if it was valid code, you can’t overwrite c++ commands

It’s trying to communicate

Edit: Also


rconcommand.Add("rcon_password",function() end)

Nowhere near enough args.



function FreezeDemProps(ply)
if ply:IsUserGroup("superadmin")  then
         for k, v in pairs( ents.FindByClass( "prop_*" ) ) do
		local phys = v:GetPhysicsObject()
		if (IsValid(phys)) then
			phys:EnableMotion(false)
		end
	end
	ply:ChatPrint("All dem props froze!")
end
else print("no")
end
concommand.Add("freezedemprops",FreezeDemProps)


This?

That won’t even work.

If you want the command to be only called by the server then just do:


concommand.Add( "freezeprops", function( ply )
	if( ply:IsPlayer() ) then return nil end
	
	-- Do Code Here
	
end )

Use flags. They exist for a reason.


concommand.Add( "freezeprops", function(  )

	-- Do Code Here

end, nil, nil, FCVAR_SERVER_CAN_EXECUTE )

100% done… lmfao