Sandbox player collisions

I understand that asking for scripts isn’t a great thing to do generally, but I’m pretty stuck here and was wondering if someone could help.

I was wondering if someone could piece together a snippet that would make all players on the server, regardless of their “team” to no-collide with each-other.

Wrong section lel.


(User was banned for this post ("Why reply/this is the correct section" - NiandraLades))

Collision can be tricky… Don’t change it frequently as it’ll cause vehicles to fall through the world, and other issues.

If you keep the function static, then it is fine.


//
// Needs to be shared for prediction ( so it isn't like walking through water )
//
hook.Add( "ShouldCollide", "UpdateCollisions", function( _e1, _e2 )
	// If both ents are valid and both are players then don't collide - Only return non-nil in hook for the behavior we want to change
	if ( IsValid( _e1 ) && IsValid( _e2 ) && _e1:IsPlayer( ) && _e2:IsPlayer( ) ) then
		return false;
	end
end );


//
// Client has no business going further
//
if ( CLIENT ) then return; end


//
// Should only need to be done once on PlayerInitialSpawn
//
hook.Add( "PlayerSpawn", "UpdateCollisions", function( _p )
	_p:EnableCustomCollisions( true );
	_p:SetCustomCollisionCheck( true );
end );

This is perfect! One little issue though, admins can no longer physgun players if needed. Any way of fixing that or is it a trade-off?

Players are also unable to inflict any damage onto one-another.

There should be no issue with that… Make sure the Physgun pickup hook returns true for admins targeting players.

I’m thinking that somehow this is effecting ULX’s player physgun hook. Not entirely sure how though. As for players not receiving damage from one-another, no idea how that’s happening either. Bullets pass straight through players and don’t even register as hits. Probably also a ULX conflict.

ULX rewrites the hook system to give itself priority… probably because a lot of addons return non-nil values in hooks for anything other than their intended circumstance… but they shouldn’t have ( both ulx and any addon maker that returns non-nil in a hook.Add for any other behavior than the intended target / purpose of the hook )…

ULX causes a lot of issues because of their system, and other addons can cause issues too… What addons, other than ulx, are you running?

ULX, Ulib, gCompute & all its prerequisites, custom thirdperson by CapsAdmin. That’s it.

Edit:

Here is ULX’s player pickup stuff, if it helps in any way.



--------------------
--       Hooks      --
--------------------
-- This cvar also exists in DarkRP (thanks, FPtje)
local cl_cvar_pickup = "cl_pickupplayers"
if CLIENT then CreateClientConVar( cl_cvar_pickup, "1", true, true ) end
local function playerPickup( ply, ent )
    local access, tag = ULib.ucl.query( ply, "ulx physgunplayer" )
    if ent:GetClass() == "player" and ULib.isSandbox() and access and not ent.NoNoclip and not ent.frozen and ply:GetInfoNum( cl_cvar_pickup, 1 ) == 1 then
        -- Extra restrictions! UCL wasn't designed to handle this sort of thing so we're putting it in by hand...
        local restrictions = {}
        ULib.cmds.PlayerArg.processRestrictions( restrictions, ply, {}, tag and ULib.splitArgs( tag )[ 1 ] )
        if restrictions.restrictedTargets == false or (restrictions.restrictedTargets and not table.HasValue( restrictions.restrictedTargets, ent )) then
            return
        end


        ent:SetMoveType( MOVETYPE_NONE ) -- So they don't bounce
        return true
    end
end
hook.Add( "PhysgunPickup", "ulxPlayerPickup", playerPickup, -5 ) -- Allow admins to move players. Call before the prop protection hook.
if SERVER then ULib.ucl.registerAccess( "ulx physgunplayer", ULib.ACCESS_ADMIN, "Ability to physgun other players", "Other" ) end


local function playerDrop( ply, ent )
    if ent:GetClass() == "player" then
        ent:SetMoveType( MOVETYPE_WALK )
    end
end
hook.Add( "PhysgunDrop", "ulxPlayerDrop", playerDrop )


Still haven’t been able to work this one out. Suggestions anybody?