public static void Run(string message)
 {
     foreach (var player in PlayerList.Where(x => x.Value.ReceiveStaffChat && HasPermission.Run(x.Value.ShPlayer.svPlayer, CmdStaffChatExecutableBy)))
     {
         player.Value.ShPlayer.svPlayer.SendChatMessage(message);
     }
 }
예제 #2
0
        public static bool OnCommand(SvPlayer player, ref string message)
        {
            var tempMessage = message;
            var command     = GetArgument.Run(0, false, false, message);
            // CustomCommands
            var customCommand = CustomCommands.FirstOrDefault(x => tempMessage.StartsWith(CmdCommandCharacter + x.Command, StringComparison.CurrentCulture));

            if (customCommand != null)
            {
                foreach (string line in customCommand.Response.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None))
                {
                    player.SendChatMessage(PlaceholderParser.ParseUserMessage(player.player, line, message));
                }
                PlayerList.Where(x => x.Value.SpyEnabled && x.Value.ShPlayer.svPlayer != player).ToList().ForEach(x => x.Value.ShPlayer.svPlayer.SendChatMessage($"<color=#f4c242>[SPYCHAT]</color> {player.playerData.username}: {tempMessage}"));
                return(true);
            }
            // Go through all registered commands and check if the command that the user entered matches
            foreach (var cmd in CommandList.Values)
            {
                if (cmd.commandCmds.Contains(command))
                {
                    if (cmd.commandDisabled)
                    {
                        player.SendChatMessage(DisabledCommand);
                        return(true);
                    }
                    if (HasPermission.Run(player, cmd.commandGroup, true, player.player.job.jobIndex) &&
                        HasWantedLevel.Run(player, cmd.commandWantedAllowed) &&
                        IsCuffed.Run(player, cmd.commandHandcuffedAllowed) &&
                        IsJailed.Run(player, cmd.commandWhileJailedAllowed))
                    {
                        PlayerList.Where(x => x.Value.SpyEnabled && x.Value.ShPlayer.svPlayer != player).ToList().ForEach(x => x.Value.ShPlayer.svPlayer.SendChatMessage($"<color=#f4c242>[SPYCHAT]</color> {player.playerData.username}: {tempMessage}"));
                        cmd.RunMethod.Invoke(player, message);
                    }
                    return(true);
                }
            }
            if (AfkPlayers.Contains(player.playerData.username))
            {
                Commands.Afk.Run(player, message);
            }
            if (MsgUnknownCommand)
            {
                player.SendChatMessage($"<color={errorColor}>Unknown command. Type</color><color={argColor}> {CmdCommandCharacter}essentials cmds </color><color={errorColor}>for more info.</color>");
                return(true);
            }
            return(false);
        }
예제 #3
0
 public static bool SvGetJob(SvPlayer player, ref int employerID)
 {
     try
     {
         var shPlayer   = player.player;
         var shEmployer = shPlayer.manager.FindByID <ShPlayer>(employerID);
         if (!WhitelistedJobs.ContainsKey(shEmployer.job.jobIndex))
         {
             return(false);
         }
         if (HasPermission.Run(player, WhitelistedJobs[shEmployer.job.jobIndex], false, shPlayer.job.jobIndex))
         {
             return(false);
         }
         player.SendChatMessage(MsgNoPermJob);
         return(true);
     }
     catch (Exception ex)
     {
         ErrorLogging.Run(ex);
         return(false);
     }
 }