Esempio n. 1
0
 protected override void OnMsgClientCallVote(BasePlayer player, GameMsg_ClCallVote message)
 {
     Votes.CallVote(message, player);
 }
Esempio n. 2
0
 protected abstract void OnMsgClientCallVote(BasePlayer player, GameMsg_ClCallVote message);
Esempio n. 3
0
 public abstract void CallVote(GameMsg_ClCallVote message, BasePlayer player);
Esempio n. 4
0
        public override void CallVote(GameMsg_ClCallVote message, BasePlayer player)
        {
            if (message.Force && !Server.IsAuthed(player.ClientId))
            {
                return;
            }

            if (Config["SvSpamprotection"] && PlayersVoteInfo[player.ClientId].LastVoteTry + Server.TickSpeed * 3 > Server.Tick)
            {
                return;
            }

            PlayersVoteInfo[player.ClientId].LastVoteTry = Server.Tick;

            if (ActiveVote != null)
            {
                GameContext.SendChat(-1, ChatMode.All, player.ClientId, "Wait for the current vote to end");
                return;
            }

            if (player.Team == Team.Spectators)
            {
                GameContext.SendChat(-1, ChatMode.All, player.ClientId, "Wait for the current vote to end");
                return;
            }

            // TODO
            //var timeRemaning = 60 - (Server.Tick - PlayerLastVoteCall[player.ClientId]) / Server.TickSpeed;
            //if (Config["SvSpamprotection"] && timeRemaning > 0)
            //{
            //    GameContext.SendChat(-1, ChatMode.All, player.ClientId,
            //        $"Wait '{timeRemaning}' seconds for start new vote");
            //    return;
            //}

            PlayersVoteInfo[player.ClientId].LastVoteCall = Server.Tick;
            var    reason = string.IsNullOrEmpty(message.Reason) ? "No reason given" : message.Reason;
            string description;
            string command;
            Vote   voteType;

            if (message.VoteType == "option")
            {
                if (!VoteOptions.TryGetValue(message.Value, out var voteOption))
                {
                    return;
                }

                voteType    = Vote.StartOption;
                description = voteOption.Description;
                command     = voteOption.Command;
            }
            else if (message.VoteType == "kick")
            {
                voteType    = Vote.StartKick;
                description = string.Empty;
                command     = string.Empty;
            }
            else if (message.VoteType == "spectate")
            {
                voteType    = Vote.StartSpectator;
                description = string.Empty;
                command     = string.Empty;
            }
            else
            {
                return; // unknown type
            }

            if (message.Force)
            {
            }
            else
            {
                PlayersVoteInfo[player.ClientId].Vote         = 1;
                PlayersVoteInfo[player.ClientId].LastVoteCall = Server.Tick;

                StartVote(new ActiveVote
                {
                    CallerId    = player.ClientId,
                    Description = description,
                    Type        = voteType,
                    Reason      = reason,
                    CloseTick   = Server.Tick + Server.TickSpeed * 25,
                    Command     = command
                });
            }
        }