private void cmdPortal(BasePlayer player, string cmd, string[] args) { if (!HasPerm(player.userID, "admin")) { return; } if (args.Length == 0) { SendReply(player, "Syntax: /portal <entrance|exit|remove|list> <ID>"); return; } string ID; PortalInfo portal; List <PortalInfo> savedPortals; switch (args[0]) { case "copy": savedPortals = new List <PortalInfo>(); foreach (var portalSave in portals) { var name = CuiHelper.GetGuid(); var p = new PortalInfo(name); p.Entrance.Location.Vector3 = player.transform.position - portalSave.Entrance.Location.Vector3; p.Exit.Location.Vector3 = player.transform.position - portalSave.Exit.Location.Vector3; savedPortals.Add(p); } SaveData(savedPortals, "Portals_COPY"); break; case "paste": LoadData(out savedPortals, "Portals_COPY"); foreach (var portalSave in savedPortals) { var name = CuiHelper.GetGuid(); var p = new PortalInfo(name); portals.Add(p); p.Entrance.Location.Vector3 = player.transform.position - portalSave.Entrance.Location.Vector3; p.ReCreate(); p.Exit.Location.Vector3 = player.transform.position - portalSave.Exit.Location.Vector3; p.ReCreate(); } SaveData(savedPortals, "Portals_COPY"); break; case "cancelpaste": LoadData(out savedPortals, "Portals_COPY"); for (int i = 0; i < savedPortals.Count; i++) { var index = portals.Count - 1; portals[index].Remove(); portals.RemoveAt(index); } break; case "entrance": if (args.Length != 2) { SendReply(player, "Syntax: /portal entrance <ID>"); return; } ID = args[1]; portal = PortalInfo.Find(ID); if (portal == null) { portal = new PortalInfo(ID); portals.Add(portal); } portal.Entrance.Location.Vector3 = player.transform.position; portal.ReCreate(); SaveData(portals); SendReply(player, GetMsg("Portal Entrance Set").Replace("{ID}", args[1])); break; case "exit": if (args.Length != 2) { SendReply(player, "Syntax: /portal exit <ID>"); return; } ID = args[1]; portal = PortalInfo.Find(ID); if (portal == null) { portal = new PortalInfo(ID); portals.Add(portal); } portal.Exit.Location.Vector3 = player.transform.position; portal.ReCreate(); SaveData(portals); SendReply(player, GetMsg("Portal Exit Set").Replace("{ID}", args[1])); break; case "remove": if (args.Length != 2) { SendReply(player, "Syntax: /portal remove <ID>"); return; } ID = args[1]; portal = PortalInfo.Find(ID); if (portal == null) { SendReply(player, GetMsg("Portal Does Not Exist").Replace("{ID}", args[1])); return; } portal.Remove(); portals.Remove(portal); SaveData(portals); SendReply(player, GetMsg("Portal Removed").Replace("{ID}", args[1])); break; case "list": string portalList = portals.Count == 0 ? GetMsg("Portal List Empty") : GetMsg("Portal List").Replace("{portals}", string.Join("<color=#333> ◆ </color>", portals.Select(p => $"<color=#C4FF00>{p.ID}</color>").ToArray())); SendReply(player, portalList); break; default: SendReply(player, "Syntax: /portal <entrance|exit|remove> <ID>"); break; } }
private void cmdPortal(BasePlayer player, string cmd, string[] args) { if (!HasPerm(player.userID, "admin")) { SendReply(player, GetMsg("No Permission")); return; } if (args.Length == 0) { SendReply(player, "Syntax: /portal <entrance|exit|remove|list> <ID>"); return; } string ID; PortalInfo portal; switch (args[0]) { case "entrance": if (args.Length != 2) { SendReply(player, "Syntax: /portal entrance <ID>"); return; } ID = args[1]; portal = PortalInfo.Find(ID); if (portal == null) { portal = new PortalInfo(ID); portals.Add(portal); } portal.Entrance.Location.Vector3 = player.transform.position; portal.ReCreate(); SaveData(portals); SendReply(player, GetMsg("Portal Entrance Set").Replace("{ID}", args[1])); break; case "exit": if (args.Length != 2) { SendReply(player, "Syntax: /portal exit <ID>"); return; } ID = args[1]; portal = PortalInfo.Find(ID); if (portal == null) { portal = new PortalInfo(ID); portals.Add(portal); } portal.Exit.Location.Vector3 = player.transform.position; portal.ReCreate(); SaveData(portals); SendReply(player, GetMsg("Portal Exit Set").Replace("{ID}", args[1])); break; case "remove": if (args.Length != 2) { SendReply(player, "Syntax: /portal remove <ID>"); return; } ID = args[1]; portal = PortalInfo.Find(ID); if (portal == null) { SendReply(player, GetMsg("Portal Does Not Exist").Replace("{ID}", args[1])); return; } portal.Remove(); portals.Remove(portal); SaveData(portals); SendReply(player, GetMsg("Portal Removed").Replace("{ID}", args[1])); break; case "list": string portalList = portals.Count == 0 ? GetMsg("Portal List Empty") : GetMsg("Portal List").Replace("{portals}", string.Join("<color=#333> â </color>", portals.Select(p => $"<color=#C4FF00>{p.ID}</color>").ToArray())); SendReply(player, portalList); break; default: SendReply(player, "Syntax: /portal <entrance|exit|remove> <ID>"); break; } }
private void CmdPortal(IPlayer iplayer, string command, string[] args) { if (!iplayer.HasPermission(permPortalsAdmin)) { Message(iplayer, "NoPermission"); return; } if (args.Length == 0) { Message(iplayer, "syntax"); return; } var player = iplayer.Object as BasePlayer; string ID; PortalInfo portal; switch (args[0]) { case "entrance": case "pri": case "primary": case "add": case "create": if (args.Length != 2) { Message(iplayer, "syntax"); return; } ID = args[1]; portal = PortalInfo.Find(ID); if (portal == null) { portal = new PortalInfo(ID); portals.Add(portal); } Vector3 primary = player.transform.position; //if (!AboveFloor(primary)) //{ // primary.y = TerrainMeta.HeightMap.GetHeight(player.transform.position) + 0.1f; //} portal.Primary.Location.Vector3 = primary; portal.OneWay = !configData.defaultTwoWay; portal.DeploySpinner = configData.deploySpinner; portal.ReCreate(); SaveData(); Message(iplayer, "PortalPrimarySet", args[1]); break; case "exit": case "sec": case "secondary": if (args.Length != 2) { Message(iplayer, "syntax"); return; } ID = args[1]; portal = PortalInfo.Find(ID); if (portal == null) { portal = new PortalInfo(ID); portals.Add(portal); } Vector3 secondary = player.transform.position; //if (!AboveFloor(secondary)) //{ // secondary.y = TerrainMeta.HeightMap.GetHeight(player.transform.position) + 0.1f; //} portal.Secondary.Location.Vector3 = secondary; portal.ReCreate(); SaveData(); Message(iplayer, "PortalSecondarySet", args[1]); break; case "wipe": portals = new List <PortalInfo>(); SaveData(); break; case "remove": case "delete": if (args.Length != 2) { Message(iplayer, "syntax"); return; } ID = args[1]; portal = PortalInfo.Find(ID); if (portal == null) { Message(iplayer, "PortalDoesNotExist", args[1]); return; } portal.Remove(); portals.Remove(portal); SaveData(); Message(iplayer, "PortalRemoved", args[1]); break; case "timer": case "time": if (args.Length != 3) { Message(iplayer, "syntax"); return; } ID = args[1]; portal = PortalInfo.Find(ID); if (portal == null) { Message(iplayer, "PortalDoesNotExist", args[1]); return; } portal.TeleportationTime = float.Parse(args[2]); portal.ReCreate(); SaveData(); Message(iplayer, "PortalTimerSet", args[1], args[2]); break; case "spinner": if (args.Length != 3) { Message(iplayer, "syntax"); return; } ID = args[1]; portal = PortalInfo.Find(ID); if (portal == null) { Message(iplayer, "PortalDoesNotExist", args[1]); return; } portal.DeploySpinner = GetBoolValue(args[2]); SaveData(); portal.ReCreate(); Message(iplayer, "PortalSpinnerSet", ID, args[2]); break; case "oneway": if (args.Length != 3) { Message(iplayer, "syntax"); return; } ID = args[1]; portal = PortalInfo.Find(ID); if (portal == null) { Message(iplayer, "PortalDoesNotExist", args[1]); return; } portal.OneWay = GetBoolValue(args[2]); portal.ReCreate(); SaveData(); Message(iplayer, "PortalOneWaySet", ID, args[2]); break; case "perm": case "permission": Puts($"Args length = {args.Length.ToString()}"); if (args.Length != 3) { Message(iplayer, "syntax"); return; } ID = args[1]; portal = PortalInfo.Find(ID); if (portal == null) { Message(iplayer, "PortalDoesNotExist", args[1]); return; } portal.RequiredPermission = "portals." + args[2]; if (!permission.PermissionExists(portal.RequiredPermission, this)) { permission.RegisterPermission(portal.RequiredPermission, this); } portal.ReCreate(); SaveData(); Message(iplayer, "PortalPermSet", ID, "portals." + args[2]); break; case "list": if (args.Length != 1) { Message(iplayer, "syntax"); return; } string portalList = null; if (portals.Count == 0) { portalList = Lang("PortalListEmpty"); } else { foreach (PortalInfo p in portals) { var pentrance = p.Primary.Location.Vector3.ToString(); var pexit = p.Secondary.Location.Vector3.ToString(); var ptime = p.TeleportationTime.ToString() + " " + Lang("seconds"); var pperm = Lang("perm") + p.RequiredPermission.Replace("portals.", ""); portalList += $"\n<color=#333> - </color><color=#C4FF00>{p.ID} {pentrance} {pexit} [{ptime}, {pperm}]</color>"; if (p.OneWay) { portalList += "<color=#333> (oneway) </color>"; } if (p.DeploySpinner) { portalList += "<color=#333> (spinner) </color>"; } portalList += "\n"; } } Message(iplayer, "PortalList", portalList); break; default: Message(iplayer, "syntax"); break; } }