示例#1
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);
        }
示例#2
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);
        }