public override void Use(Player p, string message) { if (!p.canBuild) { Player.SendMessage(p, "You're currently being &4possessed" + Server.DefaultColor + "!"); return; } try { bool stealth = false; if (message != "") { if (message == "#") { if (p.following != "") { stealth = true; message = ""; } else { Help(p); return; } } else if (message.IndexOf(' ') != -1) { if (message.Split(' ')[0] == "#") { if (p.hidden) stealth = true; message = message.Split(' ')[1]; } } } Player who = Player.Find(message); if (message == "" && p.following == "") { Help(p); return; } else if (message == "" && p.following != "" || message == p.following) { who = Player.Find(p.following); p.following = ""; if (p.hidden) { if (who != null) p.SendSpawn(who.id, who.color + who.name, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1]); if (!stealth) { Command.all.Find("hide").Use(p, ""); } else { if (who != null) { Player.SendMessage(p, "You have stopped following " + who.color + who.name + Server.DefaultColor + " and remained hidden."); } else { Player.SendMessage(p, "Following stopped."); } } return; } } if (who == null) { Player.SendMessage(p, "Could not find player."); return; } else if (who == p) { Player.SendMessage(p, "Cannot follow yourself."); return; } else if (who.group.Permission >= p.group.Permission) { Player.SendMessage(p, "Cannot follow someone of equal or greater rank."); return; } else if (who.following != "") { Player.SendMessage(p, who.name + " is already following " + who.following); return; } if (!p.hidden) Command.all.Find("hide").Use(p, ""); if (p.level != who.level) Command.all.Find("tp").Use(p, who.name); if (p.following != "") { who = Player.Find(p.following); p.SendSpawn(who.id, who.color + who.name, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1]); } who = Player.Find(message); p.following = who.name; Player.SendMessage(p, "Following " + who.name + ". Use \"/follow\" to stop."); p.SendDie(who.id); } catch (Exception e) { Server.ErrorLog(e); Player.SendMessage(p, "Error occured"); } }
public override void Use(Player p, string message) { if (message == "") { Help(p); return; } try { Level foundLevel = Level.Find(message); if (foundLevel != null) { Level startLevel = p.level; GC.Collect(); if (p.level == foundLevel) { Player.SendMessage(p, "You are already in \"" + foundLevel.name + "\"."); return; } if (!p.ignorePermission) { if (p.group.Permission < foundLevel.permissionvisit) { Player.SendMessage(p, "You're not allowed to go to " + foundLevel.name + "."); return; } } p.Loading = true; foreach (Player pl in Player.players) { if (p.level == pl.level && p != pl) { p.SendDie(pl.id); } } foreach (PlayerBot b in PlayerBot.playerbots) { if (p.level == b.level) { p.SendDie(b.id); } } Player.GlobalDie(p, true); p.level = foundLevel; p.SendUserMOTD(); p.SendMap(); GC.Collect(); ushort x = (ushort)((0.5 + foundLevel.spawnx) * 32); ushort y = (ushort)((1 + foundLevel.spawny) * 32); ushort z = (ushort)((0.5 + foundLevel.spawnz) * 32); if (!p.hidden) { Player.GlobalSpawn(p, x, y, z, foundLevel.rotx, foundLevel.roty, true); } else { unchecked { p.SendPos((byte)-1, x, y, z, foundLevel.rotx, foundLevel.roty); } } foreach (Player pl in Player.players) { if (pl.level == p.level && p != pl && !pl.hidden) { p.SendSpawn(pl.id, pl.color + pl.name, pl.pos[0], pl.pos[1], pl.pos[2], pl.rot[0], pl.rot[1]); } } foreach (PlayerBot b in PlayerBot.playerbots) { if (b.level == p.level) { p.SendSpawn(b.id, b.color + b.name, b.pos[0], b.pos[1], b.pos[2], b.rot[0], b.rot[1]); } } if (!p.hidden) { Player.GlobalChat(p, p.color + "*" + p.name + Server.DefaultColor + " went to &b" + foundLevel.name, false); } p.Loading = false; bool skipUnload = false; if (startLevel.unload && !startLevel.name.Contains("&cMuseum ")) { foreach (Player pl in Player.players) { if (pl.level == startLevel) { skipUnload = true; } } if (!skipUnload && Server.AutoLoad) { startLevel.Unload(); } } } else if (Server.AutoLoad) { Command.all.Find("load").Use(p, message); foundLevel = Level.Find(message); if (foundLevel != null) { Use(p, message); } } else { Player.SendMessage(p, "There is no level \"" + message + "\" loaded."); } GC.Collect(); GC.WaitForPendingFinalizers(); } catch (Exception e) { Server.ErrorLog(e); } }
public override void Use(Player p, string message) { if (message == "") { Help(p); return; } try { Level foundLevel = Level.Find(message); if (foundLevel != null) { Level startLevel = p.level; GC.Collect(); if (p.level == foundLevel) { Player.SendMessage(p, "You are already in \"" + foundLevel.name + "\"."); return; } if (!p.ignorePermission) if (p.group.Permission < foundLevel.permissionvisit) { Player.SendMessage(p, "You're not allowed to go to " + foundLevel.name + "."); return; } if (foundLevel.locked) { Player.SendMessage(p, "\"" + foundLevel.name + "\" is locked!"); return; } p.Loading = true; foreach (Player pl in Player.players) if (p.level == pl.level && p != pl) p.SendDie(pl.id); foreach (PlayerBot b in PlayerBot.playerbots) if (p.level == b.level) p.SendDie(b.id); Player.GlobalDie(p, true); p.level = foundLevel; p.SendUserMOTD(); p.SendMap(); GC.Collect(); ushort x = (ushort)((0.5 + foundLevel.spawnx) * 32); ushort y = (ushort)((1 + foundLevel.spawny) * 32); ushort z = (ushort)((0.5 + foundLevel.spawnz) * 32); if (!p.hidden) Player.GlobalSpawn(p, x, y, z, foundLevel.rotx, foundLevel.roty, true); else unchecked { p.SendPos((byte)-1, x, y, z, foundLevel.rotx, foundLevel.roty); } foreach (Player pl in Player.players) if (pl.level == p.level && p != pl && !pl.hidden) p.SendSpawn(pl.id, pl.color + pl.name, pl.pos[0], pl.pos[1], pl.pos[2], pl.rot[0], pl.rot[1]); foreach (PlayerBot b in PlayerBot.playerbots) if (b.level == p.level) p.SendSpawn(b.id, b.color + b.name, b.pos[0], b.pos[1], b.pos[2], b.rot[0], b.rot[1]); if (!p.hidden) Player.GlobalChat(p, p.color + "*" + p.name + Server.DefaultColor + " went to &b" + foundLevel.name, false); p.Loading = false; bool skipUnload = false; if (startLevel.unload && !startLevel.name.Contains("&cMuseum ")) { foreach (Player pl in Player.players) if (pl.level == startLevel) skipUnload = true; if (!skipUnload && Server.AutoLoad) startLevel.Unload(); } } else if (Server.AutoLoad) { Command.all.Find("load").Use(p, message); foundLevel = Level.Find(message); if (foundLevel != null) Use(p, message); } else Player.SendMessage(p, "There is no level \"" + message + "\" loaded."); GC.Collect(); GC.WaitForPendingFinalizers(); } catch (Exception e) { Server.ErrorLog(e); } }
public override void Use(Player p, string message) { string path; if (message.Split(' ').Length == 1) { path = "levels/" + message + ".lvl"; } else if (message.Split(' ').Length == 2) { try { path = @Server.backupLocation + "/" + message.Split(' ')[0] + "/" + int.Parse(message.Split(' ')[1]) + "/" + message.Split(' ')[0] + ".lvl"; } catch { Help(p); return; } } else { Help(p); return; } if (File.Exists(path)) { FileStream fs = File.OpenRead(path); try { GZipStream gs = new GZipStream(fs, CompressionMode.Decompress); byte[] ver = new byte[2]; gs.Read(ver, 0, ver.Length); ushort version = BitConverter.ToUInt16(ver, 0); Level level; if (version == 1874) { byte[] header = new byte[16]; gs.Read(header, 0, header.Length); ushort width = BitConverter.ToUInt16(header, 0); ushort height = BitConverter.ToUInt16(header, 2); ushort depth = BitConverter.ToUInt16(header, 4); level = new Level(name, width, depth, height, "empty"); level.spawnx = BitConverter.ToUInt16(header, 6); level.spawnz = BitConverter.ToUInt16(header, 8); level.spawny = BitConverter.ToUInt16(header, 10); level.rotx = header[12]; level.roty = header[13]; } else { byte[] header = new byte[12]; gs.Read(header, 0, header.Length); ushort width = version; ushort height = BitConverter.ToUInt16(header, 0); ushort depth = BitConverter.ToUInt16(header, 2); level = new Level(name, width, depth, height, "grass"); level.spawnx = BitConverter.ToUInt16(header, 4); level.spawnz = BitConverter.ToUInt16(header, 6); level.spawny = BitConverter.ToUInt16(header, 8); level.rotx = header[10]; level.roty = header[11]; } level.setPhysics(0); byte[] blocks = new byte[level.width * level.height * level.depth]; gs.Read(blocks, 0, blocks.Length); level.blocks = blocks; gs.Close(); level.backedup = true; level.permissionbuild = LevelPermission.Admin; level.jailx = (ushort)(level.spawnx * 32); level.jaily = (ushort)(level.spawny * 32); level.jailz = (ushort)(level.spawnz * 32); level.jailrotx = level.rotx; level.jailroty = level.roty; p.Loading = true; foreach (Player pl in Player.players) { if (p.level == pl.level && p != pl) { p.SendDie(pl.id); } } foreach (PlayerBot b in PlayerBot.playerbots) { if (p.level == b.level) { p.SendDie(b.id); } } Player.GlobalDie(p, true); p.level = level; p.SendMotd(); p.SendRaw(2); byte[] buffer = new byte[level.blocks.Length + 4]; BitConverter.GetBytes(IPAddress.HostToNetworkOrder(level.blocks.Length)).CopyTo(buffer, 0); //ushort xx; ushort yy; ushort zz; for (int i = 0; i < level.blocks.Length; ++i) { buffer[4 + i] = Block.Convert(level.blocks[i]); } buffer = Player.GZip(buffer); int number = (int)Math.Ceiling(((double)buffer.Length) / 1024); for (int i = 1; buffer.Length > 0; ++i) { short length = (short)Math.Min(buffer.Length, 1024); byte[] send = new byte[1027]; Player.HTNO(length).CopyTo(send, 0); Buffer.BlockCopy(buffer, 0, send, 2, length); byte[] tempbuffer = new byte[buffer.Length - length]; Buffer.BlockCopy(buffer, length, tempbuffer, 0, buffer.Length - length); buffer = tempbuffer; send[1026] = (byte)(i * 100 / number); p.SendRaw(3, send); Thread.Sleep(10); } buffer = new byte[6]; Player.HTNO((short)level.width).CopyTo(buffer, 0); Player.HTNO((short)level.depth).CopyTo(buffer, 2); Player.HTNO((short)level.height).CopyTo(buffer, 4); p.SendRaw(4, buffer); ushort x = (ushort)((0.5 + level.spawnx) * 32); ushort y = (ushort)((1 + level.spawny) * 32); ushort z = (ushort)((0.5 + level.spawnz) * 32); p.aiming = false; Player.GlobalSpawn(p, x, y, z, level.rotx, level.roty, true); p.ClearBlockchange(); p.Loading = false; if (message.IndexOf(' ') == -1) { level.name = "&cMuseum " + Server.DefaultColor + "(" + message.Split(' ')[0] + ")"; } else { level.name = "&cMuseum " + Server.DefaultColor + "(" + message.Split(' ')[0] + " " + message.Split(' ')[1] + ")"; } if (!p.hidden) { Player.GlobalChat(null, p.color + p.prefix + p.name + Server.DefaultColor + " went to the " + level.name, false); } GC.Collect(); GC.WaitForPendingFinalizers(); } catch (Exception ex) { Player.SendMessage(p, "Error loading level."); Server.ErrorLog(ex); return; } finally { fs.Close(); } } else { Player.SendMessage(p, "Level or backup could not be found."); return; } }
public override void Use(Player p, string message) { if (message == "") { message = p.name; } if (message.ToLower() == "all") { if (p.group.Permission < LevelPermission.Operator) { Player.SendMessage(p, "Reserved for OP+"); return; } foreach (Player who in Player.players) { if (who.level == p.level) { who.Loading = true; foreach (Player pl in Player.players) { if (who.level == pl.level && who != pl) { who.SendDie(pl.id); } } foreach (PlayerBot b in PlayerBot.playerbots) { if (who.level == b.level) { who.SendDie(b.id); } } Player.GlobalDie(who, true); who.SendUserMOTD(); who.SendMap(); ushort x = (ushort)((0.5 + who.level.spawnx) * 32); ushort y = (ushort)((1 + who.level.spawny) * 32); ushort z = (ushort)((0.5 + who.level.spawnz) * 32); if (!who.hidden) { Player.GlobalSpawn(who, x, y, z, who.level.rotx, who.level.roty, true); } else { unchecked { who.SendPos((byte)-1, x, y, z, who.level.rotx, who.level.roty); } } foreach (Player pl in Player.players) { if (pl.level == who.level && who != pl && !pl.hidden) { who.SendSpawn(pl.id, pl.color + pl.name, pl.pos[0], pl.pos[1], pl.pos[2], pl.rot[0], pl.rot[1]); } } foreach (PlayerBot b in PlayerBot.playerbots) { if (b.level == who.level) { who.SendSpawn(b.id, b.color + b.name, b.pos[0], b.pos[1], b.pos[2], b.rot[0], b.rot[1]); } } who.Loading = false; who.SendMessage("&bMap reloaded by " + p.name); Player.SendMessage(p, "&4Finished reloading for " + who.name); /* * foreach (Player pl in Player.players) if (who.level == pl.level && who != pl) who.SendDie(pl.id); * foreach (PlayerBot b in PlayerBot.playerbots) if (who.level == b.level) who.SendDie(b.id); * Player.GlobalDie(who, true); * * who.SendMap(); * * ushort x = (ushort)((0.5 + who.level.spawnx) * 32); * ushort y = (ushort)((1 + who.level.spawny) * 32); * ushort z = (ushort)((0.5 + who.level.spawnz) * 32); * * Player.GlobalSpawn(who, x, y, z, who.level.rotx, who.level.roty, true); * * foreach (Player pl in Player.players) * if (pl.level == who.level && who != pl && !pl.hidden) * who.SendSpawn(pl.id, pl.color + pl.name, pl.pos[0], pl.pos[1], pl.pos[2], pl.rot[0], pl.rot[1]); * * foreach (PlayerBot b in PlayerBot.playerbots) * if (b.level == who.level) * who.SendSpawn(b.id, b.color + b.name, b.pos[0], b.pos[1], b.pos[2], b.rot[0], b.rot[1]); * * who.SendMessage("Map reloaded."); */ } } GC.Collect(); GC.WaitForPendingFinalizers(); } else { Player who = Player.Find(message); if (who == null) { Player.SendMessage(p, "Could not find player."); return; } else if (who.group.Permission > p.group.Permission && p != who) { Player.SendMessage(p, "Cannot reload the map of someone higher than you."); return; } who.Loading = true; foreach (Player pl in Player.players) { if (who.level == pl.level && who != pl) { who.SendDie(pl.id); } } foreach (PlayerBot b in PlayerBot.playerbots) { if (who.level == b.level) { who.SendDie(b.id); } } Player.GlobalDie(who, true); who.SendUserMOTD(); who.SendMap(); ushort x = (ushort)((0.5 + who.level.spawnx) * 32); ushort y = (ushort)((1 + who.level.spawny) * 32); ushort z = (ushort)((0.5 + who.level.spawnz) * 32); if (!who.hidden) { Player.GlobalSpawn(who, x, y, z, who.level.rotx, who.level.roty, true); } else { unchecked { who.SendPos((byte)-1, x, y, z, who.level.rotx, who.level.roty); } } foreach (Player pl in Player.players) { if (pl.level == who.level && who != pl && !pl.hidden) { who.SendSpawn(pl.id, pl.color + pl.name, pl.pos[0], pl.pos[1], pl.pos[2], pl.rot[0], pl.rot[1]); } } foreach (PlayerBot b in PlayerBot.playerbots) { if (b.level == who.level) { who.SendSpawn(b.id, b.color + b.name, b.pos[0], b.pos[1], b.pos[2], b.rot[0], b.rot[1]); } } who.Loading = false; GC.Collect(); GC.WaitForPendingFinalizers(); who.SendMessage("&bMap reloaded by " + p.name); Player.SendMessage(p, "&4Finished reloading for " + who.name); /* * foreach (Player pl in Player.players) if (who.level == pl.level && who != pl) who.SendDie(pl.id); * foreach (PlayerBot b in PlayerBot.playerbots) if (who.level == b.level) who.SendDie(b.id); * Player.GlobalDie(who, true); * * who.SendMap(); * * ushort x = (ushort)((0.5 + who.level.spawnx) * 32); * ushort y = (ushort)((1 + who.level.spawny) * 32); * ushort z = (ushort)((0.5 + who.level.spawnz) * 32); * * Player.GlobalSpawn(who, x, y, z, who.level.rotx, who.level.roty, true); * * foreach (Player pl in Player.players) * if (pl.level == who.level && who != pl && !pl.hidden) * who.SendSpawn(pl.id, pl.color + pl.name, pl.pos[0], pl.pos[1], pl.pos[2], pl.rot[0], pl.rot[1]); * * foreach (PlayerBot b in PlayerBot.playerbots) * if (b.level == who.level) * who.SendSpawn(b.id, b.color + b.name, b.pos[0], b.pos[1], b.pos[2], b.rot[0], b.rot[1]); * * who.SendMessage("Map reloaded."); */ } }
public override void Use(Player p, string message) { if (!p.canBuild) { Player.SendMessage(p, "You're currently being &4possessed" + Server.DefaultColor + "!"); return; } try { bool stealth = false; if (message != "") { if (message == "#") { if (p.following != "") { stealth = true; message = ""; } else { Help(p); return; } } else if (message.IndexOf(' ') != -1) { if (message.Split(' ')[0] == "#") { if (p.hidden) { stealth = true; } message = message.Split(' ')[1]; } } } Player who = Player.Find(message); if (message == "" && p.following == "") { Help(p); return; } else if (message == "" && p.following != "" || message == p.following) { who = Player.Find(p.following); p.following = ""; if (p.hidden) { if (who != null) { p.SendSpawn(who.id, who.color + who.name, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1]); } if (!stealth) { Command.all.Find("hide").Use(p, ""); } else { if (who != null) { Player.SendMessage(p, "You have stopped following " + who.color + who.name + Server.DefaultColor + " and remained hidden."); } else { Player.SendMessage(p, "Following stopped."); } } return; } } if (who == null) { Player.SendMessage(p, "Could not find player."); return; } else if (who == p) { Player.SendMessage(p, "Cannot follow yourself."); return; } else if (who.group.Permission >= p.group.Permission) { Player.SendMessage(p, "Cannot follow someone of equal or greater rank."); return; } else if (who.following != "") { Player.SendMessage(p, who.name + " is already following " + who.following); return; } if (!p.hidden) { Command.all.Find("hide").Use(p, ""); } if (p.level != who.level) { Command.all.Find("tp").Use(p, who.name); } if (p.following != "") { who = Player.Find(p.following); p.SendSpawn(who.id, who.color + who.name, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1]); } who = Player.Find(message); p.following = who.name; Player.SendMessage(p, "Following " + who.name + ". Use \"/follow\" to stop."); p.SendDie(who.id); } catch (Exception e) { Server.ErrorLog(e); Player.SendMessage(p, "Error occured"); } }
public override void Use(Player p, string message) { if (message.Split(' ').Length > 2) { Help(p); return; } if (p == null) { Player.SendMessage(p, "Console possession? Nope.avi."); return; } try { string skin = (message.Split(' ').Length == 2) ? message.Split(' ')[1] : ""; message = message.Split(' ')[0]; if (message == "") { if (p.possess == "") { Help(p); return; } else { Player who = Player.Find(p.possess); if (who == null) { p.possess = ""; Player.SendMessage(p, "Possession disabled."); return; } who.following = ""; who.canBuild = true; p.possess = ""; if (!who.MarkPossessed()) { return; } p.invincible = false; Command.all.Find("hide").Use(p, ""); Player.SendMessage(p, "Stopped possessing " + who.color + who.name + Server.DefaultColor + "."); return; } } else if (message == p.possess) { Player who = Player.Find(p.possess); if (who == null) { p.possess = ""; Player.SendMessage(p, "Possession disabled."); return; } if (who == p) { Player.SendMessage(p, "Cannot possess yourself!"); return; } who.following = ""; who.canBuild = true; p.possess = ""; if (!who.MarkPossessed()) { return; } p.invincible = false; Command.all.Find("hide").Use(p, ""); Player.SendMessage(p, "Stopped possessing " + who.color + who.name + Server.DefaultColor + "."); return; } else { Player who = Player.Find(message); if (who == null) { Player.SendMessage(p, "Could not find player."); return; } if (who.group.Permission >= p.group.Permission) { Player.SendMessage(p, "Cannot possess someone of equal or greater rank."); return; } if (who.possess != "") { Player.SendMessage(p, "That player is currently possessing someone!"); return; } if (who.following != "") { Player.SendMessage(p, "That player is either following someone or already possessed."); return; } if (p.possess != "") { Player oldwho = Player.Find(p.possess); if (oldwho != null) { oldwho.following = ""; oldwho.canBuild = true; if (!oldwho.MarkPossessed()) { return; } //p.SendSpawn(oldwho.id, oldwho.color + oldwho.name, oldwho.pos[0], oldwho.pos[1], oldwho.pos[2], oldwho.rot[0], oldwho.rot[1]); } } Command.all.Find("tp").Use(p, who.name); if (!p.hidden) { Command.all.Find("hide").Use(p, ""); } p.possess = who.name; who.following = p.name; if (!p.invincible) { p.invincible = true; } bool result = (skin == "#") ? who.MarkPossessed() : who.MarkPossessed(p.name); if (!result) { return; } p.SendDie(who.id); who.canBuild = false; Player.SendMessage(p, "Successfully possessed " + who.color + who.name + Server.DefaultColor + "."); } } catch (Exception e) { Server.ErrorLog(e); Player.SendMessage(p, "There was an error."); } }