Esempio n. 1
0
        public void Command(Edict pEntity, ICommand command)
        {
            // Is the client spawned yet?
            var player = pEntity.TryGetEntity <BasePlayer>();

            if (player == null)
            {
                return;
            }

            var commandName = command.Name;

            //TODO: implement commands

            if (commandName == PlayerUtils.SayCommandName)
            {
                PlayerUtils.HostSay(player, command, false);
            }
            else if (commandName == PlayerUtils.SayTeamCommandName)
            {
                PlayerUtils.HostSay(player, command, true);
            }
            else if (commandName == "closemenus")
            {
                // just ignore it
            }
            else if (Engine.GameRules.ClientCommand(player, command))
            {
                // MenuSelect returns true only if the command is properly handled,  so don't print a warning
            }
            else
            {
                // check the length of the command (prevents crash)
                // max total length is 192 ...and we're adding a string below ("Unknown command: %s\n")
                var printableName = commandName.Length > 127 ? commandName.Substring(0, 127) : commandName;

                // tell the user they entered an unknown command
                PlayerUtils.ClientPrint(player, HudPrint.Console, $"Unknown command: {printableName}\n");
            }
        }