コード例 #1
0
 public void OnLootUse(LootStartEvent le)
 {
     this.Invoke("On_LootUse", new object[] { le });
 }
コード例 #2
0
 public void OnLootUse(LootStartEvent le)
 {
     Invoke("On_LootUse", le);
 }
コード例 #3
0
        public static void OnLootUse(LootStartEvent lootstartevent)
        {
            if (lootstartevent.Player == null)
            {
                return;
            }
            if (!lootstartevent.IsObject || DataStore.GetInstance().ContainsKey("LegitRaidA", lootstartevent.Player.UID) ||
                DataStore.GetInstance().ContainsKey("HGIG", lootstartevent.Player.SteamID))
            {
                Logger.LogError("Incumple 1");
                return;
            }
            if (DSNames.Any(table => DataStore.GetInstance().ContainsKey(table, lootstartevent.Player.SteamID) ||
                            DataStore.GetInstance().ContainsKey(table, lootstartevent.Player.UID)))
            {
                Logger.LogError("Incumple 2");
                return;
            }
            if (!lootstartevent.Entity.IsStorage())
            {
                Logger.LogError("Incumple 3");
                return;
            }
            ulong owneruid = GetHouseOwner(lootstartevent.Entity.Location);

            if (owneruid == 0UL)
            {
                Logger.LogError("No se encuentra al dueño");
                return;
            }
            if (owneruid == lootstartevent.Player.UID)
            {
                Logger.LogError("Cumple 4");
                return;
            }
            if (CanOpenChestIfThereIsNoStructureClose)
            {
                Logger.LogError("Esta abierta");
                var objects = Physics.OverlapSphere(lootstartevent.Entity.Location, 3.8f);
                var names   = new List <string>();
                foreach (var x in objects.Where(x => !names.Contains(x.name.ToLower())))
                {
                    names.Add(x.name.ToLower());
                }
                string ncollected = string.Join(" ", names.ToArray());
                if (ncollected.Contains("shelter") && !ncollected.Contains("door"))
                {
                    return;
                }
                if (!ncollected.Contains("meshbatch"))
                {
                    return;
                }
            }
            StructureMaster structureMaster = GetStructureMaster(lootstartevent.Entity.Location);

            Logger.LogError($"SM: InstanceID: {structureMaster.GetInstanceID()}");
            ulong id = GetHouseOwner(lootstartevent.Entity.Location);

            RustPP.Data.Entities.User owner  = RustPP.Data.Globals.GetUserBySteamID(lootstartevent.Entity.OwnerName);
            RustPP.Data.Entities.User player = RustPP.Data.Globals.GetUserBySteamID(lootstartevent.Player.SteamID);

            if (owner.ID == player.ID)
            {
                return;
            }

            if (FriendComponent.FriendComponent.IsFriendOf(owner, player))
            {
                Logger.LogError("Es amigo");
                return;
            }

            if (OwnerTimeData.ContainsKey(id))
            {
                Logger.LogError("Cumple 5");
                var ticks    = OwnerTimeData[id];
                var calc     = TimeSpan.FromTicks(DateTime.Now.Ticks).TotalSeconds - ticks;
                int timeraid = RaidTime;
                if (RaiderTime.ContainsKey(id))
                {
                    timeraid = RaiderTime[id];
                }
                if (double.IsNaN(calc) || double.IsNaN(ticks))
                {
                    lootstartevent.Cancel();
                    lootstartevent.Player.Notice("", "Necesitas romper una pared con C4/Granadas en una pared y podrás raidear por " + RaidTime + " minutos!", 8f);
                    lootstartevent.Player.MessageFrom("LegitRaid", "[color cyan]<!>[/color] Si intentas abrir el cofre de un amigo el deberá usar /addfriend para darte permiso.");
                    //lootstartevent.Player.MessageFrom("LegitRaid", "After that tell him to type /friendraid !");
                    OwnerTimeData.Remove(id);
                    if (RaiderTime.ContainsKey(id))
                    {
                        RaiderTime.Remove(id);
                    }
                }
                if (calc >= (RaidTime + timeraid) * 60)
                {
                    lootstartevent.Cancel();
                    lootstartevent.Player.Notice("", "Necesitas romper una pared con C4/Granadas en una pared y podrás raidear por " + RaidTime + " minutos!", 8f);
                    lootstartevent.Player.MessageFrom("LegitRaid", "[color cyan]<!>[/color] Si intentas abrir el cofre de un amigo el deberá usar /addfriend para darte permiso.");
                    OwnerTimeData.Remove(id);
                    if (RaiderTime.ContainsKey(id))
                    {
                        RaiderTime.Remove(id);
                    }
                }
                else
                {
                    Logger.LogError("Cumple 5");
                    var done = Math.Round(calc);
                    lootstartevent.Player.Notice("¡Puedes lootear por " + ((timeraid * 60) - done) + " segundos!");
                }
                return;
            }
            else
            {
                Logger.LogError("incumple 6");
                if (DataStore.GetInstance().Get("LegitRaidED", id) != null)
                {
                    List <string> list = (List <string>)DataStore.GetInstance().Get("LegitRaidED", id);
                    if (list.Contains(id.ToString()) && OwnerTimeData.ContainsKey(id))
                    {
                        var ticks    = OwnerTimeData[id];
                        var calc     = TimeSpan.FromTicks(DateTime.Now.Ticks).TotalSeconds - ticks;
                        int timeraid = RaidTime;
                        if (RaiderTime.ContainsKey(id))
                        {
                            timeraid = RaiderTime[id];
                        }
                        if (double.IsNaN(calc) || double.IsNaN(ticks))
                        {
                            lootstartevent.Cancel();
                            lootstartevent.Player.Notice("", "Necesitas romper una pared con C4/Granadas en una pared y podrás raidear por " + RaidTime + " minutos!", 8f);
                            lootstartevent.Player.MessageFrom("LegitRaid", "[color cyan]<!>[/color] Si intentas abrir el cofre de un amigo el deberá usar /addfriend para darte permiso.");
                            OwnerTimeData.Remove(id);
                            if (RaiderTime.ContainsKey(id))
                            {
                                RaiderTime.Remove(id);
                            }
                        }
                        if (calc >= (RaidTime + timeraid) * 60)
                        {
                            lootstartevent.Cancel();
                            lootstartevent.Player.Notice("", "Necesitas romper una pared con C4/Granadas en una pared y podrás raidear por " + RaidTime + " minutos!", 8f);
                            lootstartevent.Player.MessageFrom("LegitRaid", "[color cyan]<!>[/color] Si intentas abrir el cofre de un amigo el deberá usar /addfriend para darte permiso.");
                            OwnerTimeData.Remove(id);
                            if (RaiderTime.ContainsKey(id))
                            {
                                RaiderTime.Remove(id);
                            }
                        }
                        else
                        {
                            var done = Math.Round(calc);
                            lootstartevent.Player.Notice("¡Puedes lootear por " + ((timeraid * 60) - done) + " segundos!");
                        }
                        return;
                    }
                }
                lootstartevent.Cancel();
                lootstartevent.Player.Notice("", "Necesitas romper una pared con C4/Granadas en una pared y podrás raidear por " + RaidTime + " minutos!", 8f);
                lootstartevent.Player.MessageFrom("LegitRaid", "[color cyan]<!>[/color] Si intentas abrir el cofre de un amigo el deberá usar /addfriend para darte permiso.");
            }
        }
