So, I asked my friend, Jagger, if he could make me a LUA that gives Prop Mass and Model. My friend, Jagger, being as generous as he is made me this:

 if CLIENT then
function GetMassOfProp()
local tr = LocalPlayer():GetEyeTrace()
if not tr.Entity then return end
LocalPlayer():PrintMessage(HUD_PRINTTALK, "Mass: "" Model: "
concommand.Add( "propinfo", GetMassOfProp )
print("This is a client-side addon")

I get this message when I type propinfo in console while looking at any prop:

 ] propinfo 
autorun/client/propinfo.lua:5: Tried to use invalid object (type IPhysicsObject) (Object was NULL or not of the right type)

If there is a fix could you point it out? Any help would be appreciated.


Sorry, I posted in wrong section. I think.

The physics object doesn’t exist. I don’t know why, I tried making my own command to try this out,
[lua]if not CLIENT then return end

local function PropInfo(ply,cmd,arg)

local tr = ply:GetEyeTrace()

if not ValidEntity(tr.Entity) then
	ply:PrintMessage(HUD_PRINTTALK,"You must aim at a prop to get the information.")


local mass = tr.Entity:GetPhysicsObject()
if not mass:IsValid() then
	mass = "None"
	mass = mass:GetMass()

local model = tr.Entity:GetModel()

ply:PrintMessage(HUD_PRINTTALK, "Mass: "..mass)
ply:PrintMessage(HUD_PRINTTALK, "Model: "..model)

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

Mass: None
Model: models/props_borealis/bluebarrel001.mdl
Mass: None
Model: models/props_c17/furnituredrawer001a.mdl
Mass: None
Model: models/props_c17/gravestone003a.mdl
Mass: None
Model: models/props_combine/headcrabcannister01a.mdl

So you get the prop model, but not mass?

Yeah, I don’t know why it’s not getting the Physics Object.

Gah, the mass is the biggest part. Thanks though I can use the model info.


No help?

Well, I’ve checked my friends list and it happens that none of my coder friends are on.

It’s not a code problem. It seems you can’t get the Physics object clientside in singleplayer. I don’t know about multiplayer but I guess it’s the same. You’ll have to run that serverside. So the same code CowThing posted but in lua/autorun/ and without the client check.

How does the Weight Stool work then? That is more a SP and MP.

Because STools are Serverside.

Why is GetPhysicsObject even shared if it doesn’t work on the client?

Maybe it only works on client side entities?

I know another function did the same thing. It was shared, the server could manipulate props and things, but clients could only do gibs and such.

There is still something called clientside prediction in source.

So there is no way to get mass clientside?

No, unless if you can set a variable serverside.