GM:PlayerNoClip
This hook is predicted. This means that in singleplayer, it will not be called in the Client realm.
Description
Called when a player tries to switch noclip mode.
Arguments
2 boolean desiredState
Represents the noclip state (on/off) the user will enter if this hook allows them to.
Returns
Example
Get the player when they enter/exit no clip and display their status
hook.Add( "PlayerNoClip", "isInNoClip", function( ply, desiredNoClipState )
if ( desiredNoClipState ) then
print( ply:Name() .. " wants to enter noclip." )
else
print( ply:Name() .. " wants to leave noclip." )
end
end )
Output:
Player1 wants to enter noclip.
Player1 wants to leave noclip.
Example
While keeping the default behavior of admin-only noclip, the following example will also allow anyone to turn it off (if it's set on by a third-party administration addon, for example).