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(); }
private void Start() { secondary = Spawn(tr.position); secondary.SetParent(primary); secondary.transform.localPosition = Vector3.zero; secondary.transform.localRotation = Quaternion.Euler(0f, 180f, 0f); SetSignImages(primary); SetSignImages(secondary); primary.SendNetworkUpdate(BasePlayer.NetworkQueue.Update); secondary.SendNetworkUpdate(BasePlayer.NetworkQueue.Update); primary.gameObject.layer = (int)Rust.Layer.Reserved1; boxCollider = primary.gameObject.AddComponent <BoxCollider>(); boxCollider.size = new Vector3(1.2f, 2f, 1f); boxCollider.center = new Vector3(0f, 1.1f, 0f); boxCollider.isTrigger = true; }
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(); }
IEnumerator WaitForRequest(WWW www, QueueItem info) { yield return(www); BasePlayer player = info.sender; if (www.error == null) { if (www.size <= MaxSize) { Signage sign = info.sign; if (sign.textureID > 0U) { FileStorage.server.Remove(sign.textureID, FileStorage.Type.png); } sign.textureID = FileStorage.server.Store(www.bytes, FileStorage.Type.png); sign.SendNetworkUpdate(BasePlayer.NetworkQueue.Update); player.ChatMessage(Loaded); if (ConsoleLog) { ServerConsole.PrintColoured(System.ConsoleColor.DarkYellow, ConsoleLogMsg .Replace("{steam}", player.userID.ToString()) .Replace("{name}", player.displayName) .Replace("{id}", sign.textureID.ToString()) .Replace("{url}", info.url)); } } else { player.ChatMessage(SizeError); CoolDowns.Remove(player); } } else { player.ChatMessage(Error.Replace("{error}", www.error)); CoolDowns.Remove(player); } ActiveLoads--; if (QueueList.Count > 0) { Next(); } }
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(); } }
void sil(BasePlayer player, string command, string[] args) { if (args.Length > 0) { float cd; if (CoolDowns.TryGetValue(player, out cd) && cd > Time.realtimeSinceStartup && !HasPerm(player, "sil_cd")) { player.ChatMessage(CooldownMsg.Replace("{time}", ToReadableString(cd - Time.realtimeSinceStartup))); return; } RaycastHit hit; if (Physics.Raycast(player.eyes.Ray(), out hit, MaxDist)) { Signage sign = hit.transform.GetComponentInParent <Signage>(); if (sign != null) { if (player.CanBuild() || HasPerm(player, "sil_owner")) { if (args.Length > 1 && args[0] == "s") { if (HasPerm(player, "sil_storage")) { uint result; if (UInt32.TryParse(args[1], out result)) { if (FileStorage.server.Exists(result, FileStorage.Type.png)) { if (sign.textureID > 0U) { FileStorage.server.Remove(sign.textureID, FileStorage.Type.png); } sign.textureID = FileStorage.server.Store((byte[])getFileData.Invoke(FileStorage.server, new object[] { result, FileStorage.Type.png }), FileStorage.Type.png); sign.SendNetworkUpdate(BasePlayer.NetworkQueue.Update); player.ChatMessage(Loaded); CoolDowns[player] = Time.realtimeSinceStartup + StorageCooldown; } else { player.ChatMessage(NotExists); } } else { player.ChatMessage(Syntax); } } else { player.ChatMessage(NoPerm); } } else if (HasPerm(player, "sil_url")) { UWeb.Add(args[0], player, sign); player.ChatMessage(AddedToQueue); CoolDowns[player] = Time.realtimeSinceStartup + UrlCooldown; } else { player.ChatMessage(NoPerm); } } else { player.ChatMessage(NotYourSign); } return; } } player.ChatMessage(NoSignFound); } else { player.ChatMessage(Syntax); } }