Ghosting props (To prevent prop pushing)

So for my server I’m trying to get it so people can’t prop push other people, like if the prop is touched by a physgun it doesn’t collide with people

I got this so far

[lua]hook.Add(“PhysgunPickup”, “somethingelse”, function(ply, ent)
if ents.FindByClass(“prop_physics”) then
ent:SetNotSolid(true)
end
end)
hook.Add(“PhysgunDrop”, “somethingawesome”, function(ply, ent)
if ents.FindByClass(“prop_physics”) then
ent:SetNotSolid(false)
end
end)
[/lua]

You forgot to end the funtion on both hooks for a start

Alright it has been added

[lua]
hook.Add(“PhysgunPickup”, “somethingelse”, function(ply, ent)
ent.OldSolid = ent:GetSolid()
ent:SetSolid(SOLID_NONE)
end)

hook.Add(“PhysgunDrop”, “somethingawesome”, function(ply, ent)
if ent.OldSolid then
ent:SetSolid(ent.OldSolid)
end
end)
[/lua]

Something like that.

[editline]19th January 2011[/editline]

Not sure if the physgun would drop the ent though once it’s set to not solid.

It works except the prop goes through the map when picked up

Try one of the other **[SOLID_ enumerations

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Solid)**

SOLID_BSP sounds promising.

[editline]19th January 2011[/editline]

Actually collision group would probably be better (collides with anything but players instead of just world)
[lua]
hook.Add(“PhysgunPickup”, “somethingelse”, function(ply, ent)
ent.OldSolid = ent:GetCollisionGroup()
ent:SetCollisionGroup(COLLISION_GROUP_WEAPON)
end)

hook.Add(“PhysgunDrop”, “somethingawesome”, function(ply, ent)
if ent.OldSolid then
ent:SetCollisionGroup(ent.OldSolid)
end
end)
[/lua]

Yeah works perfect thanks man

There’s always a problem with this, you can trap players easily. Find a way to stop that and you’re free. :stuck_out_tongue:

I made this once in FPP. It was so shit that I removed it again.

and by shit I don’t mean broken or buggy, but fucking annoying.

The problem with this, without any checks, is that if you release a prop inside a player, he’ll get stuck.

**[Entity.SetTrigger

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Entity.SetTrigger)** should let physicsobject being able to detect **[PhysObj.IsPenetrating

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=PhysObj.IsPenetrating)** when the entity is using a different collision group.
And then when the user will release the prop from the physgun/physcannon you stop it’s relative movement to prevent prop killing.

Why not write a script that says that ply is no collided with all props? Then you can’t trap, prop push, or anything… AND i know some retard is going to say… “What if they are making a ramp and don’t want to be no collided with props?”. My answer to that is to have an option somewhere in the Q menu or like f4 so they can uncheck it and then they won’t be no collided. Sorry for the essay :stuck_out_tongue:

[lua]if PhysObj.IsPenetrating(player) then
ent:Remove()[/lua]

What if i add that, I’m trying to make the prop remove when it is in someone

It would be better if you made it nocollide between a player.

Spawn a prop and push it with another prop.

[lua]
hook.Add(“PhysgunPickup”, “somethingelse”, function(ply, ent)
ent.OldSolid = ent:GetCollisionGroup()
ent:SetCollisionGroup(COLLISION_GROUP_WEAPON)
end)

hook.Add("PhysgunDrop", "somethingawesome", function(ply, ent)
    if util.PointContents(ent:GetPos()) == CONTENTS_SOLID then --Might also try CONTENTS_PLAYERCLIP
        ent:Remove()
        return
    end
    if ent.OldSolid then
        ent:SetCollisionGroup(ent.OldSolid)
    end
end)

[/lua]

Untested.

There’s a function I found last night you could use, works great.

[lua]
function CheckPropSolid(e,solidtype,nonsolidtype,SolidCallback)
if e == NULL then return; end;
local trace = {start = e:GetPos(),endpos = e:GetPos(),filter = e};
local tr = util.TraceEntity(trace,e);
if tr.Hit then
e:SetCollisionGroup(nonsolidtype);
timer.Simple(0.5,CheckPropSolid,e,solidtype,nonsolidtype,SolidCallback);
else
e:SetCollisionGroup(solidtype);
if SolidCallback then
SolidCallback(e);
end
end
end
[/lua]

You should set it’s alpha lower as well, for effects.

Loures yours works most of the time, then sometimes it doesn’t work so people can prop push

Drew where would i add the function im only familiar with hooks