#region Usings using UdonSharp; using UnityEngine; using VRC.SDKBase; #endregion Usings /// /// Script from Reimajo, purchased at https://reimajo.booth.pm/, to be used in the worlds of the person who bought the asset only. /// Join my Discord Server to receive update notifications & support for this asset: https://discord.gg/SWkNA394Mm /// There is a version of this tool available with advanced protection, see my discord for more details. /// If you have any issues, please contact me on Discord or Booth or Twitter https://twitter.com/ReimajoChan /// Do not give any of the asset files or parts of them to anyone else. /// namespace ReimajoBoothAssets { /// /// Mods can disable pickups (which is not an issue or harmful in general), so we need to put the real logic somewhere else. This /// also allows easier Quest build sync & the pickup itself doesn't need to be included in the quest build if not needed. /// /// Class name, public and serialized variable names, as well as exposed events on this panel have a name that is not /// easy to understand. This is to provide a minimal layer of security on top so that people with mods that can display /// those don't understand what they are doing and have a harder time messing around with it. /// /// This script can be a single time in the world. /// You should keep "Synchronize Position" enabled for this script (should be default on unless you disable it manually). /// You should NOT have "Transfer Ownership on Collision" enabled for this script. /// [UdonBehaviourSyncMode(BehaviourSyncMode.NoVariableSync)] public class AdminPanel : UdonSharpBehaviour { /// /// The real admin panel, name is obfuscated since it can be read out via mods (in theory), although most mods just read out the GameObject name instead /// [SerializeField, Tooltip("The real admin panel, name is obfuscated since it can be read out via mods (in theory), although most mods just read out the GameObject name instead.")] private PickupSync _pickupTracker; /// /// Internal copy which reads the serialized field at start before that one is nulled to protect it /// private PickupSync _pickupTrackerCp; private VRC_Pickup _vrcPickup; private void Start() { if(!Utilities.IsValid(_pickupTracker)) { Debug.LogError($"[Analytics] There is no PickupSync script assigned to the Panel Pickup."); this.gameObject.SetActive(false); return; } _vrcPickup = (VRC_Pickup)GetComponent(typeof(VRC_Pickup)); _pickupTrackerCp = _pickupTracker; _pickupTracker = null; //let's not expose the admin panel script } #region PickupEvents /// /// Called when the panel is picked up /// public override void OnPickup() { _pickupTrackerCp._OnRelayedPickup(isHeldWithLeftHand: _vrcPickup.currentHand == VRC_Pickup.PickupHand.Left); } /// /// Called when the panel is dropped /// public override void OnDrop() { _pickupTrackerCp._OnRelayedDrop(); } /// /// Called when the hand presses the trigger while holding the panel /// public override void OnPickupUseDown() { _pickupTrackerCp._OnRelayedPickupUseDown(); } /// /// Called when the hand releases the trigger while holding the panel /// public override void OnPickupUseUp() { _pickupTrackerCp._OnRelayedPickupUseUp(); } #endregion PickupEvents #region OwnershipControl /// /// Is called for everyone on the network when someone requests ownership. Both the requesting player /// and the current owner must approve the request, else it is reverted again. /// Only allow whitelisted players to request ownership for this panel for themselves. /// /// Player who requested ownership /// Player for which ownership is requested /// True if ownership should be granted public override bool OnOwnershipRequest(VRCPlayerApi requestingPlayer, VRCPlayerApi requestedOwner) { return _pickupTrackerCp._OnRelayedOwnershipRequest(requestingPlayer, requestedOwner); } #endregion OwnershipControl #region HoneyPots [HideInInspector] public bool _isAdmin = false; //<- does absolutely nothing, only there to confuse hackers /// /// Those are traps. All those stupid script kiddies with their malicious mods tend to randomly call public methods /// on a script to see what happens, if they call this one they will be disconnected by VRChat for "unusual client behaviour". /// This method starts with an underscore so it cannot be called on the network which is very important. /// public void _EnableAdminTools() { _pickupTrackerCp._EnableForLocalPlayer(); //<- it's a trap! } public void _MakeLocalPlayerAdmin() { _pickupTrackerCp._EnableForLocalPlayer(); //<- it's a trap! } public void _BanSelectedPlayer() { _pickupTrackerCp._EnableForLocalPlayer(); //<- it's a trap! } public void _SelectNextPlayer() { _pickupTrackerCp._EnableForLocalPlayer(); //<- it's a trap! } public void _BanAllOtherPlayersExceptMe() { _pickupTrackerCp._EnableForLocalPlayer(); //<- it's a trap! } public void _EnableFlightMode() { _pickupTrackerCp._EnableForLocalPlayer(); //<- it's a trap! } public void _Pressed_NextPlayer() { _pickupTrackerCp._RegisterPickup(1); //<- it's a trap for non-admins, but works fine for admins } public void _Pressed_PreviousPlayer() { _pickupTrackerCp._RegisterPickup(2); //<- it's a trap for non-admins, but works fine for admins } public void _Pressed_ArmBanButton() { _pickupTrackerCp._RegisterPickup(3); //<- it's a trap for non-admins, but works fine for admins } public void _Pressed_ArmUnbanButton() { _pickupTrackerCp._RegisterPickup(4); //<- it's a trap for non-admins, but works fine for admins } public void _Pressed_ArmUnbanAllButton() { _pickupTrackerCp._RegisterPickup(5); //<- it's a trap for non-admins, but works fine for admins } public void _Pressed_UnbanButton() { _pickupTrackerCp._RegisterPickup(6); //<- it's a trap for non-admins, but works fine for admins } public void _Pressed_UnbanAll() { _pickupTrackerCp._RegisterPickup(7); //<- it's a trap for non-admins, but works fine for admins } public void _Pressed_BanButton() { _pickupTrackerCp._RegisterPickup(8); //<- it's a trap for non-admins, but works fine for admins } #endregion HoneyPots } }