Exemplo n.º 1
0
        public void OnCallCommand(PlayerCallCommandEvent ev)
        {
            b = UnityEngine.Object.FindObjectOfType <Broadcast>();
            string cmd = ev.Command.ToLower();

            if (cmd.StartsWith("votekick"))
            {
                if (VoteKick.isPlayerBanned(ev.Player))
                {
                    ev.ReturnMessage = "You have been banned from using VoteKick.";
                    return;
                }
                vPlayerCount     = PluginManager.Manager.Server.GetPlayers().Count;
                ev.ReturnMessage = StartVote(ev.Command, ev.Player);
            }
            else if (cmd == "voteyes")
            {
                if (VoteKick.isPlayerBanned(ev.Player))
                {
                    ev.ReturnMessage = "You have been banned from using VoteKick.";
                    return;
                }
                ev.ReturnMessage = Vote(true, ev.Player);
            }
            else if (cmd == "voteno")
            {
                if (VoteKick.isPlayerBanned(ev.Player))
                {
                    ev.ReturnMessage = "You have been banned from using VoteKick.";
                    return;
                }
                ev.ReturnMessage = Vote(false, ev.Player);
            }
        }
Exemplo n.º 2
0
        public string[] OnCall(ICommandSender sender, string[] args)
        {
            if (Directory.Exists(VoteKick.BanFolderFilePath))
            {
                string steamid;
                Player myPlayer = VoteKick.GetPlayer(args[0], out myPlayer);
                if (myPlayer != null)
                {
                    steamid = myPlayer.SteamId;
                }
                else if (ulong.TryParse(args[0], out ulong a))
                {
                    steamid = a.ToString();
                }
                else
                {
                    return(new string[] { "Error: invalid player." });
                }

                File.Create($"{VoteKick.BanFolderFilePath}{Path.DirectorySeparatorChar}{steamid}.txt");
                return(new string[]
                {
                    $"{VoteKick.GetPlayer(steamid).Name} has been banned."
                });
            }
            else
            {
                return(new string[]
                {
                    "Error locating config folder."
                });
            }
        }
Exemplo n.º 3
0
        public string StartVote(string command, Player player)
        {
            string rMessage = "";

            if (VoteKick.cVoteRanks.Count > 0 && !VoteKick.cVoteRanks.Contains(player.GetRankName()))
            {
                return("Your rank is not allowed to initiate a vote kick.");
            }
            else if (VoteKick.isPlayerXP && (int.Parse(File.ReadAllText(FileManager.GetAppFolder() + "PlayerXP"
                                                                        + Path.DirectorySeparatorChar.ToString() + player.SteamId + ".txt").Split(':')[0]) < VoteKick.cVoteLevel))
            {
                return($"You must be at least level {VoteKick.cVoteLevel} to initiate a vote kick.");
            }

            if (isRoundStarted)
            {
                if (!isVoting)
                {
                    string[] args = VoteKick.StringToStringArray(command.Replace("votekick ", ""));

                    if (args.Length > 0)
                    {
                        string steamid  = "";
                        Player myPlayer = VoteKick.GetPlayer(args[0], out myPlayer);
                        if (myPlayer != null)
                        {
                            steamid = myPlayer.SteamId;
                        }
                        else if (ulong.TryParse(args[0], out ulong a))
                        {
                            steamid = a.ToString();
                        }

                        target = VoteKick.GetPlayer(steamid);
                        if (target != null)
                        {
                            if (player.SteamId != target.SteamId)
                            {
                                if (!VoteKick.cImmuneRanks.Contains(target.GetRankName().ToLower()))
                                {
                                    caller = player;
                                    if (!onCooldown)
                                    {
                                        b.CallRpcAddElement($"<color=#10EE00>{caller.Name}</color> has initiated a vote kick against <color=#FF0000>{target.Name}</color>. To vote, press [`] or [~] and type <color=#10EE00>.voteyes</color> or <color=#FF0000>.voteno</color>.", 10, false);
                                        rMessage = "Vote has been started.";
                                        isVoting = true;

                                        Timing.RunCoroutine(RunInSeconds(() => EndVote(), VoteKick.cTimeout));
                                    }
                                    else
                                    {
                                        rMessage = $"You cannot start a vote kick for another {vCooldown} second{(vCooldown == 1 ? "" : "s")}.";
                                    }
                                }
                                else
                                {
                                    rMessage = "You cannot vote kick this player.";
                                }
                            }
                            else
                            {
                                rMessage = "You cannot initiate a vote on yourself.";
                            }
                        }
                        else
                        {
                            rMessage = "Invalid player.";
                        }
                    }
                }
                else
                {
                    rMessage = "There is already a vote in progress.";
                }
            }
            else
            {
                rMessage = "Round must be started to initiate vote kick.";
            }
            return(rMessage);
        }