Beispiel #1
0
        private void TeleportRequestCancel(BasePlayer player)
        {
            if (player == null)
            {
                return;
            }

            TPR tpr = FindTPR(null, player);

            if (tpr == null)
            {
                tpr = FindTPR(player, null);
            }

            // Check if there are any pending requests
            if (tpr == null)
            {
                player.ChatMessage($"<color=#d00>Error</color> there are no pending requests.");
                return;
            }

            tpr.player.ChatMessage("Teleport request cancelled");
            tpr.target.ChatMessage("Teleport request cancelled");

            pendingTeleportRequests.Remove(tpr);
        }
Beispiel #2
0
        private void TeleportRequestAccept(BasePlayer player)
        {
            PlayerData.PData pdata = PlayerData.Get(player);

            if (player == null || pdata == null)
            {
                return;
            }

            TPR tpr = FindTPR(null, player);

            // Check if there are any pending requests
            if (tpr == null)
            {
                player.ChatMessage($"<color=#d00>Error</color> there are no pending requests.");
                return;
            }

            TeleportRequestStart(tpr.player, tpr.target, 10);

            pendingTeleportRequests.Remove(tpr);
        }
Beispiel #3
0
        private void TeleportRequest(BasePlayer player, BasePlayer target)
        {
            PlayerData.PData pdata = PlayerData.Get(player);

            if (player == null || target == null || pdata == null)
            {
                return;
            }

            // Check for the cooldown
            int cooldown = pdata.HasCooldown("teleport_tpr");

            if (cooldown > 0)
            {
                player.ChatMessage($"<color=#d00>Error</color> teleport to player cooldown {Helper.TimeFormat.Long(cooldown)}.");
                return;
            }

            // Check if the player can teleport from the current location
            string canTeleportFrom = CanTeleportFrom(player);

            if (canTeleportFrom != null)
            {
                player.ChatMessage($"<color=#d00>Error</color> you cannot teleport from your current location ({canTeleportFrom}).");
                return;
            }

            // Check if the player can teleport to the target location
            string canTeleportToPosition = CanTeleportToPosition(player, target.transform.position);

            if (canTeleportToPosition != null)
            {
                player.ChatMessage($"<color=#d00>Error</color> you cannot teleport to {target.displayName} ({canTeleportFrom}).");
                return;
            }

            // Check if the player can teleport to the target itself
            string canTeleportToPlayer = CanTeleportToPlayer(player, target);

            if (canTeleportToPlayer != null)
            {
                player.ChatMessage($"<color=#d00>Error</color> you cannot teleport to {target.displayName} ({canTeleportToPlayer}).");
                return;
            }

            player.ChatMessage($"Teleport request sent to {target.displayName}. Type /tpc to cancel the teleport request.");
            target.ChatMessage($"Teleport request from {player.displayName}. Type /tpa to accept the teleport request. Or type /tpc to cancel the teleport request.");

            pendingTeleportRequests.Add(new TPR()
            {
                player = player,
                target = target,
            });

            timer.Once(30f, () =>
            {
                TPR tpr = FindTPR(player, target);
                if (tpr != null)
                {
                    if (tpr.player != null)
                    {
                        player.ChatMessage($"Teleport request timed out.");
                    }

                    if (tpr.target != null)
                    {
                        target.ChatMessage($"Teleport request timed out.");
                    }

                    pendingTeleportRequests.Remove(tpr);
                }
            });
        }