// Home Portals. public void HomeEntryChange(Player p, ushort x, ushort y, ushort z, byte type) { p.ClearBlockchange(); portalPos bp = (portalPos)p.blockchangeObject; if (bp.Multi.ToLower() == "multi" && type == Block.red && bp.port.Count > 0) { ExitChange(p, x, y, z, type); return; } else if (bp.Multi.ToLower() == "cuboid" && type == Block.red && bp.port.Count > 0) { ExitChange(p, x, y, z, type); return; } byte b = p.level.GetTile(x, y, z); p.level.Blockchange(p, x, y, z, bp.type); p.SendBlockchange(x, y, z, Block.green); if (bp.Multi.ToLower() != "multi" && bp.Multi.ToLower() != "cuboid") { p.Blockchange += new Player.BlockchangeEventHandler(ExitChange); Player.SendMessage(p, "&aEntry block placed"); } else { p.Blockchange += new Player.BlockchangeEventHandler(EntryChange); Player.SendMessage(p, "&aEntry block placed. &cPlace a Red block anywhere to finish."); } }
public void EntryChange(Player p, ushort x, ushort y, ushort z, byte type) { p.ClearBlockchange(); portalPos bp = (portalPos)p.blockchangeObject; if (bp.Multi.ToLower() == "multi" && type == Block.red && bp.port.Count > 0) { ExitChange(p, x, y, z, type); return; } byte b = p.level.GetTile(x, y, z); p.level.Blockchange(p, x, y, z, bp.type); p.SendBlockchange(x, y, z, Block.green); portPos Port; Port.portMapName = p.level.name; Port.x = x; Port.y = y; Port.z = z; bp.port.Add(Port); p.blockchangeObject = bp; if (bp.Multi.ToLower() != "multi") { p.Blockchange += new Player.BlockchangeEventHandler(ExitChange); Player.SendMessage(p, "&aEntry block placed"); } else if (bp.Multi.ToLower() == "multi") { p.Blockchange += new Player.BlockchangeEventHandler(EntryChange); Player.SendMessage(p, "&aEntry block placed. &cPlace a Red block for exit."); } }
public void ExitChange(Player p, ushort x, ushort y, ushort z, byte type) { p.ClearBlockchange(); byte b = p.level.GetTile(x, y, z); p.SendBlockchange(x, y, z, b); portalPos bp = (portalPos)p.blockchangeObject; foreach (portPos pos in bp.port) { /*DataTable Portals = MySQL.fillData("SELECT * FROM `Portals" + pos.portMapName + "` WHERE EntryX=" + (int)pos.x + " AND EntryY=" + (int)pos.y + " AND EntryZ=" + (int)pos.z); * Portals.Dispose(); * * if (Portals.Rows.Count == 0) * { * MySQL.executeQuery("INSERT INTO `Portals" + pos.portMapName + "` (EntryX, EntryY, EntryZ, ExitMap, ExitX, ExitY, ExitZ) VALUES (" + (int)pos.x + ", " + (int)pos.y + ", " + (int)pos.z + ", '" + p.level.name + "', " + (int)x + ", " + (int)y + ", " + (int)z + ")"); * } * else * { * MySQL.executeQuery("UPDATE `Portals" + pos.portMapName + "` SET ExitMap='" + p.level.name + "', ExitX=" + (int)x + ", ExitY=" + (int)y + ", ExitZ=" + (int)z + " WHERE EntryX=" + (int)pos.x + " AND EntryY=" + (int)pos.y + " AND EntryZ=" + (int)pos.z); * }*/ //DB Table portals = Server.s.database.GetTable("Portals" + pos.portMapName); List <List <string> > rows = portals.Rows; if (portals.GetRows(new string[] { "EntryX", "EntryY", "EntryZ" }, new string[] { pos.x.ToString(), pos.y.ToString(), pos.z.ToString() }).Count == 0) { portals.AddRow(new List <string> { pos.x.ToString(), pos.y.ToString(), pos.z.ToString(), p.level.ToString(), x.ToString(), y.ToString(), z.ToString() }); } else { portals.DeleteRow(rows.IndexOf(portals.GetRow(new string[] { "EntryX", "EntryY", "EntryZ" }, new string[] { pos.x.ToString(), pos.y.ToString(), pos.z.ToString() }))); portals.AddRow(new List <string> { pos.x.ToString(), pos.y.ToString(), pos.z.ToString(), p.level.name, x.ToString(), y.ToString(), z.ToString() }); } if (pos.portMapName == p.level.name) { p.SendBlockchange(pos.x, pos.y, pos.z, bp.type); } } Player.SendMessage(p, "&3Exit" + Server.DefaultColor + " block placed"); if (p.staticCommands) { bp.port.Clear(); p.blockchangeObject = bp; p.Blockchange += new Player.BlockchangeEventHandler(EntryChange); } }
public void ExitChange(Player p, ushort x, ushort y, ushort z, byte type) { p.ClearBlockchange(); byte b = p.level.GetTile(x, y, z); p.SendBlockchange(x, y, z, b); portalPos bp = (portalPos)p.blockchangeObject; foreach (portPos pos in bp.port) { DataTable Portals = Server.useMySQL ? MySQL.fillData("SELECT * FROM `Portals" + pos.portMapName + "` WHERE EntryX=" + (int)pos.x + " AND EntryY=" + (int)pos.y + " AND EntryZ=" + (int)pos.z) : SQLite.fillData("SELECT * FROM `Portals" + pos.portMapName + "` WHERE EntryX=" + (int)pos.x + " AND EntryY=" + (int)pos.y + " AND EntryZ=" + (int)pos.z); Portals.Dispose(); if (Portals.Rows.Count == 0) { if (Server.useMySQL) { MySQL.executeQuery("INSERT INTO `Portals" + pos.portMapName + "` (EntryX, EntryY, EntryZ, ExitMap, ExitX, ExitY, ExitZ) VALUES (" + (int)pos.x + ", " + (int)pos.y + ", " + (int)pos.z + ", '" + p.level.name + "', " + (int)x + ", " + (int)y + ", " + (int)z + ")"); } else { SQLite.executeQuery("INSERT INTO `Portals" + pos.portMapName + "` (EntryX, EntryY, EntryZ, ExitMap, ExitX, ExitY, ExitZ) VALUES (" + (int)pos.x + ", " + (int)pos.y + ", " + (int)pos.z + ", '" + p.level.name + "', " + (int)x + ", " + (int)y + ", " + (int)z + ")"); } } else { if (Server.useMySQL) { MySQL.executeQuery("UPDATE `Portals" + pos.portMapName + "` SET ExitMap='" + p.level.name + "', ExitX=" + (int)x + ", ExitY=" + (int)y + ", ExitZ=" + (int)z + " WHERE EntryX=" + (int)pos.x + " AND EntryY=" + (int)pos.y + " AND EntryZ=" + (int)pos.z); } else { SQLite.executeQuery("UPDATE `Portals" + pos.portMapName + "` SET ExitMap='" + p.level.name + "', ExitX=" + (int)x + ", ExitY=" + (int)y + ", ExitZ=" + (int)z + " WHERE EntryX=" + (int)pos.x + " AND EntryY=" + (int)pos.y + " AND EntryZ=" + (int)pos.z); } } //DB if (pos.portMapName == p.level.name) { p.SendBlockchange(pos.x, pos.y, pos.z, bp.type); } } Player.SendMessage(p, "&3Exit" + Server.DefaultColor + " block placed"); if (!p.staticCommands) { return; } bp.port.Clear(); p.blockchangeObject = bp; p.Blockchange += EntryChange; }
public void EntryChange(Player p, ushort x, ushort y, ushort z, ushort type) { p.ClearBlockchange(); portalPos bp = (portalPos)p.blockchangeObject; if (p.level.permissionbuild > p.group.Permission) { Player.SendMessage(p, "You do not have permission to build here!"); return; } ushort currblock = p.level.GetTile(x, y, z); if (Block.Mover(currblock)) { Player.SendMessage(p, "Portal cannot be placed here!"); return; } if (bp.Multi && type == Block.red && bp.port.Count > 0) { ExitChange(p, x, y, z, type); return; } // ushort b = p.level.GetTile(x, y, z); p.level.Blockchange(p, x, y, z, bp.type); p.SendBlockchange(x, y, z, Block.green); portPos Port; Port.portMapName = p.level.name; Port.x = x; Port.y = y; Port.z = z; bp.port.Add(Port); p.blockchangeObject = bp; if (!bp.Multi) { p.Blockchange += ExitChange; Player.SendMessage(p, "&aEntry block placed"); } else { p.Blockchange += EntryChange; Player.SendMessage(p, "&aEntry block placed. &cRed block for exit"); } }
public void ExitChange(Player p, ushort x, ushort y, ushort z, ushort type) { p.ClearBlockchange(); ushort b = p.level.GetTile(x, y, z); p.SendBlockchange(x, y, z, b); portalPos bp = (portalPos)p.blockchangeObject; foreach (portPos pos in bp.port) { Portal foundPortal = null; Portal newPortal = null; foreach (Portal po in PortalDB.portals) { if (po.entrance.ToLower() == pos.portMapName.ToLower() && po.x1 == pos.x && po.y1 == pos.y && po.z1 == pos.z) { foundPortal = po; } } if (foundPortal != null) { foundPortal.exit = p.level.name.ToLower(); foundPortal.x2 = x; foundPortal.y2 = y; foundPortal.z2 = z; } else { newPortal = new Portal(pos.portMapName.ToLower() + "-" + p.level.name.ToLower(), pos.portMapName.ToLower(), p.level.name, pos.x.ToString(), pos.y.ToString(), pos.z.ToString(), x.ToString(), y.ToString(), z.ToString()); PortalDB.portals.Add(newPortal); } if (pos.portMapName == p.level.name) { p.SendBlockchange(pos.x, pos.y, pos.z, bp.type); } } PortalDB.Save(); Player.SendMessage(p, "&cExit" + Server.DefaultColor + " block placed."); if (!p.staticCommands) { return; } bp.port.Clear(); p.blockchangeObject = bp; p.Blockchange += EntryChange; }
public void portalCuboid2(Player p, ushort x, ushort y, ushort z, byte type) { p.ClearBlockchange(); byte b = p.level.GetTile(x, y, z); p.SendBlockchange(x, y, z, b); portalPos bp = (portalPos)p.blockchangeObject; if (bp.Multi != "cuboid") { Player.SendMessage(p, "lolwut, glitch :/"); return; } portPos pos = bp.port[0]; if (pos.portMapName != p.level.name) { Player.SendMessage(p, "Portal cuboid must be on same map as first point."); return; } ushort xx; ushort yy; ushort zz; portPos port; int counter = 0; for (xx = Math.Min(pos.x, x); xx <= Math.Max(pos.x, x); ++xx) { for (yy = Math.Min(pos.y, y); yy <= Math.Max(pos.y, y); ++yy) { for (zz = Math.Min(pos.z, z); zz <= Math.Max(pos.z, z); ++zz) { counter++; port = new portPos(); port.x = xx; port.y = yy; port.z = zz; port.portMapName = p.level.name; bp.port.Add(port); p.level.Blockchange(xx, yy, zz, bp.type); p.SendBlockchange(xx, yy, zz, Block.green); } } } p.blockchangeObject = bp; Player.SendMessage(p, "Cuboided " + counter + " portals."); if (bp.port.Count != (counter + 1)) { Player.SendMessage(p, "You have " + bp.port.Count + " portals in total."); } Player.SendMessage(p, "&aYou can continue cuboiding, or &cplace a red block for exit."); p.Blockchange += new Player.BlockchangeEventHandler(portalCuboid1); }
public void portalCuboid1(Player p, ushort x, ushort y, ushort z, byte type) { p.ClearBlockchange(); if (type == Block.red) { ExitChange(p, x, y, z, type); return; } byte b = p.level.GetTile(x, y, z); p.SendBlockchange(x, y, z, b); portalPos bp = (portalPos)p.blockchangeObject; if (bp.Multi != "cuboid") { Player.SendMessage(p, "lolwut, glitch :/"); return; } portPos port = new portPos(); port.x = x; port.y = y; port.z = z; port.portMapName = p.level.name; bp.port.Add(port); p.blockchangeObject = bp; p.Blockchange += new Player.BlockchangeEventHandler(portalCuboid2); }