• No colliding prop hook help
    8 replies, posted
I found the following code to help nocollide props to prevent prop push, however I am running into some issues. The props can nocollide into other props, and they can trap players. How can I fix this? *edit: another issue I am having with this is that users can just physgun other users props which will disable the collision [CODE]local BAP = {} function BAP.Velocity( ply, ent ) if not IsValid(ent) then return end ent:SetPos(ent:GetPos()) end function BAP.DMG( ent, dmginfo ) if not IsValid(ent) then return end if ent:IsPlayer() and dmginfo:GetDamageType() == DMG_CRUSH then dmginfo:ScaleDamage( 0.0 ) end end function BAP.Pickup(ply, ent) if not IsValid(ent) then return end if ent:GetClass() == "prop_physics" then ent:SetCollisionGroup( COLLISION_GROUP_DEBRIS ) -- COLLISION_GROUP_WEAPON=Doesn't collide with players and vehicles/COLLISION_GROUP_DEBRIS=Collides with nothing but world and static stuff end end function BAP.Drop(ply, ent) if not IsValid(ent) then return end if ent:GetClass() == "prop_physics" then ent:SetCollisionGroup( COLLISION_GROUP_NONE ) end end function BAP.FreezeIt(wep, phys, ent, ply) if not IsValid(ent) then return end if ent:GetClass() == "prop_physics" then ent:SetCollisionGroup( COLLISION_GROUP_PLAYER ) end end hook.Add("PhysgunDrop", "BAP_AntiVelocity", BAP.Velocity) hook.Add("EntityTakeDamage", "BAP_AntiDMG", BAP.DMG) hook.Add("PhysgunPickup", "BAP_NoCollide", BAP.Pickup) hook.Add("OnPhysgunFreeze", "BAP_FreezePlayer", BAP.FreezeIt) [/CODE]
[QUOTE=SgtCheesepuff;50544261]I found the following code to help nocollide props to prevent prop push, however I am running into some issues. The props can nocollide into other props, and they can trap players. How can I fix this? *edit: another issue I am having with this is that users can just physgun other users props which will disable the collision [CODE]local BAP = {} function BAP.Velocity( ply, ent ) if not IsValid(ent) then return end ent:SetPos(ent:GetPos()) end function BAP.DMG( ent, dmginfo ) if not IsValid(ent) then return end if ent:IsPlayer() and dmginfo:GetDamageType() == DMG_CRUSH then dmginfo:ScaleDamage( 0.0 ) end end function BAP.Pickup(ply, ent) if not IsValid(ent) then return end if ent:GetClass() == "prop_physics" then ent:SetCollisionGroup( COLLISION_GROUP_DEBRIS ) -- COLLISION_GROUP_WEAPON=Doesn't collide with players and vehicles/COLLISION_GROUP_DEBRIS=Collides with nothing but world and static stuff end end function BAP.Drop(ply, ent) if not IsValid(ent) then return end if ent:GetClass() == "prop_physics" then ent:SetCollisionGroup( COLLISION_GROUP_NONE ) end end function BAP.FreezeIt(wep, phys, ent, ply) if not IsValid(ent) then return end if ent:GetClass() == "prop_physics" then ent:SetCollisionGroup( COLLISION_GROUP_PLAYER ) end end hook.Add("PhysgunDrop", "BAP_AntiVelocity", BAP.Velocity) hook.Add("EntityTakeDamage", "BAP_AntiDMG", BAP.DMG) hook.Add("PhysgunPickup", "BAP_NoCollide", BAP.Pickup) hook.Add("OnPhysgunFreeze", "BAP_FreezePlayer", BAP.FreezeIt) [/CODE][/QUOTE] Make a timer running on freezeit that checks if the prop is colliding with player and if not change collision group and remove timer
I am no good with coding lua, how would I create the timer and which collision group should I use?
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/timer/Create]timer.Create[/url] [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/timer/Remove]timer.Remove[/url] [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/SetSolid]Entity:SetSolid[/url] instead of collision
What's the difference between SetSolid and collision? And would I add the timer to the no collide code?
[QUOTE=SgtCheesepuff;50545947]Would I add the timer to the no collide code?[/QUOTE] No just collide
[QUOTE=rtm516;50545996]No just collide[/QUOTE] I'm so confused at what to do here.... What do you mean by No just collide? Also, how would I even set a code up that detects if a player is between a prop?
Untested but try this: (assuming your code worked) [LUA] local BAP = {} local props = {} local DelayTime = 10 function BAP.Velocity( ply, ent ) if not IsValid(ent) then return end ent:SetPos(ent:GetPos()) end function BAP.DMG( ent, dmginfo ) if not IsValid(ent) then return end if ent:IsPlayer() and dmginfo:GetDamageType() == DMG_CRUSH then dmginfo:ScaleDamage( 0.0 ) end end function BAP.Pickup(ply, ent) if not IsValid(ent) then return end if ent:GetClass() == "prop_physics" then ent:SetCollisionGroup( COLLISION_GROUP_DEBRIS ) -- COLLISION_GROUP_WEAPON=Doesn't collide with players and vehicles/COLLISION_GROUP_DEBRIS=Collides with nothing but world and static stuff end end function BAP.Drop(ply, ent) if not IsValid(ent) then return end if ent:GetClass() == "prop_physics" then ent:SetCollisionGroup( COLLISION_GROUP_NONE ) end end function BAP.FreezeIt(wep, phys, ent, ply) if not IsValid(ent) then return end if ent:GetClass() == "prop_physics" then props[ent] = CurTime() local entId = ent:GetCreationID() timer.Create("BAPFreezeItProtection"..entId, 1, 0, function() if IsValid(ent) then timer.Remove("BAPFreezeItProtection"..entId) return end if (CurTime()>=(props[ent]+DelayTime)) then ent:SetCollisionGroup( COLLISION_GROUP_PLAYER ) timer.Remove("BAPFreezeItProtection"..entId) return end end) end end function BAP.ShouldCollide(ent1, ent2) if ent1:IsPlayer() && props[ent2] then props[ent2] = CurTime() return false end end function BAP.PlayerInitialSpawn(ply) ply:SetCustomCollisionCheck(true) end hook.Add("PhysgunDrop", "BAP_AntiVelocity", BAP.Velocity) hook.Add("EntityTakeDamage", "BAP_AntiDMG", BAP.DMG) hook.Add("PhysgunPickup", "BAP_NoCollide", BAP.Pickup) hook.Add("OnPhysgunFreeze", "BAP_FreezePlayer", BAP.FreezeIt) hook.Add("ShouldCollide", "BAP_ShouldCollide", BAP.ShouldCollide) hook.Add("PlayerInitialSpawn", "BAP_PlayerInitialSpawn", BAP.PlayerInitialSpawn) [/LUA]
Will this help with players physgunning and deactivating other users entites too or no?
Sorry, you need to Log In to post a reply to this thread.