I noticed that entities lose all player interaction when the player dies while holding it with their Grav Gun. I checked a bunch of HL2 props and they screw up.
I removed all my addons just in case one was at fault but it still happened. I whipped this up and it fixes it.
[lua]local function GGFix_Death(ply)
local ent = ply.GGFEnt;
if (ValidEntity(ent)) then
DropEntityIfHeld(ent);
ent:SetOwner(nil);
ply.GGFEnt = nil;
end
end
hook.Add(“PlayerDeath”, “GravGunFix_PlayerDeath”, GGFix_Death);
local function GGFix_OnPickedUp(ply, ent)
ply.GGFEnt = ent;
end
hook.Add(“GravGunOnPickedUp”, “GravGunFix_OnPickedUp”, GGFix_OnPickedUp);
local function GGFix_OnDropped(ply, ent)
if (ValidEntity(ply.GGFEnt)) then
ply.GGFEnt = nil;
end
end
hook.Add(“GravGunOnDropped”, “GravGunFix_OnDropped”, GGFix_OnDropped);[/lua]
I wanted to make sure it wasn’t just my GMod.