public void askBuild(int slot_x, int slot_y, Vector3 position, int rotation, string state, NetworkMessageInfo info) { BetterNetworkUser user = UserList.getUserFromPlayer(info.sender); int permission = UserList.getPermission(user.steamid); if (!user.player.canBuild) //TODO: disallowing build { Reference.Tell(user.networkPlayer, "You are not allowed to build. Request permission from admins!"); return; } if (!base.GetComponent <Life>().dead) // Dead hack { Inventory inventory = base.GetComponent <Inventory>(); if (ItemType.getType(inventory.items[slot_x, slot_y].id) == 17) { SpawnStructures.placeStructure(inventory.items[slot_x, slot_y].id, position, rotation, state); } } }
private void Home(CommandArgs args) { BetterNetworkUser user = args.sender; if (this.playerHomes.ContainsKey(user.steamid)) { Reference.Tell(user.networkPlayer, "You haven't got home yet. Try to set first with /sethome command"); return; } if (!this.usedHomeCommand.ContainsKey(user.steamid)) { Vector3 originalposition = user.position; Reference.Tell(user.networkPlayer, "Teleporting home... Stand still for 5 seconds."); StartCoroutine("TeleportHome", new object[] { user, originalposition }); } else { if (UnityEngine.Time.realtimeSinceStartup - this.usedHomeCommand[user.steamid] > 60f * 5 || UserList.getPermission(user.steamid) > 4L) { Vector3 originalposition = user.position; Reference.Tell(user.networkPlayer, "Teleporting home... Stand still for 5 seconds."); StartCoroutine("TeleportHome", new object[] { user, originalposition }); } else { Reference.Tell( user.networkPlayer, "You need to wait " + System.Math.Round((double)(60f * 5 - (UnityEngine.Time.realtimeSinceStartup - this.usedHomeCommand[user.steamid]))).ToString() + " more seconds before you can teleport home again."); } } }
/// <summary> /// Teleports the home. /// The object must contains the betternetworkuser and vector3 as original location! /// </summary> /// <returns>The home.</returns> /// <param name="args">Arguments.</param> private IEnumerator TeleportHome(object[] args) { Debug.Log("Teleport home coroutine started!"); BetterNetworkUser user = (BetterNetworkUser)args[0]; Vector3 originalPosition = (Vector3)args[1]; int i = 10; bool result = false; while (i > 0) { if (!user.position.Equals(originalPosition)) { Reference.Tell(user.networkPlayer, "Teleportation cancelled"); result = false; break; } if (i % 2 == 0) { NetworkManager.error("Teleporting to home in " + i / 2 + " seconds...", "Textures/Skills/survivalist", user.networkPlayer); } i--; yield return(new WaitForSeconds(0.5f)); } if (user.position.Equals(originalPosition)) { this.teleportUserTo(user, this.playerHomes[user.steamid]); Reference.Tell(user.networkPlayer, "Teleported home."); NetworkEvents.triggerOnRegionUpdate(); this.usedHomeCommand[user.steamid] = UnityEngine.Time.realtimeSinceStartup; yield return(result); } yield return(false); }
private void OnPlayerDisconnected(NetworkPlayer networkplayer) { BetterNetworkUser player = UserList.getUserFromPlayer(networkplayer); Logger.NetworkChatLog($"(local) IP: {networkplayer.ipAddress}:{networkplayer.port}, {player.name} Disconnected"); }
public virtual void Additional(BetterNetworkUser user) { }
public static void Airdrop() { int loc = Random.RandomRange(1, 13); string arg = string.Empty; string string_ = string.Empty; string str = string.Empty; Vector3 val = default(Vector3); val = new Vector3(0f, 0f, 0f); switch (loc) { case 1: arg = "Airdrop will fall to the Summerside Peninsula"; string_ = "Airdop was fallen on Summerside Peninsula!"; val = new Vector3(790f, 24f, -450f); str = "Take airdrop on Summerside Peninsula"; break; case 2: arg = "Airdrop will fall to the Burywood"; string_ = "Airdrop was fallen on Burywood!"; val = new Vector3(50f, 23f, 700f); str = "Take airdrop on BuryWood"; break; case 3: arg = "Airdrop will fall to the Courtin Island"; string_ = "Airdrop was fallen on Courtin Island!"; val = new Vector3(890f, 22f, 500f); str = "Take airdrop on Courtin Island"; break; case 4: arg = "Airdrop will fall to the Belfast Airport"; string_ = "Airdrop was fallen on Belfast Airport!"; val = new Vector3(600f, 25f, 468f); str = "Take airdrop on Belfast Airport"; break; case 5: arg = "Airdrop will fall to the Holman Island"; string_ = "Airdrop was fallen on Holman Island!"; val = new Vector3(-770f, 29f, -760f); str = "Take airdrop on Holman Island"; break; case 6: arg = "Airdrop will fall to the O'Leary Military Base"; string_ = "Airdrop was fallen on O'Leary Military Base!"; val = new Vector3(-440f, 26f, 607f); str = "Take airdrop on Military Base"; break; case 7: arg = "Airdrop will fall to the Alberton"; string_ = "Airdrop was fallen on Alberton!"; val = new Vector3(-580f, 19f, 87f); str = "Take airdrop on Alberton"; break; case 8: arg = "Airdrop will fall to the Charlottetown"; string_ = "Airdrop was fallen on Charlottetown!"; val = new Vector3(22f, 18f, -432f); str = "Take airdrop on Charlottetown"; break; case 9: arg = "Airdrop will fall to the Montague"; string_ = "Airdrop was fallen on Montague!"; val = new Vector3(250f, 30f, -100f); str = "Take airdrop on Montague"; break; case 10: arg = "Airdrop will fall to the Oultons Isle"; string_ = "Airdrop was fallen on Oultons Isle!"; val = new Vector3(200f, 28f, -825f); str = "Take airdrop on Oultons Isle"; break; case 11: arg = "Airdrop will fall to the St. Peter's Island"; string_ = "Airdrop was fallen on St. Peter's Island!"; val = new Vector3(-245.4355f, 27.7f, 47.64797f); str = "Take airdrop on St. Peter's Island"; break; case 12: arg = "Airdrop will fall to the Fernwood Farm"; string_ = "Airdrop was fallen on Fernwood Farm!"; val = new Vector3(-244.4423f, 25.5f, -376.0898f); str = "Take airdrop on Fernwood Farm"; break; case 13: arg = "Airdrop will fall to the Wiltshire Farm"; string_ = "Airdrop was fallen on Wiltshire Farm!"; val = new Vector3(-451.6884f, 27.3f, -563.936f); str = "Take airdrop on Wiltishire Farm"; break; } for (int i = 5; i >= 1; i--) { NetworkChat.sendAlert($"{arg} after {i} min"); Thread.Sleep(60000); } NetworkChat.sendAlert(string_); for (int i = 0; i < itemAmountForDrop; i++) { int int_ = items[Random.Range(0, items.Length)]; float num3 = Random.Range(0, 5); float num4 = Random.Range(0, 5); SpawnItems.spawnItem(int_, 1, new Vector3(val.x + num3, val.y, val.z + num4)); } NetworkSounds.askSoundMax("Sounds/spooky/spooky_3", val, 500f, 1f, 700f, 3500f); for (int num5 = 1000; num5 > 0; num5--) { if (announceWhilePlayerTook) { for (int j = 0; j < UserList.users.Count; j++) { BetterNetworkUser val2 = UserList.users[j]; float num6 = Mathf.Abs(Vector3.Distance(val, val2.position)); if (num6 < 10.5f) { NetworkChat.sendAlert(val2.name + " " + str); NetworkSounds.askSoundMax("Sounds/spooky/spooky_0", val, 500f, 1f, 700f, 3500f); return; } } } if (enableEffects) { int num7 = 0; for (int k = 0; k < 25; k++) { NetworkEffects.askEffect("Effects/sparksRed", new Vector3(val.x, val.y + (float)num7, val.z), Quaternion.Euler(-90f, 0f, 0f), 100f); num7 += 2; } NetworkSounds.askSound("Sounds/projectiles/smoke", val, 500f, 1f, 700f); } Thread.Sleep(300); } }
/// <summary> /// Delays the receiving enabled. /// </summary> /// <returns>Enumerator for coroutine.</returns> /// <param name="user">User.</param> private IEnumerator DelayReceivingEnabled(BetterNetworkUser user) { yield return(new WaitForSeconds(2)); Network.SetReceivingEnabled(user.networkPlayer, 0, true); }
private void Kick(string name, string reason) { BetterNetworkUser userFromName = UserList.getUserFromName(name); NetworkTools.kick(userFromName.networkPlayer, reason); }
public override void Additional(BetterNetworkUser user) { Reference.Tell(user.networkPlayer, "Added 100 experience to you."); user.player.GetComponent <Skills> ().learn(50); // 2x xp becouse activated gold feature }