Is there a way to have an unlocked door with code lock that no player can change the code and take the lock or lock it?
Trying to build a spawn point with some doors that are locked and others unlocked all with code locks
Protecting code locks?
Discussion in 'Rust Discussion' started by RESiSTANCE 2, Aug 10, 2017.
-
The hook "CanPickupLock" was implemented for such reasons.
-
possible that this only happens in a zone? sorry, I'm new to modding
-
Code:
// Variable for our permission private const string perm = "pluginname.able"; // This hook is called when the plugin is initialised private void Init() { // Registering the permission stored in our previously declared variable // The 'this' key word is the plugins instance, in simple terms: so oxide can assign the permission to your plugin permission.RegisterPermission(perm, this); } // This hook is called when a player attempts to use a locked entity // aka locked door, locked box, locked toolcupboard // the return type is object so we can return a value (to override default behavior) // in oxide hooks, returning a value usually always overrides default behavior, but it depends on the hook you're using. http://docs.oxidemod.org/rust/ // in this case we want to override default behavior so a player can use a locked entity, so we return 'true' private object CanUseLockedEntity(BasePlayer player, BaseLock baseLock) { // checks if the player has the permission previously declared and registered // also checks if the player is an administrator if (!permission.UserHasPermission(player.UserIDString, perm) && !player.IsAdmin) // we return null here so the player hears the typical codelock deny sound etc return null; // we return true here so the player can use the locked entity, if we was to return false // they wouldn't be able to use the locked entity (afaik) return true; }
Last edited by a moderator: Aug 11, 2017