internal void Initialize() { Environment.Initialize(); try { Implementation.OnRocketImplementationInitialized += () => { gameObject.TryAddComponent<TaskDispatcher>(); gameObject.TryAddComponent<AutomaticShutdownWatchdog>(); if(Settings.Instance.RCON.Enabled) gameObject.TryAddComponent<RCONServer>(); }; Settings = new XMLFileAsset<RocketSettings>(Environment.SettingsFile); Translation = new XMLFileAsset<TranslationList>(String.Format(Environment.TranslationFile, Settings.Instance.LanguageCode), new Type[] { typeof(TranslationList), typeof(TranslationListEntry) }, defaultTranslations); Permissions = gameObject.TryAddComponent<RocketPermissionsManager>(); Plugins = gameObject.TryAddComponent<RocketPluginManager>(); Commands = gameObject.TryAddComponent<RocketCommandManager>(); if (Settings.Instance.MaxFrames < 10 && Settings.Instance.MaxFrames != -1) Settings.Instance.MaxFrames = 10; Application.targetFrameRate = Settings.Instance.MaxFrames; OnRockedInitialized.TryInvoke(); } catch (Exception ex) { Logger.LogException(ex); } }
internal void Initialize() { Environment.Initialize(); try { Implementation.OnRocketImplementationInitialized += () => { gameObject.TryAddComponent <TaskDispatcher>(); gameObject.TryAddComponent <AutomaticShutdownWatchdog>(); if (Settings.Instance.RCON.Enabled) { gameObject.TryAddComponent <RCONServer>(); } }; Settings = new XMLFileAsset <RocketSettings>(Environment.SettingsFile); Translation = new XMLFileAsset <TranslationList>(String.Format(Environment.TranslationFile, Settings.Instance.LanguageCode), new Type[] { typeof(TranslationList), typeof(TranslationListEntry) }, defaultTranslations); defaultTranslations.AddUnknownEntries(Translation); Permissions = gameObject.TryAddComponent <RocketPermissionsManager>(); Plugins = gameObject.TryAddComponent <RocketPluginManager>(); Commands = gameObject.TryAddComponent <RocketCommandManager>(); if (Settings.Instance.MaxFrames < 10 && Settings.Instance.MaxFrames != -1) { Settings.Instance.MaxFrames = 10; } Application.targetFrameRate = Settings.Instance.MaxFrames; OnRockedInitialized.TryInvoke(); } catch (Exception ex) { Logger.LogException(ex); } }
internal void Initialize() { try { Settings = new XMLFileAsset <UnturnedSettings>(Environment.SettingsFile); Translation = new XMLFileAsset <TranslationList>(String.Format(Environment.TranslationFile, Core.R.Settings.Instance.LanguageCode), new Type[] { typeof(TranslationList), typeof(TranslationListEntry) }, defaultTranslations); defaultTranslations.AddUnknownEntries(Translation); Events = gameObject.TryAddComponent <UnturnedEvents>(); gameObject.TryAddComponent <UnturnedPermissions>(); gameObject.TryAddComponent <UnturnedChat>(); gameObject.TryAddComponent <UnturnedCommands>(); gameObject.TryAddComponent <AutomaticSaveWatchdog>(); bindDelegates(); RocketPlugin.OnPluginLoading += (IRocketPlugin plugin, ref bool cancelLoading) => { try { plugin.TryAddComponent <PluginUnturnedPlayerComponentManager>(); } catch (Exception ex) { Core.Logging.Logger.LogException(ex, "Failed to load plugin " + plugin.Name + "."); cancelLoading = true; } }; RocketPlugin.OnPluginUnloading += (IRocketPlugin plugin) => { plugin.TryRemoveComponent <PluginUnturnedPlayerComponentManager>(); }; R.Commands.RegisterFromAssembly(Assembly.GetExecutingAssembly()); try { R.Plugins.OnPluginsLoaded += () => { SteamGameServer.SetKeyValue("rocketplugins", String.Join(",", R.Plugins.GetPlugins().Select(p => p.Name).ToArray())); }; SteamGameServer.SetKeyValue("rocket", Assembly.GetExecutingAssembly().GetName().Version.ToString()); SteamGameServer.SetBotPlayerCount(1); } catch (Exception ex) { Core.Logging.Logger.LogError("Steam can not be initialized: " + ex.Message); } OnRocketImplementationInitialized.TryInvoke(); } catch (Exception ex) { Core.Logging.Logger.LogException(ex); } }
private void Awake() { Commands = commands.AsReadOnly(); commandMappings = new XMLFileAsset <RocketCommands>(Environment.CommandsFile); checkCommandMappings(); R.Plugins.OnPluginsLoaded += Plugins_OnPluginsLoaded; }
public void Start() { Stats = new XMLFileAsset <StatKeeper.Stats>(Path.Combine(Plugin.Instance.Directory, "Stats/" + Player.Id + ".xml")); Stats.Instance.SteamID = (ulong)Player.CSteamID; //TODO: Add tracking of acc when player is in combat Player.Events.OnDeath += (UnturnedPlayer player, SDG.Unturned.EDeathCause cause, SDG.Unturned.ELimb limb, Steamworks.CSteamID m) => { UnturnedPlayer murderer = UnturnedPlayer.FromCSteamID(m); if (murderer != null && PlayerTool.getSteamPlayer(m) != null && cause != SDG.Unturned.EDeathCause.SUICIDE) { XMLFileAsset <Stats> killerStats = murderer.GetComponent <StatsPlayerComponent>().Stats; if (limb == SDG.Unturned.ELimb.SKULL) { killerStats.Instance.HeadShots += 1; } killerStats.Instance.Kills += 1; killerStats.Instance.RecalculateStats(); killerStats.Save(); } Stats.Instance.Deaths += 1; Stats.Instance.RecalculateStats(); Stats.Save(); Plugin.Instance.UpdateRank(); }; Stats.Instance.RecalculateStats(); Plugin.Instance.UpdateRank(); }
protected override void Load() { Instance = this; CosmeticsStore = new XMLFileAsset <PlayersCosmeticsStore>(Path.Combine(Directory, $"{Name}.cosmetics.xml")); CosmeticsStore.Load(); UnturnedPermissions.OnJoinRequested += OnJoinRequested; SaveManager.onPreSave += OnPreSave; Logger.Log($"Advanced Cosmetics v{Assembly.GetName().Version} has been loaded"); Logger.Log("Do you want more cool plugins? Join now: https://discord.gg/4FF2548 !"); }
public void UpdateStats(UnturnedPlayer player) { XMLFileAsset <Stats> PlayerStats = new XMLFileAsset <StatKeeper.Stats>(Path.Combine(Instance.Directory, "Stats/" + player.CSteamID + ".xml")); EffectManager.sendUIEffect((ushort)9879, (short)9884, player.CSteamID, true, PlayerStats.Instance.Rank.ToString()); EffectManager.sendUIEffect((ushort)9880, (short)9885, player.CSteamID, true, PlayerStats.Instance.Kills.ToString()); EffectManager.sendUIEffect((ushort)9881, (short)9886, player.CSteamID, true, PlayerStats.Instance.Deaths.ToString()); EffectManager.sendUIEffect((ushort)9882, (short)9887, player.CSteamID, true, PlayerStats.Instance.KDRatio.ToString()); EffectManager.sendUIEffect((ushort)9883, (short)9888, player.CSteamID, true, PlayerStats.Instance.HeadShots.ToString()); }
public void DefaultItems() { IAsset <DefaultValues> defaultValues = null; string text = Path.Combine(DShop.Instance.Directory, string.Format("{0}.defaultvalues.xml", DShop.Instance.Name)); try { defaultValues = new XMLFileAsset <DefaultValues>(text, null, null); defaultValues.Load(); if (ObjectListConfigVersion < defaultValues.Instance.FileVersion) { ObjectListConfigVersion = defaultValues.Instance.FileVersion; Dictionary <ushort, ShopObject> items = DShop.Instance.Database.GetAllItems(ItemType.Item); Dictionary <ushort, ShopObject> vehicles = DShop.Instance.Database.GetAllItems(ItemType.Vehicle); Logger.Log("Adding new Default items to database!"); // Start adding items to the database from the defaults file that aren't present in the database. foreach (ShopItem item in defaultValues.Instance.Items) { if (!items.ContainsKey(item.ItemID)) { // Get generate the asset name for the database. item.AssetName(); DShop.Instance.Database.AddItem(ItemType.Item, item as ShopObject); } } foreach (ShopVehicle vehicle in defaultValues.Instance.Vehicles) { if (!vehicles.ContainsKey(vehicle.ItemID)) { // Get generate the asset name for the database. vehicle.AssetName(); DShop.Instance.Database.AddItem(ItemType.Vehicle, vehicle as ShopObject); } } Logger.Log("Finished!"); } //defaultValues.Save(); } catch { Logger.LogWarning("Error parsing the defaults file, skipping loading shop defaults!"); return; } }
internal void Initialize() { Environment.Initialize(); try { Implementation.OnRocketImplementationInitialized += () => { gameObject.TryAddComponent <TaskDispatcher>(); gameObject.TryAddComponent <AutomaticShutdownWatchdog>(); if (Settings.Instance.RCON.Enabled) { gameObject.TryAddComponent <RCONServer>(); } }; Settings = new XMLFileAsset <RocketSettings>(Environment.SettingsFile); var settings = Settings.Instance; Translation = new XMLFileAsset <TranslationList>(string.Format(Environment.TranslationFile, settings.LanguageCode), new Type[] { typeof(TranslationList), typeof(TranslationListEntry) }, defaultTranslations); defaultTranslations.AddUnknownEntries(Translation); Permissions = gameObject.TryAddComponent <RocketPermissionsManager>(); //Plugins = gameObject.TryAddComponent<RocketPluginManager>(); Plugins = new RocketPluginManager(); RocketPluginManager.Awake(); Commands = new RocketCommandManager(); Commands.Awake(); // Load Commands from Rocket.Core.Commands. Commands.RegisterFromAssembly(Assembly.GetExecutingAssembly()); if (settings.MaxFrames < 10 && settings.MaxFrames != -1) { settings.MaxFrames = 10; } Application.targetFrameRate = settings.MaxFrames; OnRockedInitialized.TryInvoke(); Plugins.loadPlugins(); } catch (Exception ex) { Logging.Logger.LogException(ex); } }
public void Start() { Stats = new XMLFileAsset <StatKeeper.Stats>(Path.Combine(Plugin.Instance.Directory, "Stats/" + Player.Id + ".xml")); Stats.Instance.SteamID = (ulong)Player.CSteamID; Player.Events.OnDeath += (UnturnedPlayer player, SDG.Unturned.EDeathCause cause, SDG.Unturned.ELimb limb, Steamworks.CSteamID m) => { UnturnedPlayer murderer = UnturnedPlayer.FromCSteamID(m); if (murderer != null && PlayerTool.getSteamPlayer(m) != null) { XMLFileAsset <Stats> killerStats = murderer.GetComponent <StatsPlayerComponent>().Stats; killerStats.Instance.Kills[cause.ToString()] = killerStats.Instance.GetKills(cause.ToString()) + 1; killerStats.Instance.RecalculateStats(); killerStats.Save(); } Stats.Instance.Deaths[cause.ToString()] = Stats.Instance.GetDeaths(cause.ToString()) + 1; Stats.Instance.RecalculateStats(); Stats.Save(); }; Stats.Instance.RecalculateStats(); }
internal void Initialize() { try { Settings = new XMLFileAsset <UnturnedSettings>(Environment.SettingsFile); Translation = new XMLFileAsset <TranslationList>(String.Format(Environment.TranslationFile, Core.R.Settings.Instance.LanguageCode), new Type[] { typeof(TranslationList), typeof(TranslationListEntry) }, defaultTranslations); defaultTranslations.AddUnknownEntries(Translation); Events = gameObject.TryAddComponent <UnturnedEvents>(); gameObject.TryAddComponent <UnturnedPermissions>(); gameObject.TryAddComponent <UnturnedChat>(); gameObject.TryAddComponent <UnturnedCommands>(); gameObject.TryAddComponent <AutomaticSaveWatchdog>(); bindDelegates(); RocketPlugin.OnPluginLoading += (IRocketPlugin plugin, ref bool cancelLoading) => { try { plugin.TryAddComponent <PluginUnturnedPlayerComponentManager>(); } catch (Exception ex) { Core.Logging.Logger.LogException(ex, "Failed to load plugin " + plugin.Name + "."); cancelLoading = true; } }; RocketPlugin.OnPluginUnloading += (IRocketPlugin plugin) => { plugin.TryRemoveComponent <PluginUnturnedPlayerComponentManager>(); }; R.Commands.RegisterFromAssembly(Assembly.GetExecutingAssembly()); try { R.Plugins.OnPluginsLoaded += () => { IPluginAdvertising pluginAdvertising = PluginAdvertising.Get(); List <IRocketPlugin> rocketPlugins = R.Plugins.GetPlugins(); List <string> pluginNames = new List <string>(rocketPlugins.Count); foreach (IRocketPlugin plugin in rocketPlugins) { if (plugin != null && !string.IsNullOrEmpty(plugin.Name)) { pluginNames.Add(plugin.Name); } } pluginAdvertising.AddPlugins(pluginNames); }; SteamGameServer.SetKeyValue("unturned", Provider.APP_VERSION); SteamGameServer.SetKeyValue("rocket", Assembly.GetExecutingAssembly().GetName().Version.ToString()); } catch (Exception ex) { Core.Logging.Logger.LogError("Steam can not be initialized: " + ex.Message); } OnRocketImplementationInitialized.TryInvoke(); } catch (Exception ex) { Core.Logging.Logger.LogException(ex); } }
internal void Initialize() { try { Settings = new XMLFileAsset<UnturnedSettings>(Environment.SettingsFile); Translations = new XMLFileAsset<TranslationList>(String.Format(Environment.TranslationFile, Core.R.Settings.Instance.LanguageCode), new Type[] { typeof(TranslationList), typeof(TranslationListEntry) }, defaultTranslations); Events = gameObject.TryAddComponent<UnturnedEvents>(); gameObject.TryAddComponent<UnturnedEffectManager>(); gameObject.TryAddComponent<UnturnedPermissions>(); gameObject.TryAddComponent<UnturnedChat>(); gameObject.TryAddComponent<AutomaticSaveWatchdog>(); RocketPlugin.OnPluginLoading += (IRocketPlugin plugin, ref bool cancelLoading) => { try { plugin.TryAddComponent<PluginUnturnedPlayerComponentManager>(); plugin.TryAddComponent<PluginCommandManager>(); } catch (Exception ex) { Logger.LogException(ex, "Failed to load plugin " + plugin.Name + "."); cancelLoading = true; } }; RocketPlugin.OnPluginUnloading += (IRocketPlugin plugin) => { plugin.TryRemoveComponent<PluginUnturnedPlayerComponentManager>(); plugin.TryRemoveComponent<PluginCommandManager>(); }; PluginCommandManager.RegisterFromAssembly(Assembly.GetExecutingAssembly()); R.Plugins.OnPluginsLoaded += () => { SteamGameServer.SetKeyValue("rocketplugins", String.Join(",", R.Plugins.GetPlugins().Select(p => p.Name).ToArray())); }; SteamGameServer.SetKeyValue("rocket", Assembly.GetExecutingAssembly().GetName().Version.ToString()); SteamGameServer.SetBotPlayerCount(1); OnRocketImplementationInitialized.TryInvoke(); } catch (Exception ex) { Logger.LogException(ex); } }
private void Awake() { _whitelistAsset = new XMLFileAsset <WhitelistXml>( Path.Combine(Path.Combine(Environment.PluginsDirectory, ZebraPlugin.Self.Name), "AviZebra.whitelist.xml")); _whitelistAsset.Load(); }
public static void MigrateDatabase() { MySqlCommand cmd1 = Connection.CreateCommand(); MySqlCommand cmd2 = Connection.CreateCommand(); MySqlCommand cmd3 = Connection.CreateCommand(); cmd1.CommandText = String.Format("DELETE FROM {0}", PLAYER_TABLE); cmd2.CommandText = String.Format("DELETE FROM {0}", PERMISSION_TABLE); cmd3.CommandText = String.Format("DELETE FROM {0}", GROUP_TABLE); TryOpen(); cmd1.ExecuteNonQuery(); cmd2.ExecuteNonQuery(); cmd3.ExecuteNonQuery(); TryClose(); RocketPermissions p = new XMLFileAsset <RocketPermissions>(Rocket.Core.Environment.PermissionFile, null, null).Instance; LoonePermissionsConfig.SetDefaultGroup(p.DefaultGroup); foreach (RocketPermissionsGroup group in p.Groups) { CreateGroup(group.Id); if (group.Color != null) { UpdateGroup(EGroupProperty.COLOR, group.Color, group.Id); } if (group.ParentGroup != null) { UpdateGroup(EGroupProperty.PARENT, group.ParentGroup, group.Id); } if (group.Prefix != null) { UpdateGroup(EGroupProperty.PREFIX, group.Prefix, group.Id); } if (group.Suffix != null) { UpdateGroup(EGroupProperty.SUFFIX, group.Suffix, group.Id); } if (group.DisplayName != null) { UpdateGroup(EGroupProperty.NAME, group.DisplayName, group.Id); } UpdateGroup(EGroupProperty.PRIORITY, group.Priority.ToString(), group.Id); foreach (Permission perm in group.Permissions) { string name = perm.Name; name = name.Replace("-", "~"); AddPermission(group.Id, name, (int)perm.Cooldown); } foreach (string player in group.Members) { if (ulong.TryParse(player, out ulong id)) { AddPlayerToGroup(id, group.Id); } } } }
public void UpdateRank() { List <string> RankList = new List <string>(); List <string> FilePaths = new List <string>(); string SteamIDOne = ""; string SteamIDTwo = ""; int TempValOne = 0; int TempValTwo = 0; foreach (string file in System.IO.Directory.EnumerateFiles(Path.Combine(Instance.Directory, "Stats/"))) { FilePaths.Add(file); } while (FilePaths.Count > 0) { if (FilePaths.Count > 1) { for (int i = 0; i < (FilePaths.Count - 1); i++) { XmlDocument doc = new XmlDocument(); doc.Load(FilePaths[i]); XmlNodeList kills = doc.GetElementsByTagName("Kills"); XmlNodeList deaths = doc.GetElementsByTagName("Deaths"); XmlNodeList steamID = doc.GetElementsByTagName("SteamID"); if (kills.Count > 0 && deaths.Count > 0) { TempValOne = int.Parse(kills[0].InnerXml) + int.Parse(deaths[0].InnerXml); SteamIDOne = steamID[0].InnerXml; } doc.Load(FilePaths[i + 1]); kills = doc.GetElementsByTagName("Kills"); deaths = doc.GetElementsByTagName("Deaths"); steamID = doc.GetElementsByTagName("SteamID"); if (kills.Count > 0 && deaths.Count > 0) { TempValTwo = int.Parse(kills[0].InnerXml) + int.Parse(deaths[0].InnerXml); SteamIDTwo = steamID[0].InnerXml; } if (TempValOne > TempValTwo) { RankList.Add(SteamIDTwo); FilePaths.RemoveAt(i + 1); } else { RankList.Add(SteamIDOne); FilePaths.RemoveAt(i); } } } else { XmlDocument doc = new XmlDocument(); doc.Load(FilePaths[0]); XmlNodeList steamID = doc.GetElementsByTagName("SteamID"); RankList.Add(steamID[0].InnerXml); FilePaths.RemoveAt(0); } } for (int i = 0; i < RankList.Count; i++) { XMLFileAsset <Stats> PlayerStats = new XMLFileAsset <StatKeeper.Stats>(Path.Combine(Instance.Directory, "Stats/" + RankList[i] + ".xml")); PlayerStats.Instance.Rank = i + 1; PlayerStats.Save(); } // Find way to sort through players without adding their ID to a list foreach (SteamPlayer player in Provider.clients) { UnturnedPlayer uPlayer = UnturnedPlayer.FromCSteamID(player.playerID.steamID); UpdateStats(uPlayer); } }
internal void Initialize() { try { Settings = new XMLFileAsset <UnturnedSettings>(Environment.SettingsFile); Translation = new XMLFileAsset <TranslationList>(string.Format(Environment.TranslationFile, Core.R.Settings.Instance.LanguageCode), new Type[] { typeof(TranslationList), typeof(TranslationListEntry) }, defaultTranslations); defaultTranslations.AddUnknownEntries(Translation); //Events = gameObject.TryAddComponent<UnturnedEvents>(); Events = new UnturnedEvents(); Events.Awake(); //gameObject.TryAddComponent<UnturnedPermissions>(); //gameObject.TryAddComponent<UnturnedChat>(); SDG.Unturned.ChatManager.onChatted += UnturnedChat.handleChat; //gameObject.TryAddComponent<UnturnedCommands>(); foreach (Command vanillaCommand in Commander.commands) { R.Commands.Register(new UnturnedCommands.UnturnedVanillaCommand(vanillaCommand), vanillaCommand.command.ToLower(), Core.Serialization.CommandPriority.Low); } gameObject.TryAddComponent <AutomaticSaveWatchdog>(); bindDelegates(); RocketPlugin.OnPluginLoading += (IRocketPlugin plugin, ref bool cancelLoading) => { try { plugin.TryAddComponent <PluginUnturnedPlayerComponentManager>(); } catch (Exception ex) { Core.Logging.Logger.LogException(ex, "Failed to load plugin " + plugin.Name + "."); cancelLoading = true; } }; RocketPlugin.OnPluginUnloading += (IRocketPlugin plugin) => { plugin.TryRemoveComponent <PluginUnturnedPlayerComponentManager>(); }; R.Commands.RegisterFromAssembly(Assembly.GetExecutingAssembly()); try { if (!Settings.Instance.HidePlugins) { R.Plugins.OnPluginsLoaded += () => { var plugs = R.Plugins.GetPlugins(); var names = new string[plugs.Count]; for (int i = 0; i < names.Length; i++) { names[i] = plugs[i].Name; } SteamGameServer.SetKeyValue("rocketplugins", string.Join(",", names)); }; } if (Settings.Instance.ClampMaxPlayers) { Level.onPreLevelLoaded += ClampMaxPlayers; } SteamGameServer.SetKeyValue("unturned", Provider.APP_VERSION); SteamGameServer.SetKeyValue("rocket", Assembly.GetExecutingAssembly().GetName().Version.ToString()); SteamGameServer.SetBotPlayerCount(1); } catch (Exception ex) { Core.Logging.Logger.LogError("Steam can not be initialized: " + ex.Message); } OnRocketImplementationInitialized.TryInvoke(); } catch (Exception ex) { Core.Logging.Logger.LogException(ex); } }