void OnPlayerInit(BasePlayer player) { if (deadPlayers.Remove(player.userID) && storedData.DeadPlayers.RemoveWhere(info => info.GetUserId() == player.userID) > 0) { dataChanged = true; } }
private void OnPlayerSleep(BasePlayer player) { if (sleepers.ContainsKey(player.UserIDString)) { sleepers.Remove(player.UserIDString); } sleepers.Add(player.UserIDString, Timestamp); }
private void OnEntityKill(BaseNetworkable networkable) { Signage signage = networkable.GetComponent <Signage>(); if (signage != null) { if (signRegisteredSkulls.ContainsKey(signage)) { signRegisteredSkulls.Remove(signage); } } }
void UpdateSleepers() { foreach (var sleeper in BasePlayer.sleepingPlayerList) { if (!sleepers.ContainsKey(sleeper.UserIDString)) { sleepers.Add(sleeper.UserIDString, Timestamp); } else { sleepers.Remove(sleeper.UserIDString); } } }
private void OnPlayerDisconnect(PlayerSession session) { if (players.ContainsKey(session)) { players.Remove(session); } }
void DisableGodmode(BasePlayer player) { storedData.Gods.RemoveWhere(info => info.UserId == player.UserIDString); gods.Remove(player.UserIDString); ModifyMetabolism(player, false); displayName.SetValue(player, player.displayName.Replace(prefixFormat, "").Trim()); }
void DeleteBan(string targetID) { storedData.BanLogs.Remove(banLogs[targetID]); banLogs.Remove(targetID); banLogs[targetID] = null; SaveData(); UpdateBannedIPs(); }
void OnPlayerDisconnected(BasePlayer player, string reason) { if ((Boolean)Config["notifyjoin"]) { rust.BroadcastChat("[Quit]", "Goodbye: " + player.displayName); } Timers[player].Destroy(); Timers.Remove(player); }
void DisableGodmode(BasePlayer player) { storedData.Gods.RemoveWhere(info => info.GetUserId() == player.userID); gods.Remove(player.userID); ModifyMetabolism(player, false); if (playerPrefixEnabled) { player.displayName = player.displayName.Replace(playerPrefix, "").Trim(); } }
void OnPlayerDisconnected(BasePlayer player, string reason) { if (XPToAddTimers.ContainsKey(player)) { XPToAddTimers[player].Destroy(); } XPToAddTimers[player].Destroy(); Timers[player].Destroy(); Timers.Remove(player); }
private void OnEntityKill(Door door) { if (door == null || door.net == null) { return; } var doorID = door.net.ID; Timer value; if (doorTimers.TryGetValue(doorID, out value)) { value?.Destroy(); doorTimers.Remove(doorID); } foreach (var playerData in storedData.playerData.Values) { playerData.theDoorS.Remove(doorID); } }
Boolean removeonyear(String str) { if (onyear.ContainsKey(str)) { onyear.Remove(str); Puts(str + " hook removed!"); return(true); } return(false); }
Boolean removeonmonth(String str) { if (!(onmonth.ContainsKey(str))) { onmonth.Remove(str); Puts(str + " hook removed!"); return(true); } return(false); }
private void Loaded() { LoadPermissions(); LoadVariables(); lang.RegisterMessages(messages, this); playerCol = LayerMask.GetMask(new string[] { "Player (Server)" }); wallCol = LayerMask.GetMask(new string[] { "Construction" }); tTimers.Add(timer.Repeat(60f, 0, () => { DebugMessage(1, "PvP timer is launching"); DebugMessage(2, "Clearing existing items in list"); ExpiredPvPZonesList.Clear(); ExpiredRaidZonesList.Clear(); foreach (var entry in PvPList) { DebugMessage(2, "Checking a zone timestamp"); if (PvPList[entry.Key].PvPEndTimer < GetTimeStamp()) { DebugMessage(2, "Adding a zone for deletion"); ExpiredPvPZonesList.Add(entry.Key); } } foreach (var entry in raidZoneList) { DebugMessage(2, "Checking a zone timestamp"); if (raidZoneList[entry.Key].RaidEndTimer < GetTimeStamp()) { DebugMessage(2, "Adding a raid zone for deletion"); ExpiredRaidZonesList.Add(entry.Key); } } DebugMessage(2, "Checking if anything needs to be deleted"); if (ExpiredPvPZonesList.Count > 0) { foreach (Vector3 zone in ExpiredPvPZonesList) { DebugMessage(2, "PvP Zones are needed for deletion"); PvPList.Remove(zone); } } if (ExpiredRaidZonesList.Count > 0) { foreach (Vector3 zone in ExpiredRaidZonesList) { DebugMessage(2, "Raids Zones are needed for deletion"); raidZoneList.Remove(zone); } } ExpiredPvPZonesList.Clear(); ExpiredRaidZonesList.Clear(); })); }
private void OnPlayerConnected(Player player) { var sleepingplayer = sleeperdata[player.Id]; if (sleepingplayer == null) { return; } storedData.SleeperData.Remove(sleepingplayer); sleeperdata?.Remove(player.Id); }
private void PopupMessage(BasePlayer player, string msg) { var element = UI.CreateElementContainer(UIPopup, UI.Color("#2a2a2a", 0.98f), "0.33 0.45", "0.67 0.6"); UI.CreatePanel(ref element, UIPopup, UI.Color("#696969", 0.4f), "0.01 0.04", "0.99 0.96"); UI.CreateLabel(ref element, UIPopup, $"{UI.Color("#2a2a2a", 0.9f)}{msg}</color>", 22, "0 0", "1 1"); if (popupMessages.ContainsKey(player.userID)) { CuiHelper.DestroyUi(player, UIPopup); popupMessages[player.userID].Destroy(); popupMessages.Remove(player.userID); } CuiHelper.AddUi(player, element); popupMessages.Add(player.userID, timer.In(3.5f, () => { CuiHelper.DestroyUi(player, UIPopup); popupMessages.Remove(player.userID); })); }
void ResetPlayer(string id) { if (posTimer.ContainsKey(id)) { posTimer[id].Destroy(); posTimer.Remove(id); } if (lastPosition.ContainsKey(id)) { lastPosition.Remove(id); } }
void ResetPlayer(string userId) { if (afkTimer.ContainsKey(userId)) { afkTimer[userId].Destroy(); afkTimer.Remove(userId); } if (lastPosition.ContainsKey(userId)) { lastPosition.Remove(userId); } }
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); }
private void UnregisterPanel(PanelRegistration panel) { if (!_registeredPanels.ContainsKey(panel.Name)) { return; } _registeredPanels.Remove(panel.Name); string panelUiName = GetPanelUiName(panel.Name); foreach (BasePlayer player in BasePlayer.activePlayerList) { CuiHelper.DestroyUi(player, panelUiName); } _hiddenPanels[panel.Name] = null; RecalculatePositions(panel.Dock); DrawDock(BasePlayer.activePlayerList); }
void DisableGodmode(IPlayer player) { if (IsGod(player.Id)) { storedData.Gods.RemoveWhere(god => god.Id == player.Id); gods.Remove(player.Id); } ModifyMetabolism(player.Object as BasePlayer, false); if (showNamePrefix) { Rename(player, false); } if (gods.Count == 0) { Unsubscribe(nameof(CanBeWounded)); Unsubscribe(nameof(OnEntityTakeDamage)); Unsubscribe(nameof(OnRunPlayerMetabolism)); } }
private void ToggleAmmo(BasePlayer player) { if (!permission.UserHasPermission(player.userID.ToString(), "infinite.ammo")) { SendMessage(player, NotAllowed); return; } if (!HasInfiniteAmmo(player)) { var info = new InfiniteAmmoPlayer(player); storedData.Players.Add(info); players[player.userID] = info; SendMessage(player, Enabled); } else { storedData.Players.RemoveWhere(info => info.GetUserId() == player.userID); players.Remove(player.userID); SendMessage(player, Disabled); } }
void CheckIfWallLooting(Inventory inventory, NetUser netuser) { isWallLooting.Remove(netuser); inventoryLooter[inventory] = netuser; var character = netuser.playerClient.controllable.GetComponent <Character>(); if (!TraceEyes(character.eyesOrigin, character.eyesRay, Vector3NoChange, out cachedObjectname, out cachedModelname, out cachedDistance)) { return; } if (inventory.name != cachedObjectname) { return; } float distance = cachedDistance; if (TraceEyes(character.eyesOrigin, character.eyesRay, Vector3ABitLeft, out cachedObjectname, out cachedModelname, out cachedDistance)) { if (cachedDistance < distance) { if (cachedModelname.Contains("pillar") || cachedModelname.Contains("doorframe") || cachedModelname.Contains("wall")) { isWallLooting[netuser]++; } } } if (TraceEyes(character.eyesOrigin, character.eyesRay, Vector3ABitRight, out cachedObjectname, out cachedModelname, out cachedDistance)) { if (cachedDistance < distance) { if (cachedModelname.Contains("pillar") || cachedModelname.Contains("doorframe") || cachedModelname.Contains("wall")) { isWallLooting[netuser]++; } } } return; }
private void OnMessage(ObjectStreamConnection <CompilerMessage, CompilerMessage> connection, CompilerMessage message) { if (message == null) { Interface.Oxide.NextTick(() => { OnCompilerFailed("Compiler disconnected."); // TODO: Expand, warn about possible missing depdencies? Shutdown(); }); return; } switch (message.Type) { case CompilerMessageType.Assembly: var compilation = compilations[message.Id]; if (compilation == null) { Interface.Oxide.LogWarning("CSharp compiler compiled an unknown assembly!"); // TODO: Clarify? return; } compilation.endedAt = Interface.Oxide.Now; var stdOutput = (string)message.ExtraData; if (stdOutput != null) { foreach (var line in stdOutput.Split('\r', '\n')) { var match = fileErrorRegex.Match(line.Trim()); for (var i = 1; i < match.Groups.Count; i++) { var value = match.Groups[i].Value; if (value.Trim() == string.Empty) { continue; } var fileName = value.Basename(); var scriptName = fileName.Substring(0, fileName.Length - 3); var compilablePlugin = compilation.plugins.SingleOrDefault(pl => pl.ScriptName == scriptName); if (compilablePlugin == null) { Interface.Oxide.LogError("Unable to resolve script error to plugin: {0}", line); continue; } var missingRequirements = compilablePlugin.Requires.Where(name => !compilation.IncludesRequiredPlugin(name)); if (missingRequirements.Any()) { compilablePlugin.CompilerErrors = $"Missing dependencies: {missingRequirements.ToSentence()}"; } else { compilablePlugin.CompilerErrors = line.Trim().Replace(Interface.Oxide.PluginDirectory + Path.DirectorySeparatorChar, string.Empty); } } } } compilation.Completed((byte[])message.Data); compilations.Remove(message.Id); idleTimer?.Destroy(); if (AutoShutdown) { Interface.Oxide.NextTick(() => { idleTimer?.Destroy(); if (AutoShutdown) { idleTimer = Interface.Oxide.GetLibrary <Core.Libraries.Timer>().Once(60, Shutdown); } }); } break; case CompilerMessageType.Error: Interface.Oxide.LogError("Compilation error: {0}", message.Data); compilations[message.Id].Completed(); compilations.Remove(message.Id); idleTimer?.Destroy(); if (AutoShutdown) { Interface.Oxide.NextTick(() => { idleTimer?.Destroy(); idleTimer = Interface.Oxide.GetLibrary <Core.Libraries.Timer>().Once(60, Shutdown); }); } break; case CompilerMessageType.Ready: connection.PushMessage(message); if (!ready) { ready = true; while (messageQueue.Count > 0) { connection.PushMessage(messageQueue.Dequeue()); } } break; } }
private void cmdGunGameSet(BasePlayer player, string command, string[] args) { if (!player.IsAdmin && !permission.UserHasPermission(player.UserIDString, EventManager.ADMIN_PERMISSION)) { player.ChatMessage("You do not have permission to use this command"); return; } StoredData.WeaponSet weaponSet; setCreator.TryGetValue(player.userID, out weaponSet); if (args.Length == 0) { player.ChatMessage("/ggset new - Start creating a new weapon set"); player.ChatMessage("/ggset edit <name> - Edits the specified weapon set"); player.ChatMessage("/ggset delete <name> - Deletes the specified weapon set"); player.ChatMessage("/ggset list - Lists all available weapon sets"); if (weaponSet != null) { player.ChatMessage("/ggset add <opt:rank> - Adds the weapon you are holding to the weapon set. If you specify a rank the weapon will be inserted at that position"); player.ChatMessage("/ggset remove <number> - Removes the specified rank from the weapon set"); player.ChatMessage("/ggset ranks - List the weapons and ranks in the weapon set"); player.ChatMessage("/ggset save <name> - Saves the weapon set you are currently editing"); } return; } switch (args[0].ToLower()) { case "new": setCreator[player.userID] = new StoredData.WeaponSet(); player.ChatMessage("You are now creating a new weapon set"); return; case "edit": if (args.Length < 2) { player.ChatMessage("You must enter the name of a weapon set to edit"); return; } if (!storedData.TryFindWeaponSet(args[1], out weaponSet)) { player.ChatMessage("Unable to find a weapon set with the specified name"); return; } setCreator[player.userID] = weaponSet; player.ChatMessage($"You are now editing the weapon set {args[1]}"); return; case "delete": if (args.Length < 2) { player.ChatMessage("You must enter the name of a weapon set to delete"); return; } if (!storedData.TryFindWeaponSet(args[1], out weaponSet)) { player.ChatMessage("Unable to find a weapon set with the specified name"); return; } storedData._weaponSets.Remove(args[1]); SaveData(); player.ChatMessage($"You have deleted the weapon set {args[1]}"); return; case "list": player.ChatMessage($"Available weapon sets;\n{GetGunGameWeaponSets().ToSentence()}"); return; case "add": if (weaponSet == null) { player.ChatMessage("You are not currently editing a weapon set"); return; } Item item = player.GetActiveItem(); if (item == null) { player.ChatMessage("You must hold a weapon in your hands to add it to the weapon set"); return; } if (!_validWeapons.Contains(item.info.shortname)) { player.ChatMessage("This item is not an allowed weapon"); return; } int index = -1; if (args.Length == 2 && int.TryParse(args[1], out index)) { index = Mathf.Clamp(index, 1, weaponSet.Count); } int rank = weaponSet.AddItem(item, index); player.ChatMessage($"This weapon has been added at rank {rank}"); return; case "remove": if (weaponSet == null) { player.ChatMessage("You are not currently editing a weapon set"); return; } int delete; if (args.Length != 2 || !int.TryParse(args[1], out delete)) { player.ChatMessage("You must enter the rank number to remove a item"); return; } if (delete < 1 || delete > weaponSet.Count) { player.ChatMessage("The rank you entered is out of range"); return; } weaponSet.weapons.RemoveAt(delete - 1); player.ChatMessage($"You have removed the weapon at rank {delete}"); return; case "ranks": if (weaponSet == null) { player.ChatMessage("You are not currently editing a weapon set"); return; } string str = string.Empty; for (int i = 0; i < weaponSet.Count; i++) { str += $"Rank {i + 1} : {ItemManager.itemDictionary[weaponSet.weapons[i].itemid].displayName.english}\n"; } player.ChatMessage(str); return; case "save": if (weaponSet == null) { player.ChatMessage("You are not currently editing a weapon set"); return; } if (weaponSet.Count < 1) { player.ChatMessage("You have not added any weapons to this weapon set"); return; } if (args.Length != 2) { player.ChatMessage("You must enter a name for this weapon set"); return; } storedData._weaponSets[args[1]] = weaponSet; SaveData(); setCreator.Remove(player.userID); player.ChatMessage($"You have saved this weapon set as {args[1]}"); return; default: break; } }
private object OnItemPickup(Item item, BasePlayer player) { if (item != null && player != null) { ItemPlacement placement = player.GetComponent <ItemPlacement>(); if (placement != null) { return(false); } else { DroppedItem droppedItem = item.GetWorldEntity()?.GetComponent <DroppedItem>(); if (droppedItem == null) { return(null); } List <DroppedItem> skulls; if (spearRegisteredSkulls.TryGetValue(droppedItem, out skulls)) { if (skulls?.Count == 0) { if (!CanRemove(player, "Error.NoBuildingAuthSpear")) { return(false); } Pool.FreeList(ref skulls); spearRegisteredSkulls.Remove(droppedItem); } else { SendReply(player, msg("Error.SkullsOnSpear", player.userID)); return(false); } } if (droppedItem.item.info.itemid == SKULL_ITEM_ID) { Signage signage = droppedItem.GetComponentInParent <Signage>(); if (signage != null && signRegisteredSkulls.ContainsKey(signage)) { if (!CanRemove(player, "Error.NoBuildingAuthSkull")) { return(false); } signRegisteredSkulls.Remove(signage); if (signage.HasFlag(BaseEntity.Flags.Locked)) { signage.SetFlag(BaseEntity.Flags.Locked, false); } UpdateSignImage(signage, "", true); } else { if (droppedItem.HasParent()) { DroppedItem spear = droppedItem.GetParentEntity().GetComponent <DroppedItem>(); if (spear == null) { return(null); } if (spearRegisteredSkulls.TryGetValue(spear, out skulls) && skulls.Contains(droppedItem)) { if (!CanRemove(player, "Error.NoBuildingAuthSkull")) { return(false); } spearRegisteredSkulls[spear].Remove(droppedItem); } } } } } } return(null); }
void DisableThiefMode(BasePlayer player) { storedData.Thiefs.RemoveWhere(info => info.GetUserId() == player.userID); Thiefs.Remove(player.userID); }
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(); }