Nebual / sandbox-plus

A community fork of Facepunch's Sandbox gamemode for s&box, with tweaks to allow modular addons, like Wirebox, to extend it further
MIT License
16 stars 9 forks source link

Add Entity.GetPlayerOwner() + player.cantool Event #9

Closed Nebual closed 1 year ago

Nebual commented 1 year ago

Minimum functionality required for a Prop Protection to be implemented.

Example minimalist Prop Protection that would treat all tools (including "tool_wiring" & "use" & "physgun") the same, and only allows the Entity's owner player to trace:

[Event( "player.cantool" )]
public static void OnCanTool( CanToolParams canToolParams )
{
    if ( canToolParams.entity.GetPlayerOwner().IsValid() && canToolParams.player != canToolParams.entity.GetPlayerOwner() )
    {
        canToolParams.preventDefault = true;
    }
}