• Prop inside of Player
    4 replies, posted
Hello, i'm trying to figure out how to make a prop nocollide with another player if it is frozen inside the player. Once the player is no longer inside the prop, make it solid again. [CODE]hook.Add("OnPhysgunFreeze", "Freeze", function(wep, phys, ent, ply) if ent:GetClass() == "prop_physics" then local trace = { start = ent:GetPos(), endpos = ent:GetPos(), filter = ent, ignoreworld = true } local tr = util.TraceEntity( trace, ent ) if ( tr.Hit and tr.Entity.IsPlayer and tr.Entity:IsPlayer()) then ent:SetCollisionGroup(COLLISION_GROUP_PASSABLE_DOOR) ent:SetRenderMode(RENDERMODE_TRANSALPHA) return false end end end)[/CODE] Could someone assist me?
I'm new to Gmod Lua but let me see if I can gather more information. First, what is currently happening with this chunk of code? What is your expected output? Second, this line ... [CODE]if ( tr.Hit and tr.Entity.IsPlayer and tr.Entity:IsPlayer()) then ...[/CODE] [B]tr.Entity.IsPlayer[/B] and [B]tr.Entity:IsPlayer()[/B], why both? I only see the latter in the docs. Third, your entity function calls seem to make sense but why are you returning false? Fourth, you set the render mode to [B]RENDERMODE_TRANSALPHA[/B], but you don't call [B]Entity:SetColor(Color)[/B] afterwards. What's the point? I'm not trying to criticize, I just want more information!
[QUOTE=sincity;51692176][CODE]if ( tr.Hit and tr.Entity.IsPlayer and tr.Entity:IsPlayer()) then ...[/CODE] [B]tr.Entity.IsPlayer[/B] and [B]tr.Entity:IsPlayer()[/B], why both? I only see the latter in the docs.[/QUOTE] I assume he's checking that function exists before calling it in case something unexpected happens
[QUOTE=Slowboi;51692306]I assume he's checking that function exists before calling it in case something unexpected happens[/QUOTE] That will never happen. tr.Entity will always return an entity -- NULL:IsPlayer () is even valid. If that's true, he doesn't even have to check tr.Hit or if tr.Entity is valid
Everything works as intended to besides the Entity:SetCollisionGroup(). Even if i set it to COLLISION_GROUP_WORLD the prop still remains solid. I could, of course, do ent:Remove() but that could get annoying when building.
Sorry, you need to Log In to post a reply to this thread.