Ejemplo n.º 1
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);
     }
 }
Ejemplo n.º 2
0
        public static void Run(string fileName)
        {
            try
            {
                IdListObject idlist;
                switch (fileName)
                {
                case SettingsFile:
                    var m = JsonConvert.DeserializeObject <__RootObject>(FilterComments.Run(SettingsFile));


                    LocalVersion             = m.General.Version;
                    CmdCommandCharacter      = m.General.CommandCharacter;
                    DownloadIdList           = m.General.DownloadIDList;
                    TimestampFormat          = m.General.TimestapFormat;
                    MsgSayColor              = m.General.MsgSayColor;
                    MsgUnknownCommand        = m.General.DisplayUnknownCommandMessage;
                    VoteKickDisabled         = m.General.VoteKickDisabled;
                    ShowDMGMessage           = m.General.ShowDMGMessage;
                    DebugLevel               = m.General.DebugLevel;
                    EnableDiscordWebhook_Ban = m.General.EnableDiscordWebhook_Ban;
                    if (EnableDiscordWebhook_Ban && string.IsNullOrEmpty(m.General.DiscordWebhook_Ban.Trim()))
                    {
                        Debug.Log("[ERROR] Discord webhook_Ban is empty but EnableDiscordWebhook_Ban is true! Disabling webhook_Ban.");
                        EnableDiscordWebhook_Ban = false;
                    }
                    else
                    {
                        DiscordWebhook_Ban = m.General.DiscordWebhook_Ban;
                    }
                    EnableDiscordWebhook_Report = m.General.EnableDiscordWebhook_Report;
                    if (EnableDiscordWebhook_Report && string.IsNullOrEmpty(m.General.DiscordWebhook_Report.Trim()))
                    {
                        Debug.Log("[ERROR] Discord webhook_Report is empty but EnableDiscordWebhook_Report is true! Disabling webhook_Report.");
                        EnableDiscordWebhook_Report = false;
                    }
                    else
                    {
                        DiscordWebhook_Report = m.General.DiscordWebhook_Report;
                    }
                    BlockBanButtonTabMenu    = m.General.BlockBanButtonTabMenu;
                    blockLicenseRemoved      = m.General.BlockLicenseRemoved;
                    MessagesAllowedPerSecond = m.General.MessagesAllowedPerSecond;
                    TimeBetweenDelay         = m.General.TimeBetweenDelay;
                    WipePassword             = m.General.WipePassword;

                    infoColor    = m.MessageColors.Info;
                    errorColor   = m.MessageColors.Error;
                    warningColor = m.MessageColors.Warning;
                    argColor     = m.MessageColors.Arg;

                    MsgNoPerm            = m.Messages.NoPerm;
                    MsgDiscord           = m.Messages.DiscordLink;
                    MsgSayPrefix         = m.Messages.MsgSayPrefix;
                    DisabledCommand      = $"<color={errorColor}>{m.Messages.DisabledCommand}</color>";
                    PlayerIsAFK          = $"<color={warningColor}>{m.Messages.PlayerIsAFK}</color>";
                    SelfIsMuted          = $"<color={errorColor}>{m.Messages.SelfIsMuted}</color>";
                    ArgRequired          = $"<color={errorColor}>{m.Messages.ArgRequired}</color>";
                    NotFoundOnline       = $"<color={errorColor}>{m.Messages.NotFoundOnline}</color>";
                    NotFoundOnlineIdOnly = $"<color={errorColor}>{m.Messages.NotFoundOnlineIdOnly}</color>";
                    AdminSearchingInv    = $"<color={errorColor}>{m.Messages.AdminSearchingInv}</color>";
                    PlayerMessage        = m.Messages.PlayerMessage;
                    AdminMessage         = m.Messages.AdminMessage;
                    AdminChatMessage     = m.Messages.AdminChatMessage;
                    MsgNoPermJob         = $"<color={errorColor}>{m.Messages.MsgNoPermJob}</color>";
                    BlockedItemMessage   = $"<color={errorColor}>{m.Messages.BlockedItem}</color>";
                    MsgNoWantedAllowed   = $"<color={errorColor}>{m.Messages.MsgNoWantedAllowed}</color>";
                    MsgNoCuffedAllowed   = $"<color={errorColor}>{m.Messages.MsgNoCuffedAllowed}</color>";
                    MsgNoJailAllowed     = $"<color={errorColor}>{m.Messages.MsgNoJailAllowed}</color>";
                    MeMessage            = m.Messages.MeMessage;

                    AccessMoneyMenu    = m.FunctionUI.AccessMoneyMenu;
                    AccessItemMenu     = m.FunctionUI.AccessItemMenu;
                    AccessSetHPMenu    = m.FunctionUI.AccessSetHPMenu;
                    AccessSetStatsMenu = m.FunctionUI.AccessSetStatsMenu;
                    AccessCWMenu       = m.FunctionUI.AccessCWMenu;

                    ReportReasons = new string[] { m.ReportOptions.F2, m.ReportOptions.F3, m.ReportOptions.F4, m.ReportOptions.F5, m.ReportOptions.F6, m.ReportOptions.F7, m.ReportOptions.F8, m.ReportOptions.F9, m.ReportOptions.F10 };

                    // Softcode this someday
                    Jobs = new string[] { m.JobIndexArray.Citizen, m.JobIndexArray.Criminal, m.JobIndexArray.Prisoner, m.JobIndexArray.Police, m.JobIndexArray.Paramedic, m.JobIndexArray.Firefighter, m.JobIndexArray.Rojo_Loco, m.JobIndexArray.Green_St_Fam, m.JobIndexArray.Borgata_Blue, m.JobIndexArray.Mayor, m.JobIndexArray.DeliveryDriver, m.JobIndexArray.TaxiDriver, m.JobIndexArray.SpecOps };

                    BlockedItems = m.BlockedItems;

                    EnableBlockSpawnBot          = m.Misc.EnableBlockSpawnBot;
                    LanguageBlock                = m.Misc.EnableLanguageBlock;
                    ChatBlock                    = m.Misc.EnableChatBlock;
                    CheckBannedEnabled           = m.Misc.CheckBannedEnabled;
                    TimeBetweenAnnounce          = m.Misc.TimeBetweenAnnounce;
                    Variables.Announcer.Interval = TimeBetweenAnnounce;
                    TimescaleDisabled            = m.Misc.TimescaleDisabled;

                    if (m.Misc.EnableBlockSpawnBot)
                    {
                        BlockedSpawnIds = m.Misc.BlockSpawnBot.Split(',').Select(int.Parse).ToArray();
                    }
                    GodModeLevel    = m.Misc.GodModeLevel;
                    ShowJailMessage = m.Misc.ShowJailMessage;
                    BlockSuicide    = m.Misc.BlockSuicide;
                    BlockMissions   = m.Misc.BlockMissions;
                    ProximityChat   = m.Misc.ProximityChat;
                    LocalChatMute   = m.Misc.LocalChatMute;
                    LocalChatMe     = m.Misc.LocalChatMe;

                    foreach (var currJob in m.WhitelistedJobs)
                    {
                        if (WhitelistedJobs.ContainsKey(currJob.JobIndex))
                        {
                            Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [WARNING] WhitelistedJobs already contains a item with the key '{currJob.JobIndex}'! (Did you make two objects with the same JobIndex?)");
                            continue;
                        }
                        WhitelistedJobs.Add(currJob.JobIndex, currJob.Whitelisted);
                    }
                    RegisterCommands.Run(m.Commands);
                    break;

                case IdListItemsFile:
                    idlist    = JsonConvert.DeserializeObject <IdListObject>(FilterComments.Run(IdListItemsFile));
                    IDs_Items = idlist.items.Select(x => x.gameid).ToArray();
                    break;

                case IdListVehicleFile:
                    idlist       = JsonConvert.DeserializeObject <IdListObject>(FilterComments.Run(IdListVehicleFile));
                    IDs_Vehicles = idlist.items.Select(x => x.gameid).ToArray();
                    break;

                case AnnouncementsFile:
                    Variables.Announcer.Announcements = File.ReadAllLines(fileName).ToList();
                    break;

                case RulesFile:
                    Rules = File.ReadAllText(fileName);
                    break;

                case GodListFile:
                    GodListPlayers = File.ReadAllLines(fileName).ToList();
                    break;

                case AfkListFile:
                    AfkPlayers = File.ReadAllLines(fileName).ToList();
                    break;

                case MuteListFile:
                    MutePlayers = File.ReadAllLines(fileName).ToList();
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                ErrorLogging.Run(ex);
            }
        }