private void SetSignImages(Signage signage) { string hex = Team == EventManager.Team.B ? captureTheFlagEvent.TeamBColor : captureTheFlagEvent.TeamAColor; if (signImageCRC == 0) { hex = hex.TrimStart('#'); int red = int.Parse(hex.Substring(0, 2), NumberStyles.AllowHexSpecifier); int green = int.Parse(hex.Substring(2, 2), NumberStyles.AllowHexSpecifier); int blue = int.Parse(hex.Substring(4, 2), NumberStyles.AllowHexSpecifier); Color color = new Color((float)red / 255f, (float)green / 255f, (float)blue / 255f); Color[] array = new Color[256 * 256]; for (int i = 0; i < array.Length; i++) { array[i] = color; } Texture2D texture2D = new Texture2D(256, 256); texture2D.SetPixels(array); byte[] bytes = texture2D.EncodeToPNG(); Destroy(texture2D); signImageCRC = FileStorage.server.Store(bytes, FileStorage.Type.png, CommunityEntity.ServerInstance.net.ID); } Array.Resize <uint>(ref signage.textureIDs, 1); signage.textureIDs[0] = signImageCRC; signage.SetFlag(BaseEntity.Flags.Locked, true); }
private void CreateSign(IPlayer player, Signage sign, string type) { uWeb.Add(SignImage(), player, sign, type); if (!autoLock) { return; } sign.SetFlag(BaseEntity.Flags.Locked, true); sign.SendNetworkUpdate(); }
void CreateSign(BasePlayer player, Signage sign) { uWeb.Add(SignImage(), player, sign); // Prevent player edits if (!LockSigns) { return; } sign.SetFlag(BaseEntity.Flags.Locked, true); sign.SendNetworkUpdate(); }
void SignChatCmd(BasePlayer player) { if (!HasPermission(player, "deathsigns.admin")) { PrintToChat(player, NoPermission); return; } // Check for sign to use RaycastHit hit; Signage sign = null; if (Physics.Raycast(player.eyes.HeadRay(), out hit, 2f)) { sign = hit.transform.GetComponentInParent <Signage>(); } if (sign == null) { PrintToChat(player, NoSignsFound); return; } if (storedData.Signs.ContainsKey(sign.net.ID)) { PrintToChat(player, "Already a death sign!"); return; } // Create sign image var text = $"{storedData.Deaths}+{(storedData.Deaths == 1 ? "death" : "deaths")}"; const string bgColor = "ffffff"; const string textColor = "000000"; const int textSize = 80; const int width = 350; const int height = 150; var url = $"http://placeholdit.imgix.net/~text?txtsize={textSize}&txt={text}&w={width}&h={height}"; uWeb.Add(url, player, sign); // Store updated data var info = new SignData(sign); storedData.Signs.Add(sign.net.ID, info); Interface.Oxide.DataFileSystem.WriteObject(Name, storedData); // Lock sign to prevent player edits sign.SetFlag(BaseEntity.Flags.Locked, true); sign.SendNetworkUpdate(); }
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); }
public void Build(Vector3 spawnAt) { foreach (StructureComponent component in StructureComponents.Values) { Vector3 v3 = (component.LocalPosition.ToVector3() + spawnAt); BaseEntity ent = GameManager.server.CreateEntity(component.Prefab, v3, component.LocalRotation.ToQuaternion()); ent.SpawnAsMapEntity(); BuildingBlock bb = ent.GetComponent <BuildingBlock>(); bb.blockDefinition = PrefabAttribute.server.Find <Construction>(bb.prefabID); bb.grade = component.Grade; bb.health = component.Health; if (bb.HasSlot(BaseEntity.Slot.Lock)) { if (component.HasCodeLock) { BaseEntity baseEntity = GameManager.server.CreateEntity("build/locks/lock.code", Vector3.zero, new Quaternion()); baseEntity.OnDeployed(bb); if (!string.IsNullOrEmpty(component.LockCode)) { CodeLock codeLock = baseEntity.GetComponent <CodeLock>(); codeLock.SetFlag(BaseEntity.Flags.Locked, true); codeLock.SetFieldValue("code", component.LockCode); codeLock.SetFieldValue("whitelistPlayers", component.LockWList); } baseEntity.gameObject.Identity(); baseEntity.SetParent(bb, "lock"); baseEntity.Spawn(); bb.SetSlot(BaseEntity.Slot.Lock, baseEntity); } else if (component.HasKeyLock) { BaseEntity baseEntity = GameManager.server.CreateEntity("build/locks/lock.key", Vector3.zero, new Quaternion()); baseEntity.OnDeployed(bb); int code = int.Parse(component.LockCode); if ((code & 0x80) != 0) { KeyLock keyLock = baseEntity.GetComponent <KeyLock>(); keyLock.SetFieldValue("keycode", (code & 0x7F)); keyLock.SetFieldValue("firstKeyCreated", true); keyLock.SetFlag(BaseEntity.Flags.Locked, true); } baseEntity.gameObject.Identity(); baseEntity.SetParent(bb, "lock"); baseEntity.Spawn(); bb.SetSlot(BaseEntity.Slot.Lock, baseEntity); } } bb.SendNetworkUpdateImmediate(); } foreach (DeployableComponent component in DeployableComponents.Values) { Vector3 v3 = (component.LocalPosition.ToVector3() + spawnAt); BaseEntity ent = GameManager.server.CreateEntity(component.Prefab, v3, component.LocalRotation.ToQuaternion()); ent.SpawnAsMapEntity(); if (component.HasOwner) { SleepingBag sleepingBag = ent.GetComponent <SleepingBag>(); sleepingBag.deployerUserID = component.DeployedBy; sleepingBag.niceName = component.BagName; } else if (component.IsCupBoard) { BuildingPrivlidge buildingPrivlidge = ent.GetComponent <BuildingPrivlidge>(); buildingPrivlidge.authorizedPlayers = component.AuthedPlayers; } else if (component.HasStorage) { StorageContainer storageContainer = ent.GetComponent <StorageContainer>(); var items = component.ItemList; foreach (var item in items) { Item newItem = ItemManager.CreateByItemID((int)item["id"], (int)item["amount"], (bool)item["blueprint"]); newItem.MoveToContainer(storageContainer.inventory); } if (ent.HasSlot(BaseEntity.Slot.Lock)) { if (component.HasCodeLock) { BaseEntity baseEntity = GameManager.server.CreateEntity("build/locks/lock.code", Vector3.zero, new Quaternion()); baseEntity.OnDeployed(ent); if (!string.IsNullOrEmpty(component.LockCode)) { CodeLock codeLock = baseEntity.GetComponent <CodeLock>(); codeLock.SetFlag(BaseEntity.Flags.Locked, true); codeLock.SetFieldValue("code", component.LockCode); codeLock.SetFieldValue("whitelistPlayers", component.LockWList); } baseEntity.gameObject.Identity(); baseEntity.SetParent(ent, "lock"); baseEntity.Spawn(); ent.SetSlot(BaseEntity.Slot.Lock, baseEntity); } else if (component.HasKeyLock) { BaseEntity baseEntity = GameManager.server.CreateEntity("build/locks/lock.key", Vector3.zero, new Quaternion()); baseEntity.OnDeployed(ent); int code = int.Parse(component.LockCode); if ((code & 0x80) != 0) { KeyLock keyLock = baseEntity.GetComponent <KeyLock>(); keyLock.SetFieldValue("keycode", (code & 0x7F)); keyLock.SetFieldValue("firstKeyCreated", true); keyLock.SetFlag(BaseEntity.Flags.Locked, true); } baseEntity.gameObject.Identity(); baseEntity.SetParent(ent, "lock"); baseEntity.Spawn(); ent.SetSlot(BaseEntity.Slot.Lock, baseEntity); } } } else if (component.HasPainting) { Signage signage = ent.GetComponent <Signage>(); if (component.Painting != null) { byte[] painting = component.Painting; signage.textureID = FileStorage.server.Store(painting, FileStorage.Type.png, signage.net.ID); } if (component.PaintingLocked) { signage.SetFlag(BaseEntity.Flags.Locked, true); } signage.SendNetworkUpdate(); } ent.SendNetworkUpdateImmediate(); } foreach (SpawnableComponent component in SpawnableComponents.Values) { Vector3 v3 = (component.LocalPosition.ToVector3() + spawnAt); BaseEntity ent = GameManager.server.CreateEntity(component.Prefab, v3, component.LocalRotation.ToQuaternion()); ent.SpawnAsMapEntity(); ent.SendNetworkUpdateImmediate(); } }