Ejemplo n.º 1
0
        public void OnDamageBarricade(CSteamID steamid, Transform barricade, ref ushort num2, ref bool barricadebool,
                                      EDamageOrigin damageorigin)
        {
            //Logdamage(steamid, barricade,num2);
            byte            x;
            byte            y;
            ushort          num;
            ushort          index;
            BarricadeRegion barricadeRegion;
            string          hq;

            hq = " ";
            UnturnedPlayer player;
            CSteamID       steam64;
            ushort         itemid;
            float          bx;
            float          by;
            float          bz;
            ulong          owner;
            string         url;
            string         barricadename;

            //initialize variables in case exception happens which it will and data is missing.
            bx                = 0;
            by                = 0;
            bz                = 0;
            url               = "";
            itemid            = 0;
            owner             = 0;
            player            = null;
            steam64.m_SteamID = 0;
            barricadename     = " Unknown";


            try


            {
                BarricadeManager.tryGetInfo(barricade, out x, out y, out num, out index, out barricadeRegion);
                BarricadeData barricadetargeted = barricadeRegion.barricades[index];
                //if (barricadetargeted.barricade.health < num2)
                //{
                //Rocket.Core.Logging.Logger.Log("Sqr Distance to Axis HQ: " + (barricadetargeted.point - axishq).sqrMagnitude);
                //Rocket.Core.Logging.Logger.Log("Sqr Distance to Allies HQ: "+ (barricadetargeted.point - allieshq).sqrMagnitude);

                /*if (((barricadetargeted.point - axishq).sqrMagnitude <= 3600) ||
                 *  ((barricadetargeted.point - allieshq).sqrMagnitude <= 3600))
                 */
                Vector2 barricadevector2;
                barricadevector2.x = barricadetargeted.point.x;
                barricadevector2.y = barricadetargeted.point.z;
                if (((barricadevector2 - axishq).magnitude <= 500) || (barricadevector2 - allieshq).magnitude <= 500)
                {
                    if ((barricadevector2 - axishq).magnitude <= 500)
                    {
                        hq = " Axis ";
                    }
                    else if ((barricadevector2 - allieshq).magnitude <= 500)
                    {
                        hq = " Allies ";
                    }

                    Rocket.Core.Logging.Logger.Log("Barricade damaged in HQ: " + hq);

                    if (steamid.m_SteamID != 0)
                    {
                        player = UnturnedPlayer.FromCSteamID(steamid);
                    }
                    else
                    {
                        player = null;
                    }

                    //  Rocket.Core.Logging.Logger.Log("destroying player found");
                    steam64 = steamid;
                    //  itemid = barricadetargeted.barricade.id;
                    Rocket.Core.Logging.Logger.Log("Barricade ID found");
                    ItemAsset itemAsset = (from i in new List <ItemAsset>(Assets.find(EAssetType.ITEM).Cast <ItemAsset>())
                                           where i.itemName != null
                                           orderby i.itemName.Length
                                           where i.id == itemid
                                           select i).FirstOrDefault <ItemAsset>();
                    //stole this from rockets /i command
                    barricadename = itemAsset.itemName;
                    //     Rocket.Core.Logging.Logger.Log("barricade name found");


                    bx = barricadetargeted.point.x;
                    by = barricadetargeted.point.y;
                    bz = barricadetargeted.point.z;
                    //  Rocket.Core.Logging.Logger.Log("barricade location found");

                    //and then send to discord webhook


                    owner = barricadetargeted.owner;
                    //   Rocket.Core.Logging.Logger.Log("barricade owner found");

                    if (player != null)
                    {
                        url = player.SteamProfile.AvatarFull.ToString();
                        //Rocket.Core.Logging.Logger.Log("steam profile avatar found");
                    }
                    else
                    {
                        url = "https://upload.wikimedia.org/wikipedia/commons/thumb/4/46/Question_mark_%28black%29.svg/200px-Question_mark_%28black%29.svg.png";
                        // Rocket.Core.Logging.Logger.Log("no player - url not done");
                    }



                    Discord.SendWebhookPost(Configuration.Instance.raidalertchannel,
                                            Discord.BuildDiscordEmbed("A barricade was damaged in" + hq + "HQ",
                                                                      "This barricade was damagedat " + DateTime.Now,
                                                                      player.DisplayName, url, 16711680, new object[]
                    {
                        Discord.BuildDiscordField("Destroyer steam64", steam64.ToString(), true),
                        Discord.BuildDiscordField("Barricade ID", itemid.ToString(), true),
                        Discord.BuildDiscordField("Barricade Name", barricadename, true),
                        Discord.BuildDiscordField("Barricade Position", "X: " + bx + " Y: " + by + " Z: " + bz,
                                                  true),
                        Discord.BuildDiscordField("Owner of this barricade", owner.ToString(),
                                                  true),
                    }));
                }
            }
            catch (Exception e)
            {
                //uh oh! a barriacde has requested to break but hasn't broken!! Likely due to advanced regions nodestroy flag!!
                var error = e;
                Rocket.Core.Logging.Logger.Log("Exception caught: " + e);
                bool found = false;
                foreach (var spawner in miscstuff.Instance.Configuration.Instance.listofignoredexploitbarricades)
                {
                    if (itemid == spawner)
                    {
                        found = true;
                    }
                }

                if (found == false)
                {
                    Discord.SendWebhookPost("https://ptb.discord.com/api/webhooks/807221467204550666/yte_hGdNflFqCtW80uhnNR1O9a0uX8GNoz5xGdur9xfLjUvRhs2sIctPypJocXdSVHRU",
                                            Discord.BuildDiscordEmbed("Possible Exploit of infinite crops detected at" + hq + "HQ",
                                                                      "Possible exploit detected at: " + DateTime.Now,
                                                                      "Unknown Player", "https://upload.wikimedia.org/wikipedia/commons/thumb/4/46/Question_mark_%28black%29.svg/200px-Question_mark_%28black%29.svg.png", 16711680, new object[]
                    {
                        Discord.BuildDiscordField("Crop ID", itemid.ToString(), true),
                        Discord.BuildDiscordField("Crop Name", barricadename, true),
                        Discord.BuildDiscordField("Crop Position", "X: " + bx + " Y: " + by + " Z: " + bz,
                                                  true),
                        Discord.BuildDiscordField("Owner of this plant:", owner.ToString(),
                                                  true),
                    }));
                }
            }
        }
