void LoadData() { teamLobbyDoors.Clear(); try { storedData = Interface.Oxide.DataFileSystem.ReadObject <StoredData>("TeamLobbyDoors"); } catch { storedData = new StoredData(); } foreach (var remote in storedData.TeamLobbyDoors) { teamLobbyDoors[remote.position] = remote; } }
void LoadData() { zonedefinitions.Clear(); try { storedData = Interface.GetMod().DataFileSystem.ReadObject <StoredData>("ZoneManager"); } catch { storedData = new StoredData(); } foreach (var zonedef in storedData.ZoneDefinitions) { zonedefinitions[zonedef.ID] = zonedef; } }
void LoadData() { elevators.Clear(); try { storedData = Interface.GetMod().DataFileSystem.ReadObject <StoredData>("Elevators"); } catch { storedData = new StoredData(); } foreach (var elevator in storedData.Elevators) { elevators[elevator.Name] = elevator; } }
///////////////////////////////////////// // Unload() // Called when the plugin is unloaded (via oxide.unload or oxide.reload or when the server shutsdown) ///////////////////////////////////////// void Unload() { foreach (KeyValuePair <BasePlayer, Plugins.Timer> pair in TimersList) { pair.Value.Destroy(); } TimersList.Clear(); }
private void Unloaded() { DestroyTimers(); PvPList.Clear(); raidZoneList.Clear(); ExpiredPvPZonesList.Clear(); ExpiredRaidZonesList.Clear(); tTimers.Clear(); }
internal void Prepare(Action callback) { ThreadPool.QueueUserWorkItem(_ => { try { referencedPlugins.Clear(); references.Clear(); // Include references made by the CSharpPlugins project foreach (var name in CSharpPluginLoader.PluginReferences) { references[name + ".dll"] = new CompilerFile(Interface.Oxide.ExtensionDirectory, name + ".dll"); } CompilablePlugin plugin; while (queuedPlugins.TryDequeue(out plugin)) { if (Current == null) { Current = this; } if (!CacheScriptLines(plugin) || plugin.ScriptLines.Length < 1) { plugin.References.Clear(); plugin.IncludePaths.Clear(); plugin.Requires.Clear(); Interface.Oxide.LogWarning("Plugin script is empty: " + plugin.Name); RemovePlugin(plugin); } else if (plugins.Add(plugin)) { PreparseScript(plugin); ResolveReferences(plugin); } CacheModifiedScripts(); // We don't want the main thread to be able to add more plugins which could be missed if (queuedPlugins.Count == 0 && Current == this) { Current = null; } } //Interface.Oxide.LogDebug("Done preparing compilation: " + plugins.Select(p => p.Name).ToSentence()); callback(); } catch (Exception ex) { Interface.Oxide.LogException("Exception while resolving plugin references", ex); RemoteLogger.Exception("Exception while resolving plugin references", ex); } }); }
public void Reset() { currentPriority = 0f; SortNode.Clear(); RunDetection.Clear(); NodeList.Clear(); Loops = 0; shouldBreak = false; }
private void OnCompilerFailed(string reason) { foreach (var compilation in compilations.Values) { foreach (var plugin in compilation.plugins) { plugin.CompilerErrors = reason; } compilation.Completed(); } compilations.Clear(); }
void UpdateBannedIPs() { bannedIPs.Clear(); foreach (KeyValuePair <string, BanData> pair in banLogs) { foreach (string ip in pair.Value.IPs) { if (bannedIPs[ip] == null) { bannedIPs.Add(ip, pair.Value); } } } }
List <Vector3> FindLinePath(Vector3 sourcePosition, Vector3 targetPosition, BasePlayer player = null) { float distance = (int)Mathf.Ceil(Vector3.Distance(sourcePosition, targetPosition)); Hash <float, Vector3> StraightPath = new Hash <float, Vector3>(); StraightPath[0f] = sourcePosition; Vector3 currentPos; for (float i = 1f; i < distance; i++) { currentPos = Vector3.Lerp(sourcePosition, targetPosition, i / distance); if (!FindRawGroundPosition(currentPos, out GroundPosition)) { if (!FindRawGroundPositionUP(currentPos, out GroundPosition)) { return(null); } } if (Vector3.Distance(GroundPosition, StraightPath[i - 1f]) > 2) { return(null); } if (Physics.Linecast(StraightPath[i - 1f] + jumpPosition, GroundPosition + jumpPosition, blockLayer)) { return(null); } if (player != null) { Draw.Call("Sphere", player, StraightPath[i], 0.5f, UnityEngine.Color.white, 20f); } StraightPath[i] = GroundPosition; } if (Physics.Linecast(StraightPath[distance - 1f] + jumpPosition, targetPosition + jumpPosition, blockLayer)) { return(null); } StraightPath[distance] = targetPosition; StraightPath.Remove(0f); List <Vector3> straightPath = new List <Vector3>(); foreach (KeyValuePair <float, Vector3> pair in StraightPath) { straightPath.Add(pair.Value); } StraightPath.Clear(); return(straightPath); }
void LoadData() { sethomedatas.Clear(); try { storedData = Interface.GetMod().DataFileSystem.ReadObject <StoredData>("SetHome"); } catch { storedData = new StoredData(); } foreach (var thehomedata in storedData.SetHomeDatas) { sethomedatas[thehomedata.userid] = thehomedata; } }
void LoadData() { waypoints.Clear(); try { storedData = Interface.GetMod().DataFileSystem.ReadObject <StoredData>("Waypoints"); } catch { storedData = new StoredData(); } foreach (var thewaypoint in storedData.WayPoints) { waypoints[thewaypoint.Name] = thewaypoint; } }
void LoadData() { jailinmates.Clear(); try { storedData = Interface.GetMod().DataFileSystem.ReadObject <StoredData>("Jail"); } catch { storedData = new StoredData(); } foreach (var jaildef in storedData.JailInmates) { jailinmates[jaildef.userid] = jaildef; } }
void LoadData() { deadPlayers.Clear(); try { storedData = Interface.GetMod().DataFileSystem.ReadObject <StoredData>("DeadPlayersList"); } catch { storedData = new StoredData(); } foreach (var dead_player in storedData.DeadPlayers) { deadPlayers[dead_player.GetUserId()] = dead_player; } }
void LoadData() { zonelogs.Clear(); try { storedData = Interface.GetMod().DataFileSystem.ReadObject <StoredData>("EventManager"); } catch { storedData = new StoredData(); } foreach (var thelog in storedData.ZoneLogs) { zonelogs[thelog.name] = thelog; } }
void LoadData() { banLogs.Clear(); try { storedData = Interface.GetMod().DataFileSystem.ReadObject <StoredData>("EnhancedBanSystem"); } catch { storedData = new StoredData(); } foreach (var thelog in storedData.BanLogs) { banLogs[thelog.steamID] = thelog; } }
static Dictionary <string, object> GetDeployableList() { var deployables = new Dictionary <string, object>(); deployableCloneToGood.Clear(); var objects = Resources.FindObjectsOfTypeAll(typeof(DeployableItemDataBlock)); if (objects != null) { foreach (DeployableItemDataBlock gameObj in objects) { deployableCloneToGood[gameObj.ObjectToPlace.gameObject.name + "(Clone)"] = gameObj.name; if (!deployables.ContainsKey(gameObj.name)) { deployables.Add(gameObj.name, true); } } } return(deployables); }
static Dictionary <string, object> GetStructureList() { var structures = new Dictionary <string, object>(); structureCloneToGood.Clear(); var objects = Resources.FindObjectsOfTypeAll(typeof(StructureComponentDataBlock)); if (objects != null) { foreach (StructureComponentDataBlock gameObj in objects) { structureCloneToGood[gameObj.structureToPlacePrefab.gameObject.name + "(Clone)"] = gameObj.name; if (!structures.ContainsKey(gameObj.name)) { structures.Add(gameObj.name, true); } } } return(structures); }
void ResetVotes() { GroundVote.Clear(); WeaponVote.Clear(); }
void cmdChatKit(BasePlayer player, string command, string[] args) { if (args.Length == 0) { if (GUIKits.ContainsKey("chat")) { NewKitPanel(player, "chat"); } else { string reason = string.Empty; foreach (KeyValuePair <string, Kit> pair in storedData.Kits) { bool cansee = CanSeeKit(player, pair.Key, false, out reason); if (!cansee && reason == string.Empty) { continue; } SendReply(player, string.Format("{0} - {1} - {2}", pair.Value.name, pair.Value.description, reason)); } } return; } if (args.Length == 1) { switch (args[0]) { case "help": SendReply(player, "====== Player Commands ======"); SendReply(player, "/kit => to get the list of kits"); SendReply(player, "/kit KITNAME => to redeem the kit"); if (!hasAccess(player)) { return; } SendReply(player, "====== Admin Commands ======"); SendReply(player, "/kit add KITNAME => add a kit"); SendReply(player, "/kit remove KITNAME => remove a kit"); SendReply(player, "/kit edit KITNAME => edit a kit"); SendReply(player, "/kit list => get a raw list of kits (the real full list)"); SendReply(player, "/kit give PLAYER/STEAMID KITNAME => give a kit to a player"); SendReply(player, "/kit resetkits => deletes all kits"); SendReply(player, "/kit resetdata => reset player data"); break; case "add": case "remove": case "edit": if (!hasAccess(player)) { SendReply(player, "You don't have access to this command"); return; } SendReply(player, string.Format("/kit {0} KITNAME", args[0])); break; case "give": if (!hasAccess(player)) { SendReply(player, "You don't have access to this command"); return; } SendReply(player, "/kit give PLAYER/STEAMID KITNAME"); break; case "list": if (!hasAccess(player)) { SendReply(player, "You don't have access to this command"); return; } foreach (KeyValuePair <string, Kit> pair in storedData.Kits) { SendReply(player, string.Format("{0} - {1}", pair.Value.name, pair.Value.description)); } break; case "items": break; case "resetkits": if (!hasAccess(player)) { SendReply(player, "You don't have access to this command"); return; } storedData.Kits.Clear(); kitEditor.Clear(); ResetData(); SaveKits(); SendReply(player, "Resetted all kits and player data"); break; case "resetdata": if (!hasAccess(player)) { SendReply(player, "You don't have access to this command"); return; } ResetData(); SendReply(player, "Resetted all player data"); break; default: TryGiveKit(player, args[0].ToLower()); break; } if (args[0] != "items") { return; } } if (!hasAccess(player)) { SendReply(player, "You don't have access to this command"); return; } string kitname = string.Empty; switch (args[0]) { case "add": kitname = args[1].ToLower(); if (storedData.Kits[kitname] != null) { SendReply(player, "This kit already exists."); return; } storedData.Kits[kitname] = new Kit(args[1]); kitEditor[player] = kitname; SendReply(player, "You've created a new kit: " + args[1]); SendListKitEdition(player); break; case "give": if (args.Length < 3) { SendReply(player, "/kit give PLAYER/STEAMID KITNAME"); return; } kitname = args[2].ToLower(); if (storedData.Kits[kitname] == null) { SendReply(player, "This kit doesn't seem to exist."); return; } List <BasePlayer> findPlayers = FindPlayer(args[1]); if (findPlayers.Count == 0) { SendReply(player, "No players found."); return; } if (findPlayers.Count > 1) { SendReply(player, "Multiple players found."); return; } GiveKit(findPlayers[0], kitname); SendReply(player, string.Format("You gave {0} the kit: {1}", findPlayers[0].displayName, storedData.Kits[kitname].name)); SendReply(findPlayers[0], string.Format("You've received the kit {1} from {0}", player.displayName, storedData.Kits[kitname].name)); break; case "edit": kitname = args[1].ToLower(); if (storedData.Kits[kitname] == null) { SendReply(player, "This kit doesn't seem to exist"); return; } kitEditor[player] = kitname; SendReply(player, string.Format("You are now editing the kit: {0}", kitname)); SendListKitEdition(player); break; case "remove": kitname = args[1].ToLower(); if (storedData.Kits[kitname] == null) { SendReply(player, "This kit doesn't seem to exist"); return; } storedData.Kits.Remove(kitname); SendReply(player, string.Format("{0} was removed", kitname)); if (kitEditor[player] == kitname) { kitEditor.Remove(player); } break; default: if (kitEditor[player] == null) { SendReply(player, "You are not creating or editing a kit"); return; } if (storedData.Kits[kitEditor[player]] == null) { SendReply(player, "There was an error while getting this kit, was it changed while you were editing it?"); return; } for (int i = 0; i < args.Length; i = i + 2) { if (args[i].ToLower() == "items") { i--; storedData.Kits[kitEditor[player]].items = GetPlayerItems(player); SendReply(player, "The items were copied from your inventory"); continue; } // I WILL NEED TO MAKE IT THAT YOU CAN CHANGE THE ITEMS else if (args[i].ToLower() == "name") { continue; } // I WILL NEED TO MAKE IT THAT YOU CAN CHANGE THE NAME else { FieldInfo cachedField = GetKitField(args[i]); if (cachedField == null) { SendReply(player, string.Format("{0} is not a valid argument", args[i])); continue; } object editvalue; switch (args[i + 1].ToLower()) { case "true": editvalue = "true"; break; case "null": case "0": case "false": case "reset": editvalue = null; break; default: editvalue = (string)args[i + 1]; break; } cachedField.SetValue(storedData.Kits[kitEditor[player]], editvalue); SendReply(player, string.Format("{0} set to {1}", cachedField.Name, editvalue == null ? "null" : editvalue)); switch (cachedField.Name) { case "permission": InitializePermissions(); break; default: break; } } } break; } SaveKits(); }
private IEnumerator UpgradeBuildingBlocks(BasePlayer player, BuildingGrade.Enum targetGrade, PermissionSettings permS, bool isAdmin) { var pay = permS.pay && !permission.UserHasPermission(player.UserIDString, PERMISSION_NO_COST); int current = 0, success = 0; var autoGrade = targetGrade == BuildingGrade.Enum.None; foreach (var buildingBlock in allBuildingBlocks) { if (buildingBlock == null || buildingBlock.IsDestroyed) { continue; } BuildingGrade.Enum grade = targetGrade; if (CheckBuildingGrade(buildingBlock, true, ref grade)) { if (!autoGrade || tempGrantedGrades.Contains(grade)) { if (TryUpgradeToGrade(buildingBlock, player, grade, pay, isAdmin)) { success++; } } } if (++current % configData.globalS.perFrame == 0) { yield return(CoroutineEx.waitForEndOfFrame); } } foreach (var item in collect) { takeOutItems[item.info.itemid] += item.amount; item.Remove(); } foreach (var entry in takeOutItems) { player.Command("note.inv " + entry.Key + " " + entry.Value * -1f); } if (player != null && player.IsConnected) { if (missingDictionary.Count > 0) { StringBuilder stringBuilder = Pool.Get <StringBuilder>(); var language = lang.GetLanguage(player.UserIDString); foreach (var entry in missingDictionary) { stringBuilder.AppendLine(Lang("MissingItemsFormat", player.UserIDString, GetItemDisplayName(language, entry.Key), entry.Value)); } var missingResources = stringBuilder.ToString(); stringBuilder.Clear(); Pool.Free(ref stringBuilder); Print(player, success > 0 ? Lang("UpgradeNotEnoughItemsSuccess", player.UserIDString, success, missingResources) : Lang("UpgradeNotEnoughItems", player.UserIDString, missingResources)); } else { Print(player, success > 0 ? Lang("FinishedUpgrade", player.UserIDString, success) : Lang("NotUpgraded", player.UserIDString)); } } collect.Clear(); takeOutItems.Clear(); missingDictionary.Clear(); }
void cmdChatHouse(NetUser player, string command, string[] args) { if (!hasAccess(player)) { SendReply(player, "You don't have access to this command"); return; } if (args.Length == 0) { SendReply(player, "/house STEAMID/name"); return; } string[] steamids; ulong teststeam; if (args.Length == 1 && args[0].Length == 17 && ulong.TryParse(args[0], out teststeam)) { steamids = new string[] { teststeam.ToString() }; } else { var tempsteamids = PlayerDatabase?.Call("FindAllPlayers", args[0]); if (tempsteamids == null) { SendReply(player, "You must have the Player Database plugin to use this plugin."); return; } steamids = (string[])tempsteamids; if (steamids.Length == 0) { SendReply(player, "No Players found."); return; } } userIDToStructure.Clear(); foreach (StructureMaster master in (List <StructureMaster>)StructureMaster.AllStructures) { if (userIDToStructure[master.ownerID] == null) { userIDToStructure[master.ownerID] = new List <StructureMaster>(); } userIDToStructure[master.ownerID].Add(master); } if (userTeleports[player] == null) { userTeleports[player] = new List <Vector3>(); } userTeleports[player].Clear(); int currentid = 0; SendReply(player, "/housetp XX => to teleport to the house by houseid."); for (int i = 0; i < steamids.Length; i++) { cachedSteamID = steamids[i]; cachedsteamid = Convert.ToUInt64(cachedSteamID); cachedName = "Unknown"; var tempname = PlayerDatabase?.Call("GetPlayerData", cachedSteamID, "name"); if (tempname != null) { cachedName = tempname.ToString(); } if (userIDToStructure[cachedsteamid] == null) { SendReply(player, string.Format("{0} - {1}: No Structures Found.", cachedSteamID, cachedName)); continue; } foreach (StructureMaster master in userIDToStructure[cachedsteamid]) { cachedVector3 = FindFirstComponent(master); userTeleports[player].Add(cachedVector3); SendReply(player, string.Format("{3} - {0} - {1}: {2}", cachedSteamID, cachedName, cachedVector3.ToString(), currentid.ToString())); currentid++; } } }