示例#1
0
        private void OnPlayerUnlock(ObjectUnlockEvent theEvent)
        {
            Player player   = theEvent.Sender;
            var    playerId = player.Id.ToString();

            if (AllowLockPicking)
            {
                return;
            }
            if (DeclarationOfWarEnable)
            {
                var         playerguild   = player.GetGuild();
                ulong       playerguildId = playerguild.BaseID;
                CrestScheme crestScheme   = SocialAPI.Get <CrestScheme>();
                Crest       crest         = crestScheme.GetCrestAt(player.Entity.Position);
                if (crest != null)
                {
                    var   crestguid   = crest.ObjectGUID;
                    Guild targetguild = SocialAPI.Get <GuildScheme>().TryGetGuildByObject(crestguid);


                    if (IsAtWar(playerguildId, targetguild.BaseID) && targetguild != null)
                    {
                        return;
                    }
                }
            }
            if (ProtectedZoneEnable)
            {
                var zoneId   = TryGetZoneId(player);
                var zoneFlag = "lockpickingallowed";
                if (NoLockPickingInZones)
                {
                    if (!IsInZone(player))
                    {
                        return;
                    }
                }
                if (IsInZone(player) && hasFlag(zoneId.ToString(), zoneFlag))
                {
                    return;
                }
            }
            var                  name                  = "";
            var                  position              = new Vector3();
            var                  defenseLevel          = 0;
            ISecurable           securable             = GUIDManager.TryGetObject <ISecurable>(theEvent.GUID);
            Component            component             = securable as Component;
            CageCaptureManager   cageCaptureManager    = GUIDManager.TryGetObject <CageCaptureManager>(theEvent.GUID);
            PlayerCaptureManager playerCaptureManager1 = player.Entity.TryGet <PlayerCaptureManager>();

            if (playerCaptureManager1 != null && playerCaptureManager1.Captive != null && playerCaptureManager1.Captive == player.Entity && !playerCaptureManager1.Captive.Has <CageCaptureManager>())
            {
                return;                                                                                                                                                                                      //allow prisoner to escape rope with lockpick
            }
            if (cageCaptureManager)
            {
                if (AllowCageLockPicking)
                {
                    return;
                }
                if (cageCaptureManager.Prisoner != null)
                {
                    if (cageCaptureManager.PrisonerPlayerID == player.Id)
                    {
                        return;                                                  //allow prisoner to escape with lockpick
                    }
                }
                defenseLevel = securable.Defense;
            }
            else
            {
                if (AllowDoorLockPicking)
                {
                    return;
                }
                defenseLevel = securable.Defense;
            }

            if (component != null)
            {
                Entity entity = component.TryGetEntity(); //works for cages, entity is null on all doors
                position = (entity == null ? component.gameObject.transform.position : entity.Position);
                if (entity != null)
                {
                    name = Clean(entity.name);
                }
                else
                {
                    name = "Door";
                }
            }
            theEvent.Cancel(player + " tried to unlock a " + name + " at " + position);
            securable.Lock(true);
            //give lockpicks used back
            string itemname = "Lockpick";
            int amount      = defenseLevel;
            if (!ConsumeLockPicks)
            {
                GiveInventoryStack(player, itemname, amount);
            }
            if (MessageOn)
            {
                SendReply(player, Message("Warning", playerId), name);
            }

            if (LoggingOn)
            {
                Puts(Message("Log"), player, name, player.Entity.Position);
            }
        }
        void cmdProd(Player player, string command, string[] args)
        {
            string playerId = player.Id.ToString();
            ulong  ownerId  = 0;

            if (!hasPermission(player))
            {
                return;
            }

            var        position = new Vector3();
            RaycastHit hit;

            var playerentity = player.Entity;

            if (Physics.Raycast(playerentity.Position, playerentity.GetOrCreate <LookBridge>().Forward, out hit, float.MaxValue))
            {
                position = new Vector3(hit.point.x, hit.point.y, hit.point.z);
                Collider component    = hit.collider;
                Collider mainCollider = component as Collider;
                var      collidertype = hit.collider.GetType().Name;
                var      target       = mainCollider.TryGetEntity();
                if (target == null)
                {
                    if (Physics.Raycast(playerentity.Position, playerentity.GetOrCreate <LookBridge>().Forward, out hit, float.MaxValue, layers))
                    {
                        position = new Vector3(hit.point.x, hit.point.y, hit.point.z);
                        var  block = component.gameObject;
                        bool flag  = block.FirstComponentAncestor <OctPrefab>() != null;
                        if (!flag && block.layer == BlockManager.CubeLayer && block.tag != "NonOctPrefab")
                        {
                            flag = true;
                        }
                        if (flag)
                        {
                            position = block.gameObject.transform.position; //get position of actual block
                            CrestScheme crestScheme = SocialAPI.Get <CrestScheme>();
                            Crest       crest       = crestScheme.GetCrestAt(position);

                            if (crest == null)
                            {
                                SendReply(player, lang.GetMessage("noOwnerDetected", this, playerId));
                                return;
                            }
                            SendReply(player, lang.GetMessage("guildNameIs", this, playerId), crest.GuildName);
                            var   crestguid = crest.ObjectGUID;
                            Guild guild     = SocialAPI.Get <GuildScheme>().TryGetGuildByObject(crestguid);
                            if (guild != null)
                            {
                                var guildOwner = guild.Members();
                                SendReply(player, lang.GetMessage("guildMembers", this, playerId), guildOwner);
                            }
                        }
                    }
                    else
                    {
                        SendReply(player, lang.GetMessage("noTarget", this, playerId));
                    }
                    return;
                }
                position = target.Position;          //get position of actual entity
                if (target.name.Contains("Sleeper")) //check for Sleepers
                {
                    PlayerSleeperObject sleeper = target.GetComponentInChildren <PlayerSleeperObject>();
                    SendReply(player, lang.GetMessage("sleeperName", this, playerId), sleeper.DisplayName);
                }
                else
                {
                    foreach (var entity in Entity.TryGetAll()) //check all entities positions and find the one closest to where player is looking
                    {
                        if (entity.Position == position)
                        {
                            var name       = entity.name;
                            var isecurable = entity.TryGet <ISecurable>();
                            var owner      = "";

                            foreach (var sleeper in PlayerSleeperObject.AllSleeperObjects) //Loop through sleepers and check for ownership
                            {
                                if (SocialAPI.Get <SecurityScheme>().OwnsObject(sleeper.Key, entity.TryGet <ISecurable>()))
                                {
                                    PlayerSleeperObject sleeperobject = sleeper.Value.GetComponentInChildren <PlayerSleeperObject>();
                                    ownerId = sleeper.Key;
                                    owner   = sleeperobject.DisplayName;
                                }
                            }
                            foreach (var players in Server.AllPlayers)// Check all online players for ownership
                            {
                                if (SocialAPI.Get <SecurityScheme>().OwnsObject(players.Id, entity.TryGet <ISecurable>()))
                                {
                                    ownerId = players.Id;
                                    owner   = players.Name;
                                }
                            }
                            foreach (var players in Server.DeadPlayerMessages)// Check all dead players for ownership
                            {
                                if (SocialAPI.Get <SecurityScheme>().OwnsObject(players.Key, entity.TryGet <ISecurable>()))
                                {
                                    ownerId = players.Key;
                                    owner   = players.Value;
                                }
                            }
                            SendReply(player, lang.GetMessage("getInfo", this, playerId), name, position, owner, ownerId);
                        }
                    }
                }
            }
            else
            {
                SendReply(player, lang.GetMessage("noInfo", this, playerId));
            }
            return;
        }