Check if player is holding an ent without the use of PhysgunPickup

Clientside issue

PhysgunPickup is not reliable clientside:

  • lua_run_cl hook.Add(“PhysgunPickup”, “SeeIfItWorks”, print)

  • Bind a key to spawning a prop (ex. bind b “gm_spawn models/props_combine/breendesk.mdl”)

  • Hold left mouse while holding physgun at the floor

  • Press the button to spawn a prop

  • PhysgunPickup won’t register you picking up the prop (as the prop is not valid yet on the client?)
    Nothing prints in console

    If you release mouse button and then pick it up again it DOES output the LocalPlayer and the entity in the console.

I need another completely clientside way to find out if I’m holding a prop. One that IS reliable.
I couldn’t find any usermessages that are sent from the server to client when a prop is picked up.
I couldn’t find any special attributes to the entity when it’s being picked up.

So basically I need a way to find out whether the LocalPlayer is holding a prop with the physgun.

The only way I can think of right now is kind of hacky. You would have to check if A. the LMB is held down, B. the player’s trace.Entity is a prop or whatever, and C. LocalPlayer():GetActiveWeapon():GetClass() == “weapon_physgun”. That doesn’t really take into account the fact that you can hold stuff without looking at it, so I would just use a timer or something to check after however much time if they’re still holding it.

I can’t use that. I’m snapping to a certain angle of a prop, then pick it up and when I have actually picked it up I want to snap back. So I have to have some input from the server.

Using a timer would be ineffective. Either it wouldn’t work or it’s too slow.

check if he is on the physgun and has his finger down and then after check if he is holding a valid entity?

sorry if this conflicts with you not wanting to use physgunpickup but it might be a diffrent hook that changes the material of the physbeam?

Couldn’t you just check to see if they picked up the item then use a timer to check and see if they drop it? I’m sure of what I’m thinking of may work, maybe…


You could also recreate the physgun in lua. It wouldn’t be the first time it’s been done.

That would be serverside.

do what crazy Quebec said, as you could easly implement some easter eggs in it like you could make it that if you press mouse1+mouse32+ctrl and your health is 86 then it kills everyone

note: that was only an idea, in reality i dont want everyone to die :S

Get out.

p = LocalPlayer()
hook.Add(“Think”, “IsHoldingProp?”, function()
if p:GetActiveWeapon() == “weapon_physgun” then
if p:GetEyeTrace().Entity == “prop_physics” then
if input.IsMouseDown(MOUSE_LEFT) then

You can hold a prop if your not looking at it, and .Entity would return the entity, not the classname.


Pretty sure that means he’s looking at it.

I gave you a box, and you’re right about the .Entity not returning a classname. FPtje is smart enough to have been able to figure that out himself.