コード例 #4
0
        public void OnLootUse(LootStartEvent le)
        {
            if (!le.IsObject)
            {
                return;
            }
            var player = (Fougerite.Player)le.Player;

            //if (le.Entity.Inventory.SlotCount == 36) //WoodBoxLarge tiene 36 slots
            if (le.Entity.Name == "WoodBoxLarge")
            {
                if (IsShop(le.Entity.Location))
                {
                    //Borrar mochilas alrededor
                    try
                    {
                        var objects = Physics.OverlapSphere(le.Entity.Location, 3f);
                        foreach (var x in objects)
                        {
                            if (x.name == "LootSack(Clone)")
                            {
                                Util.GetUtil().DestroyObject(x.gameObject);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.Log(Name + " ERROR A: " + ex.ToString());
                    }


                    ////

                    try
                    {
                        if (!PlayersInShop.Contains(player))
                        {
                            PlayersInShop.Add(player);
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.Log(Name + " ERROR B: " + ex.ToString());
                        PlayersInShop.Add(player);
                    }
                    player.Notice("", "Welcome to the Shop!", 5f);

                    string mensajealcliente = "MensajeDeLaTienda-";
                    foreach (var line in File.ReadAllLines(PricesFile))
                    {
                        if (line == "")
                        {
                            continue;
                        }
                        mensajealcliente += "\n" + line;
                    }
                    player.SendConsoleMessage(mensajealcliente);
                }
                else
                {
                    try
                    {
                        PlayersInShop.RemoveAll(t => PlayersInShop.Contains(player));
                        //PlayersInShop.Remove(player);
                    }
                    catch (Exception ex)
                    {
                        Logger.Log(Name + " ERROR C: " + ex.ToString());
                    }
                }
            }
        }
コード例 #5
0
        public void OnLootUse(LootStartEvent lootstartevent)
        {
            if (lootstartevent.Player == null)
            {
                return;
            }

            if (!lootstartevent.IsObject || DataStore.GetInstance().ContainsKey("LegitRaidA", lootstartevent.Player.UID) ||
                DataStore.GetInstance().ContainsKey("HGIG", lootstartevent.Player.SteamID))
            {
                return;
            }

            if (DSNames.Any(table => DataStore.GetInstance().ContainsKey(table, lootstartevent.Player.SteamID) ||
                            DataStore.GetInstance().ContainsKey(table, lootstartevent.Player.UID)))
            {
                return;
            }

            if (lootstartevent.Entity.UOwnerID == lootstartevent.Player.UID)
            {
                return;
            }

            if (CanOpenChestIfThereIsNoStructureClose)
            {
                var objects = Physics.OverlapSphere(lootstartevent.Entity.Location, 3.8f);
                var names   = new List <string>();
                foreach (var x in objects.Where(x => !names.Contains(x.name.ToLower())))
                {
                    names.Add(x.name.ToLower());
                }

                string ncollected = string.Join(" ", names.ToArray());
                if (ncollected.Contains("shelter") && !ncollected.Contains("door"))
                {
                    return;
                }

                if (!ncollected.Contains("meshbatch"))
                {
                    return;
                }
            }

            if (RustPP)
            {
                var friendc = Fougerite.Server.GetServer().GetRustPPAPI().GetFriendsCommand.GetFriendsLists();
                if (friendc.ContainsKey(lootstartevent.Entity.UOwnerID))
                {
                    var  fs       = (RustPP.Social.FriendList)friendc[lootstartevent.Entity.UOwnerID];
                    bool isfriend = fs.Cast <FriendList.Friend>()
                                    .Any(friend => friend.GetUserID() == lootstartevent.Player.UID);
                    if ((isfriend && DataStore.GetInstance().Get("LegitRaid", lootstartevent.Entity.UOwnerID) != null) ||
                        (isfriend && AutoWhiteListFriends))
                    {
                        return;
                    }
                }
            }

            if (OwnerTimeData.ContainsKey(lootstartevent.Entity.UOwnerID))
            {
                var id       = lootstartevent.Entity.UOwnerID;
                var ticks    = OwnerTimeData[id];
                var calc     = TimeSpan.FromTicks(DateTime.Now.Ticks).TotalSeconds - ticks;
                int timeraid = RaidTime;
                if (RaiderTime.ContainsKey(id))
                {
                    timeraid = RaiderTime[id];
                }

                if (double.IsNaN(calc) || double.IsNaN(ticks))
                {
                    lootstartevent.Cancel();
                    lootstartevent.Player.Notice("",
                                                 "You need to use C4/Grenade on wall and raid within " + RaidTime + " mins!", 8f);
                    lootstartevent.Player.MessageFrom("LegitRaid",
                                                      orange + "If your friend owns the chest tell him to add you with /addfriend name");
                    lootstartevent.Player.MessageFrom("LegitRaid",
                                                      orange + "After that tell him to type /friendraid !");
                    OwnerTimeData.Remove(id);
                    if (RaiderTime.ContainsKey(id))
                    {
                        RaiderTime.Remove(id);
                    }
                }

                if (calc >= (RaidTime + timeraid) * 60)
                {
                    lootstartevent.Cancel();
                    lootstartevent.Player.Notice("",
                                                 "You need to use C4/Grenade on wall and raid within " + RaidTime + " mins!", 8f);
                    lootstartevent.Player.MessageFrom("LegitRaid",
                                                      orange + "If your friend owns the chest tell him to add you with /addfriend name");
                    lootstartevent.Player.MessageFrom("LegitRaid",
                                                      orange + "After that tell him to type /friendraid !");
                    OwnerTimeData.Remove(id);
                    if (RaiderTime.ContainsKey(id))
                    {
                        RaiderTime.Remove(id);
                    }
                }
                else
                {
                    var done = Math.Round(calc);
                    lootstartevent.Player.Notice("You can loot until: " + ((timeraid * 60) - done) + " seconds!");
                }
            }
            else
            {
                var id = GetHouseOwner(lootstartevent.Entity);
                if (DataStore.GetInstance().Get("LegitRaidED", id) != null)
                {
                    List <string> list = (List <string>)DataStore.GetInstance().Get("LegitRaidED", id);
                    if (list.Contains(lootstartevent.Entity.OwnerID) && OwnerTimeData.ContainsKey(id))
                    {
                        var ticks    = OwnerTimeData[id];
                        var calc     = TimeSpan.FromTicks(DateTime.Now.Ticks).TotalSeconds - ticks;
                        int timeraid = RaidTime;
                        if (RaiderTime.ContainsKey(id))
                        {
                            timeraid = RaiderTime[id];
                        }

                        if (double.IsNaN(calc) || double.IsNaN(ticks))
                        {
                            lootstartevent.Cancel();
                            lootstartevent.Player.Notice("",
                                                         "You need to use C4/Grenade on wall and raid within " + RaidTime + " mins!", 8f);
                            lootstartevent.Player.MessageFrom("LegitRaid",
                                                              orange + "If your friend owns the chest tell him to add you with /addfriend name");
                            lootstartevent.Player.MessageFrom("LegitRaid",
                                                              orange + "After that tell him to type /friendraid !");
                            OwnerTimeData.Remove(id);
                            if (RaiderTime.ContainsKey(id))
                            {
                                RaiderTime.Remove(id);
                            }
                        }

                        if (calc >= (RaidTime + timeraid) * 60)
                        {
                            lootstartevent.Cancel();
                            lootstartevent.Player.Notice("",
                                                         "You need to use C4/Grenade on wall and raid within " + RaidTime + " mins!", 8f);
                            lootstartevent.Player.MessageFrom("LegitRaid",
                                                              orange + "If your friend owns the chest tell him to add you with /addfriend name");
                            lootstartevent.Player.MessageFrom("LegitRaid",
                                                              orange + "After that tell him to type /friendraid !");
                            OwnerTimeData.Remove(id);
                            if (RaiderTime.ContainsKey(id))
                            {
                                RaiderTime.Remove(id);
                            }
                        }
                        else
                        {
                            var done = Math.Round(calc);
                            lootstartevent.Player.Notice(
                                "You can loot until: " + ((timeraid * 60) - done) + " seconds!");
                        }

                        return;
                    }
                }

                lootstartevent.Cancel();
                lootstartevent.Player.Notice("",
                                             "You need to use C4/Grenade on wall and raid within " + RaidTime + " mins!", 8f);
                lootstartevent.Player.MessageFrom("LegitRaid",
                                                  orange + "If your friend owns the chest tell him to add you with /addfriend name");
                lootstartevent.Player.MessageFrom("LegitRaid", orange + "After that tell him to type /friendraid !");
            }
        }