/// <summary> /// ON START WETNESS /// ON STOP WETNESS /// ON START POISON /// ON STOP POISON /// ON START RADIATION /// ON STOP RADIATION /// ON START RADIATION POISON /// ON STOP RADIATION POISON /// ON START COMFORT /// ON STOP COMFORT /// ON START BLEEDING /// ON STOP BLEEDING /// </summary> /// <param name="metabolism"></param> /// <param name="source"></param> void OnRunPlayerMetabolism(PlayerMetabolism metabolism, BaseCombatEntity source) { if (source is BasePlayer) { BasePlayer player = (BasePlayer)source; PlayerProfile profile; if (onlinePlayers.TryGetValue(player, out profile)) { if (profile.Metabolism == null) { profile.Metabolism = new ProfileMetabolism(metabolism); return; } Dictionary <string, ProfileMetabolism.MetaAction> changes = profile.Metabolism.DetectChange(metabolism); foreach (KeyValuePair <string, ProfileMetabolism.MetaAction> kvp in changes) { if (kvp.Value == ProfileMetabolism.MetaAction.Start) { Interface.CallHook("OnStart" + kvp.Key, player); } else { Interface.CallHook("OnStop" + kvp.Key, player); } } } } }
void Unloaded() { foreach (var player in BasePlayer.activePlayerList) { OnlinePlayer onlinePlayer; if (onlinePlayers.TryGetValue(player, out onlinePlayer) && onlinePlayer.View != null) { CloseBoxView(player, onlinePlayer.View); } } }
void Unloaded() { foreach (var player in BasePlayer.activePlayerList) { OnlinePlayer onlinePlayer; if (onlinePlayers.TryGetValue(player, out onlinePlayer) && onlinePlayer.View != null) { SaveProfileByUser(player.userID); CloseBank(player, onlinePlayer.View); } } }
public int GetStatistic(string statistic) { int value = 0; statistics.TryGetValue(statistic, out value); return(value); }
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); } }
private void OnPlayerSleepEnded(BasePlayer player) { if (!permission.UserHasPermission(player.UserIDString, permUse)) { return; } List <MapMarkerGenericRadius> playerMarkers; if (!_mapMarker.TryGetValue(player.userID, out playerMarkers)) { _mapMarker.Add(player.userID, playerMarkers = new List <MapMarkerGenericRadius>()); } foreach (StashContainer stash in _stashes.Where(s => s.OwnerID == player.userID)) { if (stash.IsHidden()) { MapMarkerGenericRadius marker = GetOrAddMarker(player, stash.transform.position); marker.SendUpdate(); } } }
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); }
private void Disappear(BasePlayer basePlayer, bool showNotification = true) { if (Interface.CallHook("OnVanishDisappear", basePlayer) != null) { return; } OnlinePlayer player; if (!onlinePlayers.TryGetValue(basePlayer, out player)) { player = new OnlinePlayer(); onlinePlayers[basePlayer] = player; } List <Connection> connections = new List <Connection>(); foreach (BasePlayer target in BasePlayer.activePlayerList) { if (basePlayer == target || !target.IsConnected || config.VisibleToAdmin && target.IPlayer.IsAdmin) { continue; } connections.Add(target.net.connection); } if (config.PerformanceMode) { basePlayer.limitNetworking = true; } basePlayer.syncPosition = false; HeldEntity heldEntity = basePlayer.GetHeldEntity(); if (heldEntity != null) { heldEntity.SetHeld(false); heldEntity.UpdateVisiblity_Invis(); heldEntity.SendNetworkUpdate(); } if (Net.sv.write.Start()) { Net.sv.write.PacketID(Network.Message.Type.EntityDestroy); Net.sv.write.EntityID(basePlayer.net.ID); Net.sv.write.UInt8((byte)BaseNetworkable.DestroyMode.None); Net.sv.write.Send(new SendInfo(connections)); } basePlayer.UpdatePlayerCollider(false); player.IsInvisible = true; if (player.groupSwitchTimer != null) { player.groupSwitchTimer.Destroy(); } player.groupSwitchTimer = timer.Every(5f, () => { if (basePlayer != null) { basePlayer.UpdateNetworkGroup(); } }); if (basePlayer.GetComponent <WeaponBlock>() == null && basePlayer.IPlayer.HasPermission(permAbilitiesHideWeapons)) { basePlayer.gameObject.AddComponent <WeaponBlock>(); } if (config.AppearWhileRunning && basePlayer.GetComponent <Runner>() == null) { basePlayer.gameObject.AddComponent <Runner>(); } if (config.VanishTimeout > 0f) { ulong userId = basePlayer.userID; if (timers.ContainsKey(userId)) { timers[userId].Reset(); } else { timers.Add(userId, timer.Once(config.VanishTimeout, () => { if (basePlayer != null && basePlayer.IsConnected && IsInvisible(basePlayer)) { Reappear(basePlayer); Message(basePlayer.IPlayer, "VanishTimedOut"); } timers.Remove(userId); })); } } if (!storedData.Invisible.Contains(basePlayer.userID)) { storedData.Invisible.Add(basePlayer.userID); } Subscribe(); if (config.ShowGuiIcon) { VanishGui(basePlayer); } if (showNotification) { Message(basePlayer.IPlayer, "VanishEnabled"); } }
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; } }