Example #1
0
        /// <summary>
        /// Updates or gives a warpplate a delay
        /// </summary>
        /// <param name="args">The command arguments</param>
        public async void SetWarpplateDelay(CommandArgs args)
        {
            // Use the given warpplate name or find the warpplate they are standing in
            string region = "";

            if (args.Parameters.Count == 3)
            {
                region = args.Parameters[1];
            }
            else if (args.Parameters.Count == 2)
            {
                region = Manager.InAreaWarpplateName(args.Player.TileX, args.Player.TileY);
            }
            else
            {
                args.Player.SendErrorMessage("Invalid syntax! Proper synatx: /wp delay [<warpplate name>] <delay in seconds>");
                args.Player.SendErrorMessage("Set 0 for immediate warp");
                return;
            }

            // Check if the warpplate exists
            Warpplate warpplate = Manager.GetWarpplateByName(region);

            if (warpplate == null)
            {
                args.Player.SendErrorMessage("No such warpplate");
                return;
            }

            // Update the delay of the given warpplate
            int Delay;

            if (int.TryParse(args.Parameters[args.Parameters.Count - 1], out Delay))
            {
                warpplate.Delay = Delay + 1;
                if (await Manager.UpdateWarpplate(warpplate.Name))
                {
                    args.Player.SendSuccessMessage("Set delay of {0} to {1} seconds", warpplate.Name, Delay);
                }
                else
                {
                    args.Player.SendErrorMessage("Something went wrong");
                }
            }
            else
            {
                args.Player.SendErrorMessage("Bad number specified");
            }
        }
Example #2
0
        /// <summary>
        /// Ticks down cooldown and carries out checks to see if they need to be warped by a warpplate
        /// </summary>
        public void Update()
        {
            if (WarpplateUseCooldown != 0)
            {
                WarpplateUseCooldown--;
                return;
            }

            string warpplateName = Manager.InAreaWarpplateName(TSPlayer.TileX, TSPlayer.TileY);

            if (warpplateName == null || warpplateName == "")
            {
                TimeStandingOnWarpplate = 0;
                HasJustUsedWarpplate    = false;
            }
            else if (!HasJustUsedWarpplate)
            {
                CheckAndUseWarpplate(warpplateName);
            }
        }