Ejemplo n.º 2
0
        public void OnDamageStructure(CSteamID steamid, Transform structure, ref ushort num, ref bool barricadebool,
                                      EDamageOrigin damageorigin)
        {
            byte            x;
            byte            y;
            ushort          index;
            StructureRegion structureRegion;
            string          hq;

            hq = " ";


            StructureManager.tryGetInfo(structure, out x, out y, out index, out structureRegion);
            StructureData structuretargeted = structureRegion.structures[index];
            // if (structuretargeted.structure.health < num)
            // {
            //if (((structuretargeted.point -axishq).sqrMagnitude <= 3600) || ((structuretargeted.point - allieshq).sqrMagnitude <= 3600))
            Vector2 structurevector2;

            structurevector2.x = structuretargeted.point.x;
            structurevector2.y = structuretargeted.point.z;
            if (((structurevector2 - axishq).magnitude <= 600) || (structurevector2 - allieshq).magnitude <= 600)
            {
                if ((structurevector2 - axishq).magnitude <= 600)
                {
                    hq = " Axis ";
                }
                else if ((structurevector2 - allieshq).magnitude <= 600)
                {
                    hq = " Allies ";
                }
                Rocket.Core.Logging.Logger.Log("Structure destroyed in HQ");
                var       player    = UnturnedPlayer.FromCSteamID(steamid);
                var       steam64   = steamid;
                var       itemid    = structuretargeted.structure.id;
                ItemAsset itemAsset = (from i in new List <ItemAsset>(Assets.find(EAssetType.ITEM).Cast <ItemAsset>())
                                       where i.itemName != null
                                       orderby i.itemName.Length
                                       where i.id == itemid
                                       select i).FirstOrDefault <ItemAsset>();
                //stole this from rockets /i command
                var barricadename = itemAsset.itemName;
                var url           = player.SteamProfile.AvatarFull.ToString();
                var bx            = structuretargeted.point.x;
                var by            = structuretargeted.point.y;
                var bz            = structuretargeted.point.z;
                //and then send to discord webhook


                var owner = structuretargeted.owner;


                Discord.SendWebhookPost(Configuration.Instance.raidalertchannel,
                                        Discord.BuildDiscordEmbed("A structure was damaged in" + hq + "HQ",
                                                                  "This structure was damaged at " + DateTime.Now,
                                                                  player.DisplayName, url, 65327, new object[]
                {
                    Discord.BuildDiscordField("Destroyer steam64", steam64.ToString(), true),
                    Discord.BuildDiscordField("Structure ID", itemid.ToString(), true),
                    Discord.BuildDiscordField("Structure Name", barricadename, true),
                    Discord.BuildDiscordField("Structure Position", "X: " + bx + " Y: " + by + " Z: " + bz,
                                              true),
                    Discord.BuildDiscordField("Owner of this structure", owner.ToString(),
                                              true),
                }));
            }

            //}
        }