Esempio n. 1
0
        void OnHammerHit(BasePlayer player, HitInfo info)
        {
            if (!_allowAOERepair || !HasPerm(player) || IsRaidBlocked(player.UserIDString) || info.HitEntity == null || info.HitEntity.IsDestroyed)
            {
                return;
            }

            var entity = info.HitEntity as BaseCombatEntity;

            if (!entity)
            {
                return;
            }

            if (!playerData.ContainsKey(player.userID))
            {
                playerData[player.userID] = DefaultHandyManOn;
                dataFile.WriteObject(playerData);
            }

            if (playerData[player.userID])
            {
                if (!HasResources(player))
                {
                    SendChatMessage(player, msg("No Resources", player.UserIDString));
                    return;
                }

                Repair(entity, player);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// TODO: Investigate entity driven repair.
        /// Currently only building structures are driving repair. I want to allow things like high external walls to also
        /// drive repair, but they don't seem to fire under OnStructureRepair. I suspect this would be a better trigger as it would
        /// allow me to check my entity configuration rather than fire on simple repair.
        /// </summary>
        /// <param name="player"></param>
        /// <param name="info"></param>
        void OnHammerHit(BasePlayer player, HitInfo info)
        {
            //gets the correct entity type from the hammer target
            var e = info.HitEntity.GetComponent <BaseCombatEntity>();

            //checks to see that we have an entity - we should always have one
            if (e != null)
            {
                //yes - continue repair
                //checks if player preference for handyman exists on this player
                if (!playerPrefs_IsActive.ContainsKey(player.userID))
                {
                    //no - create a default entry for this player based on the default HandyMan configuration state
                    playerPrefs_IsActive[player.userID] = configData.DefaultHandyManOn;
                    dataFile.WriteObject(playerPrefs_IsActive);
                }

                //Check if repair should fire - This is to prevent a recursive / infinate loop when all structures in range fire this method.
                //This also checks if the player has turned HandyMan on
                if (_allowAOERepair && playerPrefs_IsActive[player.userID])
                {
                    //calls our custom method for this
                    Repair(e, player);
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Repairs all entities
        /// </summary>
        /// <param name="player"></param>
        /// <param name="info"></param>
        void OnHammerHit(BasePlayer player, HitInfo info)
        {
            if (!HasPerm(player) || IsRaidBlocked(player.UserIDString) || info.HitEntity == null || info.HitEntity.IsDestroyed)
            {
                return;
            }

            //gets the correct entity type from the hammer target
            var entity = info.HitEntity.GetComponent <BaseCombatEntity>();

            if (!entity)
            {
                return;
            }

            if (!playerPrefs_IsActive.ContainsKey(player.userID)) // update user if they have no profile
            {
                playerPrefs_IsActive[player.userID] = DefaultHandyManOn;
                dataFile.WriteObject(playerPrefs_IsActive);
            }

            //Check if repair should fire - This is to prevent a recursive / infinate loop when all structures in range fire this method.
            //This also checks if the player has turned HandyMan on
            if (_allowAOERepair && playerPrefs_IsActive[player.userID])
            {
                //calls our custom method for this
                Repair(entity, player);
            }
        }
Esempio n. 4
0
            public virtual void Save()
            {
                if (Compressed)
                {
                    SaveCompressed();
                    return;
                }

                _file.WriteObject(Instance);
                return;
            }
        private void OnPlayerInit(BasePlayer player)
        {
            if (sharingEnabledList.ContainsKey(player.UserIDString))
            {
                sharingEnabled = sharingEnabledList[player.UserIDString];
            }
            else
            {
                sharingEnabledList.Add(player.UserIDString, sharingEnabled);

                playerData.WriteObject(sharingEnabledList);
            }
        }
Esempio n. 6
0
 void OnServerSave()
 {
     AreasFile.WriteObject(Areas.Serialize());
     FactionsFile.WriteObject(Factions.Serialize());
     PinsFile.WriteObject(Pins.Serialize());
     WarsFile.WriteObject(Wars.Serialize());
 }
Esempio n. 7
0
        void SaveData()
        {
            DynamicConfigFile file = Interface.Oxide.DataFileSystem.GetDatafile("TeamLobbyDoors");

            file.Settings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; // allows you to store Vector3
            file.WriteObject <StoredData>(storedData);
        }
Esempio n. 8
0
 void SaveData()
 {
     if (dataFile != null && storedData != null)
     {
         dataFile.WriteObject(storedData);
     }
 }
Esempio n. 9
0
        void cmdChatSaveItems(BasePlayer player, string command, string[] args)
        {
            if (!player.IsAdmin)
            {
                return;
            }
            kit = new WeaponSet();
            player.inventory.containerBelt.itemList.Sort((i, j) => i.position.CompareTo(j.position));
            player.inventory.containerMain.itemList.Sort((i, j) => i.position.CompareTo(j.position));
            player.inventory.containerWear.itemList.Sort((i, j) => i.position.CompareTo(j.position));

            foreach (var item in player.inventory.containerBelt.itemList)
            {
                kit.belt.Add(item == null
                    ? new CustomItem("", 0)
                    : new CustomItem(item.info.itemid.ToString(), item.amount));
            }

            foreach (var item in player.inventory.containerMain.itemList)
            {
                kit.main.Add(item == null
                    ? new CustomItem("", 0)
                    : new CustomItem(item.info.itemid.ToString(), item.amount));
            }

            foreach (var item in player.inventory.containerWear.itemList)
            {
                kit.wear.Add(item?.info.itemid.ToString() ?? "");
            }

            funKitFile.WriteObject(kit);
            player.ChatMessage("Save completed");
        }
        private void SaveData()
        {
            storedData.data.Clear();
            storedData.spearData.Clear();

            foreach (KeyValuePair <Signage, DroppedItem> kvp in signRegisteredSkulls)
            {
                if (kvp.Key == null || kvp.Key.IsDestroyed || kvp.Value == null || kvp.Value.IsDestroyed)
                {
                    continue;
                }

                storedData.data.Add(kvp.Key.net.ID, new StoredData.TrophyData(kvp.Value));
            }

            foreach (KeyValuePair <DroppedItem, List <DroppedItem> > kvp in spearRegisteredSkulls)
            {
                if (kvp.Key == null || kvp.Key.IsDestroyed || kvp.Value == null || kvp.Value.Count == 0)
                {
                    continue;
                }

                storedData.spearData.Add(new StoredData.SpearData(kvp.Key, kvp.Value.Select(x => new StoredData.TrophyData(x)).ToList()));
            }

            data.WriteObject(storedData);
        }
Esempio n. 11
0
        void safecfg()
        {
            radzonedata["Position"] = new List <string> {
                target.x.ToString(), target.y.ToString(), target.z.ToString()
            };
            radzonedata["SafeRadius"] = new List <string> {
                saferadius.ToString()
            };
            radzonedata["SafeRadiusMinimum"] = new List <string> {
                saferadiusmin.ToString()
            };
            radzonedata["EventRadius"] = new List <string> {
                eventradius.ToString()
            };
            radzonedata["RadiationPower"] = new List <string> {
                radpower.ToString()
            };
            radzonedata["DecreaseStep"] = new List <string> {
                step.ToString()
            };
            radzonedata["DecreasePeriod"] = new List <string> {
                period.ToString()
            };

            /*radzonedata["DrawTime"] = new List<string>(){drawtime.ToString()};
             * radzonedata["DrawMode"] = new List<string>(){drawmode};*/

            dataFile.WriteObject(radzonedata);
        }
Esempio n. 12
0
        void UnstuckAdjust(ConsoleSystem.Arg arg)
        {
            var action = arg.Args[0];
            var id     = arg.Args[1];

            if (action == "up")
            {
                anchorMinY += 0.005; anchorMaxY += 0.005;
            }
            if (action == "down")
            {
                anchorMinY -= 0.005; anchorMaxY -= 0.005;
            }
            if (action == "left")
            {
                anchorMinX -= 0.005; anchorMaxX -= 0.005;
            }
            if (action == "right")
            {
                anchorMinX += 0.005; anchorMaxX += 0.005;
            }
            UnstuckButton(id);

            if (action == "save")
            {
                if (!playerPrefs.ContainsKey(id))
                {
                    playerPrefs.Add(id, string.Empty);
                }
                playerPrefs[id] = string.Concat(anchorMinX, ' ', anchorMinY, ' ', anchorMaxX, ' ', anchorMaxY);
                dataFile.WriteObject(playerPrefs);
            }
        }
Esempio n. 13
0
        // Saves the data file
        private void saveData()
        {
            ffplayers_file.WriteObject(ffplayers);
            var data      = Interface.GetMod().DataFileSystem.GetDatafile("rustio_clans");
            var clansData = new Dictionary <string, object>();

            foreach (var clan in clans)
            {
                var clanData = new Dictionary <string, object>();
                clanData.Add("tag", clan.Value.tag);
                clanData.Add("description", clan.Value.description);
                clanData.Add("owner", clan.Value.owner);
                var moderators = new List <object>();
                foreach (var imoderator in clan.Value.moderators)
                {
                    moderators.Add(imoderator);
                }
                var members = new List <object>();
                foreach (var imember in clan.Value.members)
                {
                    members.Add(imember);
                }
                var invited = new List <object>();
                foreach (var iinvited in clan.Value.invited)
                {
                    invited.Add(iinvited);
                }
                clanData.Add("moderators", moderators);
                clanData.Add("members", members);
                clanData.Add("invited", invited);
                clansData.Add(clan.Value.tag, clanData);
            }
            data["clans"] = clansData;
            Interface.GetMod().DataFileSystem.SaveDatafile("rustio_clans");
        }
Esempio n. 14
0
        void ChatCommand(IPlayer player, string command, string[] args)
        {
            if (usePermissions && !IsAllowed(player.Id, permAuto))
            {
                player.Reply(Lang("NotAllowed", player.Id, command));
                return;
            }

            int time;

            if (args == null || args.Length != 1 || !int.TryParse(args[0], out time))
            {
                time = 0;
            }

            if (time > maximumDelay || time < minimumDelay && time != 0)
            {
                player.Reply(Lang("Usage", player.Id, command));
                return;
            }

            playerPrefs[player.Id] = time;
            dataFile.WriteObject(playerPrefs);

            player.Reply(time == 0 ? Lang("DelayDisabled", player.Id, time) : Lang("DelaySet", player.Id, time));
        }
Esempio n. 15
0
 private void SaveData()
 {
     storedData.lootTable  = smallList;
     storedData2.lootTable = mediumList;
     storedData3.lootTable = largeList;
     PresentData.WriteObject(storedData);
     PresentData2.WriteObject(storedData2);
     PresentData3.WriteObject(storedData3);
 }
Esempio n. 16
0
        void UpdateBlockData()
        {
            var check_url    = "https://api.github.com/repos/lukespragg/geoip-json/git/trees/master" + auth;
            var download_url = "https://raw.githubusercontent.com/lukespragg/geoip-json/master/geoip-blocks-ipv4.json";
            var headers      = new Dictionary <string, string> {
                ["User-Agent"] = "Oxide-Awesomesauce"
            };

            Interface.Oxide.GetLibrary <WebRequests>("WebRequests").EnqueueGet(check_url, (api_code, api_response) =>
            {
                if (api_code != 200 || api_response == null)
                {
                    Puts("Checking for blocks IPv4 update failed! (" + api_code + ")");
                    if (debug)
                    {
                        Puts(api_response);
                    }
                    return;
                }

                var json           = JsonConvert.DeserializeObject <Dictionary <string, object> >(api_response, jsonSettings);
                string latest_sha  = string.Empty;
                string current_sha = blockData.hash;

                foreach (Dictionary <string, object> file in json["tree"] as List <object> )
                {
                    if ((string)file["path"] == "geoip-blocks-ipv4.json")
                    {
                        latest_sha = file["sha"].ToString();
                    }
                }

                if (latest_sha == current_sha)
                {
                    CacheBlockData();
                    Puts("Using latest blocks IPv4 data, commit: " + current_sha.Substring(0, 7));
                    return;
                }

                Puts("Updating blocks IPv4 data to commit " + latest_sha.Substring(0, 7) + "...");
                blockData.hash = latest_sha;

                Interface.Oxide.GetLibrary <WebRequests>("WebRequests").EnqueueGet(download_url, (code, response) =>
                {
                    if (code != 200 || response == null)
                    {
                        timer.Once(30f, UpdateBlockData);
                    }

                    blockData.ipv4 = JsonConvert.DeserializeObject <List <BlockEntry> >(response);
                    blockConfig.WriteObject(blockData);
                    CacheBlockData();

                    Puts("Blocks IPv4 data updated successfully!");
                }, this, headers, 300f);
            }, this, headers);
        }
Esempio n. 17
0
 void OnNewSave()
 {
     Interface.Call("OnWipe");
     if (DateTime.Now.Day <= 7)
     {
         Interface.Call("OnGlobalWipe");
     }
     wipeFile.WriteObject(DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
 }
Esempio n. 18
0
        private void Init()
        {
            permission.RegisterPermission(SpeedTypeAdmin, this);

            if (config.Tier2EventStatus || config.Tier3EventStatus)
            {
                TierStates = dataFile.ReadObject <Dictionary <string, int> >();

                if (TierStates.Count == 0)
                {
                    TierStates = new Dictionary <string, int>
                    {
                        { "t2efrequency", config.Tier2Frequency },
                        { "t3efrequency", config.Tier3Frequency }
                    };
                    dataFile.WriteObject(TierStates);
                }
            }
        }
Esempio n. 19
0
        void MasterKeyChatCmd(BasePlayer player)
        {
            if (!playerPrefs.ContainsKey(player.userID))
            {
                playerPrefs.Add(player.userID, true);
            }
            playerPrefs[player.userID] = !playerPrefs[player.userID];
            dataFile.WriteObject(playerPrefs);

            PrintToChat(player, playerPrefs[player.userID] ? GetMessage("Enabled", player.UserIDString) : GetMessage("Disabled"));
        }
 void saveData()
 {
     try
     {
         DataFile.WriteObject(storedData);
     }
     catch (Exception E)
     {
         Puts(E.ToString());
     }
 }
Esempio n. 21
0
        private void SaveExplosionData()
        {
            int expired = dataExplosions.RemoveAll(x => x.ContainsKey(szDeleteDate) && x[szDeleteDate] != DateTime.MinValue.ToString() && DateTime.Parse(x[szDeleteDate]) < DateTime.UtcNow);

            if (expired > 0)
            {
                explosionsLogChanged = true;
            }

            if (explosionsLogChanged)
            {
                explosionsFile.WriteObject(dataExplosions);
                explosionsLogChanged = false;
            }
        }
Esempio n. 22
0
        void UpdateLocationData()
        {
            var check_url    = "https://api.github.com/repos/lukespragg/geoip-json/contents/geoip-locations-en.json" + auth;
            var download_url = "https://raw.githubusercontent.com/lukespragg/geoip-json/master/geoip-locations-en.json";
            var headers      = new Dictionary <string, string> {
                ["User-Agent"] = "Oxide-Awesomesauce"
            };

            Interface.Oxide.GetLibrary <WebRequests>("WebRequests").EnqueueGet(check_url, (api_code, api_response) =>
            {
                if (api_code != 200 || api_response == null)
                {
                    Puts("Checking for locations EN update failed! (" + api_code + ")");
                    if (debug)
                    {
                        Puts(api_response);
                    }
                    return;
                }

                var json           = JsonConvert.DeserializeObject <Dictionary <string, object> >(api_response, jsonSettings);
                string latest_sha  = (string)json["sha"];
                string current_sha = locationData.hash;

                if (latest_sha == current_sha)
                {
                    Puts("Using latest locations EN data, commit: " + current_sha.Substring(0, 7));
                    return;
                }

                Puts("Updating locations EN data to commit " + latest_sha.Substring(0, 7) + "...");
                locationData.hash = latest_sha;

                Interface.Oxide.GetLibrary <WebRequests>("WebRequests").EnqueueGet(download_url, (code, response) =>
                {
                    if (code != 200 || response == null)
                    {
                        timer.Once(30f, UpdateLocationData);
                        return;
                    }

                    locationData.locations = JsonConvert.DeserializeObject <List <LocationEntry> >(response);
                    locationConfig.WriteObject(locationData);

                    Puts("Locations EN data updated successfully!");
                }, this, null, 300f);
            }, this, headers);
        }
Esempio n. 23
0
        private void ChatCommand(IPlayer player, string command, string[] args)
        {
            if (!player.HasPermission(permCom))
            {
                player.Reply(Lang("NotAllowed", player.Id, command));
                return;
            }

            if (!playerPrefs.ContainsKey(player.Id))
            {
                playerPrefs.Add(player.Id, true);
            }
            playerPrefs[player.Id] = !playerPrefs[player.Id];
            dataFile.WriteObject(playerPrefs);

            player.Reply(playerPrefs[player.Id] ? Lang("MasterKeyEnabled", player.Id) : Lang("MasterKeyDisabled"));
        }
Esempio n. 24
0
        void ChatCommand(IPlayer player, string command, string[] args)
        {
            if (!IsAllowed(player.Id, "masterkey.*"))
            {
                // TODO: No perm message
                return;
            }

            if (!playerPrefs.ContainsKey(player.Id))
            {
                playerPrefs.Add(player.Id, true);
            }
            playerPrefs[player.Id] = !playerPrefs[player.Id];
            dataFile.WriteObject(playerPrefs);

            player.Reply(playerPrefs[player.Id] ? Lang("Enabled", player.Id) : Lang("Disabled"));
        }
Esempio n. 25
0
        void ToggleCommand(BasePlayer player, string command, string[] args)
        {
            if (!permission.UserHasPermission(player.net.connection.userid.ToString(), "arenawalls.admin"))
            {
                SendReply(player, Lang("No Permission", player.UserIDString));
                return;
            }

            if (!playerPrefs.ContainsKey(player.userID.ToString()))
            {
                playerPrefs.Add(player.userID.ToString(), true);
            }
            playerPrefs[player.userID.ToString()] = !playerPrefs[player.userID.ToString()];
            dataFile.WriteObject(playerPrefs);

            SendReply(player, playerPrefs[player.userID.ToString()] ? Lang("Enabled", player.UserIDString) : Lang("Disabled"));
        }
Esempio n. 26
0
        void OnServerInitialized()
        {
            LoadConfig();
            LoadDefaultMessages();
            permission.RegisterPermission("Lottery.canuse", this);
            if (DefaultWinRates != null)
            {
                IndividualRates = new Dictionary <string, int>();
                foreach (var entry in DefaultWinRates)
                {
                    int rate;
                    if (!int.TryParse(entry.Value.ToString(), out rate))
                    {
                        continue;
                    }
                    IndividualRates.Add(entry.Key, rate);
                }

                var ServerRewardsDict = SRWinRates;
                SRRates = new Dictionary <string, int>();
                if (ServerRewardsDict != null)
                {
                    foreach (var entry in ServerRewardsDict)
                    {
                        int rate;
                        if (!int.TryParse(entry.Value.ToString(), out rate))
                        {
                            continue;
                        }
                        SRRates.Add(entry.Key, rate);
                    }
                }

                data = Interface.Oxide.DataFileSystem.GetFile(Name);
                try
                {
                    Currentbet = data.ReadObject <Dictionary <ulong, playerinfo> >();
                }
                catch (Exception e)
                {
                    Currentbet = new Dictionary <ulong, playerinfo>();
                    Puts(e.Message);
                }
                data.WriteObject(Currentbet);
            }
        }
Esempio n. 27
0
 public static void save()
 {
     if (!initialized)
     {
         init();
     }
     try
     {
         bountyDataFile.WriteObject(instance);
     }
     catch (Exception E)
     {
         StringBuilder sb = new StringBuilder($"saving {typeof(BountyData).Name} failed. Are you trying to save complex classes like BasePlayer or Item? that won't work!\n");
         sb.Append(E.Message);
         PluginInstance.Puts(sb.ToString());
     }
 }
Esempio n. 28
0
        void OnServerInitialized()
        {
            DynamicConfigFile bwFile = Interface.Oxide.DataFileSystem.GetFile("ChatMuteWords");

            badWordsList = bwFile.ReadObject <List <string> >() ?? new List <string>();
            if (badWordsList.Count == 0)
            {
                bwFile.WriteObject(new List <string>()
                {
                    "f**k"
                });
            }
            timer.Every(1f, () =>
            {
                List <ulong> toRemove = mutes.Keys.ToList().Where(uid => -- mutes[uid] < 0).ToList();
                toRemove.ForEach(p => mutes.Remove(p));
            });
            mutes = saveFile.ReadObject <Dictionary <ulong, int> >();
        }
Esempio n. 29
0
        void conssetskin(ConsoleSystem.Arg arg)
        {
            if (arg.Connection != null)
            {
                int        skin   = int.Parse(arg.Args[0]);
                BasePlayer player = arg.Connection.player as BasePlayer;

                DestroyUI(player, "menu");

                int prevSkin;
                if (playerPrefs.TryGetValue(player.userID, out prevSkin) && prevSkin > 0)
                {
                    DestroyUI(player, $"info{playerPrefs[player.userID]}");
                }
                playerPrefs[player.userID] = skin;
                dataFile.WriteObject(playerPrefs);
                drawtoplayer(player, skin);
            }
        }
Esempio n. 30
0
        void LoadData()
        {
            lootConfig = LootConfigFile.ReadObject <Dictionary <string, LootStorage> >();
            lootCases  = LootCasesFile.ReadObject <Dictionary <string, LootCase> >();
            if (lootCases.Count == 0)
            {
                lootCases.Add("mycase", new LootCase()
                {
                    items = new List <LootItem>()
                    {
                        new LootItem()
                        {
                            shortname = "wood", amount = 100, chance = 1f
                        }
                    }
                });

                LootCasesFile.WriteObject(lootCases);
            }
        }