public static bool Prefix(CheaterReport __instance, GameConsoleTransmission reporter, string reporterSteamId,
                                  string reportedSteamId, string reportedAuth, string reportedIp, string reporterAuth, string reporterIp,
                                  ref string reason, ref byte[] signature, string reporterPublicKey, int reportedId)
        {
            if (EventPlugin.CheaterReportPatchDisable)
            {
                return(true);
            }

            try
            {
                if (reportedSteamId == reporterSteamId)
                {
                    reporter.SendToClient(__instance.connectionToClient,
                                          "You can't report yourself!" + Environment.NewLine, "yellow");
                }

                int  serverId = ServerConsole.Port;
                bool allow    = true;
                Events.InvokeCheaterReport(reporterSteamId, reportedSteamId, reportedIp, reason, serverId, ref allow);

                return(allow);
            }
            catch (Exception e)
            {
                Log.Error($"Cheater Report Patch error: {e}");
                return(true);
            }
        }
Beispiel #2
0
        // Calling the method with bool is easier
        // It contains the code that processes the event
        private static bool InvokeLocalReport(CheaterReport reporter, GameObject reportedTo, ref string reason)
        {
            var issuer = API.Features.Player.Get(reporter.gameObject);
            var target = API.Features.Player.Get(reportedTo);

            var ev = new LocalReportingEventArgs(issuer, target, reason);

            Server.OnLocalReporting(ev);

            reason = ev.Reason;

            // If further processing isn't allowed
            // then send the success of sending the report
            // --------------------------------------------------
            // gameObjects is compared cuz there is no comparison overload for Player,
            // it can be different objects
            if (!ev.IsAllowed && reporter.gameObject != reportedTo.gameObject)
            {
                reporter.GetComponent <GameConsoleTransmission>().SendToClient(
                    reporter.connectionToClient,
                    "[Reporting] Player report successfully sent to local administrators.",
                    "green");
            }

            return(ev.IsAllowed);
        }
Beispiel #3
0
        static bool Prefix(
            ref bool __state,
            string reporterUserId,
            string reportedUserId,
            string reason,
            ref int reportedId,
            string reporterNickname,
            string reportedNickname,
            bool friendlyFire)
        {
            try
            {
                string pings = "";

                foreach (string s in ReportPing.Instance.Config.RoleId)
                {
                    pings += $"<@&{s}> ";
                }

                pings = Uri.EscapeDataString(pings);

                string payload = JsonSerializer.ToJsonString <DiscordWebhook>(new DiscordWebhook(
                                                                                  pings, CheaterReport.WebhookUsername,
                                                                                  CheaterReport.WebhookAvatar, false, new DiscordEmbed[1]
                {
                    new DiscordEmbed(CheaterReport.ReportHeader, "rich", CheaterReport.ReportContent,
                                     CheaterReport.WebhookColor, new DiscordEmbedField[10]
                    {
                        new DiscordEmbedField("Server Name", CheaterReport.ServerName, false),
                        new DiscordEmbedField("Server Endpoint", string.Format("{0}:{1}", (object)ServerConsole.Ip, (object)ServerConsole.Port), false),
                        new DiscordEmbedField("Reporter UserID", CheaterReport.AsDiscordCode(reporterUserId), false),
                        new DiscordEmbedField("Reporter Nickname", CheaterReport.DiscordSanitize(reporterNickname), false),
                        new DiscordEmbedField("Reported UserID", CheaterReport.AsDiscordCode(reportedUserId), false),
                        new DiscordEmbedField("Reported Nickname", CheaterReport.DiscordSanitize(reportedNickname), false),
                        new DiscordEmbedField("Reported ID", reportedId.ToString(), false),
                        new DiscordEmbedField("Reason", CheaterReport.DiscordSanitize(reason), false),
                        new DiscordEmbedField("Timestamp", TimeBehaviour.Rfc3339Time(), false),
                        new DiscordEmbedField("UTC Timestamp", TimeBehaviour.Rfc3339Time(DateTimeOffset.UtcNow), false)
                    })
                }));
                HttpQuery.Post(friendlyFire ? FriendlyFireConfig.WebhookUrl : CheaterReport.WebhookUrl, "payload_json=" + payload);
                __state = true;
            }
            catch (Exception ex)
            {
                ServerConsole.AddLog("Failed to send report by webhook: " + ex.Message, ConsoleColor.Gray);
                Debug.LogException(ex);
                __state = false;
            }

            return(false);
        }
Beispiel #4
0
        public static bool Prefix(CheaterReport __instance, int playerId, string reason)
        {
            ReferenceHub reported = Player.GetPlayer(playerId);
            ReferenceHub reporter = Player.GetPlayer(__instance.gameObject);

            Log.Debug($"[ReportPatch] Reported:{reported.GetNickname()} Reason:{reason} Reporter:{reporter.GetNickname()}");

            if (!string.IsNullOrEmpty(Configs.report_webhook) &&
                !string.IsNullOrEmpty(reporter.GetUserId()) &&
                !string.IsNullOrEmpty(reported.GetUserId()) &&
                reported.GetPlayerId() != reporter.GetPlayerId())
            {
                Methods.SendReport(reported, reason, reporter);
                __instance.GetComponent <GameConsoleTransmission>().SendToClient(__instance.connectionToClient, "Player report successfully sent.", "green");
                return(false);
            }

            return(true);
        }
Beispiel #5
0
        private static bool Prefix(
            CheaterReport __instance,
            GameConsoleTransmission reporter,
            string reporterUserId,
            string reportedUserId,
            ref string reason)
        {
            if (reportedUserId == reporterUserId)
            {
                reporter.SendToClient(__instance.connectionToClient, "You can't report yourself!" + Environment.NewLine, "yellow");
            }

            var ev = new ReportingCheaterEventArgs(API.Features.Player.Get(reporterUserId), API.Features.Player.Get(reportedUserId), ServerConsole.Port, reason);

            Server.OnReportingCheater(ev);

            reason = ev.Reason;

            return(ev.IsAllowed);
        }
        private static bool Prefix(CheaterReport __instance, int playerId, string reason, ref bool notifyGm)
        {
            try
            {
                var player = __instance.GetPlayer();
                var target = Server.Get.GetPlayer(playerId);
                if (target == null)
                {
                    return(false);
                }
                Server.Get.Events.Player.InvokePlayerReport(player, target, reason, ref notifyGm, out var allow);

                return(allow);
            }
            catch (Exception e)
            {
                SynapseController.Server.Logger.Error($"Synapse-Event: PlayerReport failed!!\n{e}\nStackTrace:\n{e.StackTrace}");
                return(true);
            }
        }