void AddLock(BaseEntity ent)
        {
            CodeLock alock = GameManager.server.CreateEntity(lockPrefab) as CodeLock;

            alock.Spawn();
            alock.code = "789456789123";
            alock.SetParent(ent, ent.GetSlotAnchorName(BaseEntity.Slot.Lock));
            alock.transform.localScale += new Vector3(-50, -50, -50);
            ent.SetSlot(BaseEntity.Slot.Lock, alock);
            alock.SetFlag(BaseEntity.Flags.Locked, true);
            alock.SendNetworkUpdateImmediate();
        }
Exemple #2
0
        private void CmdLockQuarry(IPlayer iplayer)
        {
            if (iplayer == null)
            {
                return;
            }
            BasePlayer player = iplayer.Object as BasePlayer;

            if (player == null)
            {
                return;
            }

            if (configData.globalSettings.usePermission && !permission.UserHasPermission(iplayer.Id, PERMISSION_USE))
            {
                if (!configData.globalSettings.adminsAllowed || !iplayer.IsAdmin)
                {
                    Print(iplayer, Lang("NotAllowed", iplayer.Id));
                    return;
                }
            }

            RaycastHit rhit;
            BaseEntity entity = null;

            if (Physics.Raycast(player.eyes.HeadRay(), out rhit))
            {
                entity = rhit.GetEntity();
            }
            if (entity == null)
            {
                Print(iplayer, Lang("NotLookingAtQuarry", iplayer.Id));
                return;
            }

            Vector3 cordinates;

            if (entity.ShortPrefabName == "mining.pumpjack")
            {
                cordinates = new Vector3(-3.38f, 6.30f, -0.30f);
            }
            else if (entity.ShortPrefabName == "mining_quarry")
            {
                cordinates = new Vector3(1.35f, 10.15f, 0.00f);
            }
            else
            {
                Print(iplayer, Lang("NotAQuarry", iplayer.Id));
                return;
            }

            if (entity.OwnerID != player.userID)
            {
                Print(iplayer, Lang("Ownership", iplayer.Id));
                return;
            }

            if (entity.GetComponentInChildren <CodeLock>() != null)
            {
                Print(iplayer, Lang("Already", iplayer.Id));
                return;
            }

            if (player.inventory.FindItemID(1159991980) == null)
            {
                Print(iplayer, Lang("NoLock", iplayer.Id));
                return;
            }

            player.inventory.Take(null, 1159991980, 1);
            CodeLock codelock = GameManager.server.CreateEntity("assets/prefabs/locks/keypad/lock.code.prefab", cordinates) as CodeLock;

            if (codelock != null)
            {
                codelock.Spawn();
                codelock.SetParent(entity.GetComponent <BaseResourceExtractor>());
                if (configData.globalSettings.autoLock)
                {
                    codelock.code = Random.Range(1000, 9999).ToString();
                    codelock.SetFlag(BaseEntity.Flags.Locked, true);
                    codelock.whitelistPlayers.Add(player.userID);
                }
                Print(iplayer, Lang("Added", iplayer.Id));
            }
        }