コード例 #1
0
ファイル: DrugsManager.cs プロジェクト: MTG-RP/V-RP
        public void cmd_aopencrate(Client sender)
        {
            Account a = sender.GetAccount();

            if (a.AdminLevel < 5)
            {
                return;
            }

            if (a.AdminDuty)
            {
                Airdrop drop = FindNearestAirdrop(sender);
                if (drop == null)
                {
                    API.SendChatMessageToPlayer(sender, "No crate around.");
                    return;
                }

                if (drop.IsOpen)
                {
                    API.SendChatMessageToPlayer(sender, "Crates already open!");
                    return;
                }

                ChatManager.NearbyMessage(sender, 10, "~p~" + a.AdminName + " opens the crate.");
                drop.IsOpen = true;
                drop.UpdateMarkerOpen();
                return;
            }

            API.SendChatMessageToPlayer(sender, "You're not on admin duty!");
            LogManager.Log(LogManager.LogTypes.AdminActions,
                           $"[/{MethodBase.GetCurrentMethod().GetCustomAttributes(typeof(CommandAttribute), false)[0].CastTo<CommandAttribute>().CommandString}] Admin {a.AdminName} has admin opened a crate.");
        }
コード例 #2
0
ファイル: DrugsManager.cs プロジェクト: MTG-RP/V-RP
        public void cmd_lockcrate(Client sender)
        {
            if (sender.GetAccount().AdminLevel < 5)
            {
                return;
            }

            Airdrop a = FindNearestAirdrop(sender);

            if (a == null)
            {
                return;
            }
            if (!a.IsOpen)
            {
                return;
            }

            a.UpdateMarkerClose();
            Account acc = sender.GetAccount();

            ChatManager.NearbyMessage(sender, 10, "~p~" + acc.AdminName + " locks the crate.");



            LogManager.Log(LogManager.LogTypes.AdminActions,
                           $"[/{MethodBase.GetCurrentMethod().GetCustomAttributes(typeof(CommandAttribute), false)[0].CastTo<CommandAttribute>().CommandString}] Admin {acc.AdminName} has locked a crate.");
        }
コード例 #3
0
ファイル: DrugsManager.cs プロジェクト: MTG-RP/V-RP
        public void OpenCrate(Client sender)
        {
            if (API.IsPlayerInAnyVehicle(sender))
            {
                API.SendChatMessageToPlayer(sender, "You can't open a crate while you're in a vehicle!");
                return;
            }

            Airdrop   closest = FindNearestAirdrop(sender);
            Character c       = sender.GetCharacter();

            if (closest == null)
            {
                return;
            }

            if (!closest.IsOpen)
            {
                ChatManager.RoleplayMessage(c, "attempts to open the crate, but was unable to open it.", ChatManager.RoleplayMe);
                API.SendChatMessageToPlayer(sender, "The crate is locked.");
                return;
            }

            ChatManager.RoleplayMessage(c, "attempts to open the crate, peering inside.", ChatManager.RoleplayMe);

            InventoryManager.ShowInventoryManager(sender, sender.GetCharacter(), closest, "Inventory: ", "Crate: ");
        }
コード例 #4
0
ファイル: DrugsManager.cs プロジェクト: MTG-RP/V-RP
        private Airdrop FindNearestAirdrop(Client sender, float bound = 5)
        {
            Airdrop drop = null;

            foreach (var a in _airdrops)
            {
                var dist = a.Loc.DistanceTo(API.GetEntityPosition(sender));
                if (dist < bound)
                {
                    drop = a;
                }
            }
            return(drop);
        }
コード例 #5
0
ファイル: DrugsManager.cs プロジェクト: MTG-RP/V-RP
        // Creates the drop, adds it to the list and calls for the prop to be set on the floor.
        public void SpawnDrop(Client sender, IInventoryItem drug)
        {
            var drop = new Airdrop(drug, API.GetEntityPosition(sender));

            _airdrops.Add(drop);
            PlaceAirDropProp(drop, API.GetEntityPosition(sender));
            API.TriggerClientEvent(sender, "PLACE_OBJECT_ON_GROUND_PROPERLY", drop.prop, "");
            Vector3 crateLoc = API.GetEntityPosition(drop.prop);

            drop.SetCorrectCrateLocation(crateLoc);
            drop.marker = new MarkerZone(crateLoc, new Vector3())
            {
                TextLabelText = "Drugs Crate - Locked"
            };
            drop.marker.Create();
        }
コード例 #6
0
ファイル: DrugsManager.cs プロジェクト: MTG-RP/V-RP
        public void cmd_deleteCrate(Client sender)
        {
            Account a = sender.GetAccount();

            if (a.AdminLevel < 5)
            {
                return;
            }

            Airdrop dropToDelete = FindNearestAirdrop(sender);

            if (dropToDelete == null)
            {
                API.SendChatMessageToPlayer(sender, "No airdrops nearby.");
                return;
            }

            dropToDelete.Delete();
            _airdrops.Remove(dropToDelete);
            API.SendChatMessageToPlayer(sender, "Airdrop has been deleted.");
            LogManager.Log(LogManager.LogTypes.AdminActions,
                           $"[/{MethodBase.GetCurrentMethod().GetCustomAttributes(typeof(CommandAttribute), false)[0].CastTo<CommandAttribute>().CommandString}] Admin {a.AdminName} has deleted a crate.");
        }
コード例 #7
0
ファイル: DrugsManager.cs プロジェクト: MTG-RP/V-RP
        public void PryCrate(Client sender)
        {
            if (API.IsPlayerInAnyVehicle(sender))
            {
                API.SendChatMessageToPlayer(sender, "You can't pry a crate while you're in a vehicle!");
                return;
            }

            Character c       = sender.GetCharacter();
            Airdrop   closest = FindNearestAirdrop(sender);

            if (closest == null)
            {
                return;
            }

            if (closest.IsOpen)
            {
                API.SendChatMessageToPlayer(sender, "This crate is already open!");
                return;
            }

            if (!closest.IsOpen && InventoryManager.DoesInventoryHaveItem <Crowbar>(c).Length >= 1)
            {
                ChatManager.RoleplayMessage(c, "forces open the crate, using their crowbar to pry the lid off.",
                                            ChatManager.RoleplayMe);
                closest.UpdateMarkerOpen();
                LogManager.Log(LogManager.LogTypes.Commands,
                               $"[/{MethodBase.GetCurrentMethod().GetCustomAttributes(typeof(CommandAttribute), false)[0].CastTo<CommandAttribute>().CommandString}] User {c.CharacterName} has opened a crate.");

                return;
            }

            ChatManager.RoleplayMessage(c, "attempts to pry open the crate lid with their hands, but is unable to.", ChatManager.RoleplayMe);
            API.SendChatMessageToPlayer(sender, "You need a crowbar for this!");
        }
コード例 #8
0
ファイル: DrugsManager.cs プロジェクト: MTG-RP/V-RP
        // Airdrop helper methods.

        public void PlaceAirDropProp(Airdrop drop, Vector3 loc)
        {
            drop.prop = API.CreateObject(1885839156, drop.Loc, new Vector3());
        }