/*void Unloaded() * { * storedData.cantele.Clear(); * Interface.GetMod().DataFileSystem.WriteObject("WarpSystem", storedData); * }*/ void OnServerCommand(ConsoleSystem.Arg arg) { if (arg == null) { return; } if (arg.connection == null) { return; } if (arg.connection.player == null) { return; } if (arg.cmd == null) { return; } if (arg.cmd.name == null) { return; } BasePlayer player = (BasePlayer)arg.connection.player; ulong steamId = player.userID; double nextteletime; string cmd = arg.cmd.namefull; string text = arg.GetString(0, "text"); if (cmd == "chat.say" && text.StartsWith("/")) { foreach (WarpInfo info in storedData.WarpInfo) { if (text == "/" + info.WarpName || text == "/" + info.WarpId) { if (info.WarpPermissionGroup == "all" || permission.UserHasGroup(steamId.ToString(), info.WarpPermissionGroup)) { if (enablecooldown == true) { if (storedData.cantele.TryGetValue(steamId, out nextteletime)) { if (GetTimeStamp() > nextteletime) { storedData.cantele[steamId] = GetTimeStamp() + cooldown; Interface.GetMod().DataFileSystem.WriteObject("WarpSystem", storedData); goto Finish; } else { int nexttele = Convert.ToInt32(GetTimeStamp() - nextteletime); SendReply(player, youhavetowait, nexttele.ToString().Replace("-", "")); return; } } else { storedData.cantele.Add(steamId, GetTimeStamp() + cooldown); Interface.GetMod().DataFileSystem.WriteObject("WarpSystem", storedData); goto Finish; } } Finish: if (storedData.lastposition.ContainsKey(steamId) | !storedData.lastposition.ContainsKey(steamId)) { storedData.lastposition.Remove(steamId); Interface.GetMod().DataFileSystem.WriteObject("WarpSystem", storedData); float x = player.transform.position.x; float y = player.transform.position.y; float z = player.transform.position.z; var oldinfo = new OldPosInfo(x, y, z); storedData.lastposition.Add(steamId, oldinfo); Interface.GetMod().DataFileSystem.WriteObject("WarpSystem", storedData); } SendReply(player, teleportingto, info.WarpTimer, info.WarpName); timer.Once(info.WarpTimer, () => { if (WarpIfRunning == false && player.IsRunning()) { SendReply(player, cantwarpwhilerunning); return; } if (WarpIfWounded == false && player.IsWounded()) { SendReply(player, cantwarpwhilewounded); return; } if (WarpIfSwimming == false && player.IsSwimming()) { SendReply(player, cantwarpwhileswimming); return; } if (WarpIfBuildingBlocked == false & !player.CanBuild()) { SendReply(player, cantwarpwhilebuildingblocked); return; } if (WarpIfDucking == false && player.IsDucked()) { SendReply(player, cantwarpwhileducking); return; } ForcePlayerPos(player, new Vector3(info.WarpX, info.WarpY, info.WarpZ)); SendReply(player, youhaveteleportedto, info.WarpName); }); } else { SendReply(player, "You are not allowed to use this warp!"); return; } } } } }
void cmdWarp(Player player, string cmdd, string[] args) { if (args.Length == 0) { if (permission.UserHasPermission(player.Id.ToString(), "warp.admin")) { SendReply(player, "[91FFB5]Available Commands[FFFFFF]"); SendReply(player, "[91FFB5]-[FFFFFF] /warp <add> <WarpName> <WarpTimer> <WarpRange> <WarpPermissionGroup>"); SendReply(player, "[91FFB5]-[FFFFFF] /warp limit"); //SendReply(player, "[91FFB5]-[FFFFFF] /warp random"); SendReply(player, "[91FFB5]-[FFFFFF] /warp remove <WarpName>"); SendReply(player, "[91FFB5]-[FFFFFF] /warp wipe"); SendReply(player, "[91FFB5]-[FFFFFF] /warp list"); SendReply(player, "[91FFB5]-[FFFFFF] /warp to <WarpName> || /warp list"); /*SendReply(player, "[91FFB5]-[FFFFFF] /<WarpName> => A shorter version of /warp to <WarpName> || /warp list"); * SendReply(player, "[91FFB5]Teleport all online players[FFFFFF]: \n[91FFB5]-[FFFFFF] /warp all <WarpName>"); * SendReply(player, "[91FFB5]Teleport all sleepers[FFFFFF]: \n[91FFB5]-[FFFFFF] /warp all sleepers <WarpName>");*/ } else { SendReply(player, "[91FFB5]Available Commands[FFFFFF]"); SendReply(player, "[91FFB5]-[FFFFFF] /warp list"); SendReply(player, "[91FFB5]-[FFFFFF] /warp limit"); //SendReply(player, "[91FFB5]-[FFFFFF] /warp random"); SendReply(player, "[91FFB5]-[FFFFFF] /warp to <WarpName> || /warp list"); //SendReply(player, "[91FFB5]-[FFFFFF] /<WarpName> => A shorter version of /warp to <WarpName> || /warp list"); } return; } ulong steamId = player.Id; float nextteletime; switch (args[0]) { case "limit": SendReply(player, "[91FFB5]Current Warp Limits[FFFFFF]"); if (storedData.cantele.TryGetValue(steamId, out nextteletime)) { int nexttele = Convert.ToInt32(nextteletime - Time.realtimeSinceStartup); if (nexttele <= 0) { nexttele = 0; } SendReply(player, $"You will be able to warp again in {nexttele.ToString()} seconds"); } SendReply(player, $"Warp Cooldown: <color=orage>{cooldown.ToString()}[FFFFFF]"); SendReply(player, $"Warp Cooldown Enabled: <color=orage>{enablecooldown.ToString()}[FFFFFF]"); SendReply(player, "[91FFB5]*************[FFFFFF]"); break; case "back": if (permission.UserHasPermission(player.Id.ToString(), "canback")) { SendReply(player, "Teleporting to you last saved locations in {0} seconds.", warpbacktimer.ToString()); timer.Once(warpbacktimer, () => { ForcePlayerPos(player, new Vector3(storedData.lastposition[steamId].OldX, storedData.lastposition[steamId].OldY, storedData.lastposition[steamId].OldZ)); SendReply(player, backtolastloc); storedData.lastposition.Remove(steamId); Interface.GetMod().DataFileSystem.WriteObject("WarpSystem", storedData); }); } break; /*case "random": * player.SendConsoleCommand($"chat.say \"/warp to {GetRandomId(player).ToString()}\" "); * break;*/ /*case "all": * if(!permission.UserHasPermission(player.userID.ToString(), "warp.admin")) * { * SendReply(player, "You do not have permission to use this command!"); * return; * } * if(args.Length == 2) * { * foreach(BasePlayer current in BasePlayer.activePlayerList) * { * foreach(WarpInfo info in storedData.WarpInfo) * { * if(info.WarpName.ToString().ToLower() == args[1].ToString().ToLower() || info.WarpId.ToString() == args[1].ToString()) * { * ForcePlayerPos(current, new Vector3(info.WarpX, info.WarpY, info.WarpZ)); * SendReply(current, "You got teleported to [91FFB5]" + info.WarpName + "[FFFFFF] by [FF8C00]" + player.displayName + "[FFFFFF]"); * * } * } * } * } * else if(args.Length == 3 && args[1].ToString() == "sleepers") * { * foreach(Player sleepers in BasePlayer.sleepingPlayerList) * { * foreach(WarpInfo info in storedData.WarpInfo) * { * if(info.WarpName.ToString().ToLower() == args[2].ToString().ToLower() || info.WarpId.ToString() == args[2].ToString()) * { * ForcePlayerPos(sleepers, new Vector3(info.WarpX, info.WarpY, info.WarpZ)); * //SendReply(player, "You got teleported to [91FFB5]" + info.WarpName + "[FFFFFF] by [FF8C00]" + player.displayName + "[FFFFFF]"); * * } * } * } * } * else * { * SendReply(player, "[91FFB5]Teleport all online players[FFFFFF]: \n /warp all <WarpName>"); * SendReply(player, "[91FFB5]Teleport all sleepers[FFFFFF]: \n /warp all sleepers <WarpName>"); * return; * } * break;*/ case "wipe": if (!permission.UserHasPermission(player.Id.ToString(), "warp.admin")) { SendReply(player, "You do not have permission to use this command!"); return; } storedData.WarpInfo.Clear(); storedData.cantele.Clear(); Interface.GetMod().DataFileSystem.WriteObject("WarpSystem", storedData); SendReply(player, "You have wiped all the teleports!"); break; case "list": SendReply(player, "[91FFB5]Current Warps[FFFFFF]"); foreach (WarpInfo info in storedData.WarpInfo) { if (permission.UserHasGroup(steamId.ToString(), info.WarpPermissionGroup) || info.WarpPermissionGroup == "all") { SendReply(player, warplist.ToString(), info.WarpName, info.WarpPermissionGroup, info.WarpId); } } SendReply(player, "[91FFB5]*************[FFFFFF]"); break; case "add": if (!permission.UserHasPermission(player.Id.ToString(), "warp.admin")) { SendReply(player, "You do not have permission to use this command!"); return; } if (args.Length != 5) { SendReply(player, "/warp <add> <WarpName> <WarpTimer> <WarpRange> <WarpPermissionGroup>"); return; } foreach (WarpInfo info in storedData.WarpInfo) { if (args[1].ToString().ToLower() == info.WarpName.ToString().ToLower()) { SendReply(player, therealreadyis.ToString()); return; } } string permissionp = args[4]; string name = args[1]; int warpnum; int timerp = Convert.ToInt32(args[2]); int randomr = Convert.ToInt32(args[3]); if (storedData.WarpInfo == null) { warpnum = 1; } else { warpnum = GetNewId(); } var data = new WarpInfo(name, player, timerp, permissionp, warpnum, randomr); storedData.WarpInfo.Add(data); SendReply(player, warpadded, name.ToString()); Interface.GetMod().DataFileSystem.WriteObject("WarpSystem", storedData); if (!permission.GroupExists(args[3])) { permission.CreateGroup(args[3], "", 0); } break; case "to": if (args.Length != 2) { SendReply(player, "/warp to <WarpName> || /warplist"); return; } foreach (WarpInfo info in storedData.WarpInfo) { if (info.WarpName.ToString().ToLower() == args[1].ToString().ToLower() || info.WarpId.ToString() == args[1].ToString()) { if (info.WarpPermissionGroup == "all" || permission.UserHasGroup(steamId.ToString(), info.WarpPermissionGroup)) { if (enablecooldown == true) { if (storedData.cantele.TryGetValue(steamId, out nextteletime)) { if (Time.realtimeSinceStartup >= nextteletime) { storedData.cantele[steamId] = Time.realtimeSinceStartup + cooldown; Interface.GetMod().DataFileSystem.WriteObject("WarpSystem", storedData); goto Finish; } else { int nexttele = Convert.ToInt32(nextteletime - Time.realtimeSinceStartup); SendReply(player, youhavetowait, nexttele.ToString()); return; } } else { storedData.cantele.Add(steamId, Time.realtimeSinceStartup + cooldown); Interface.GetMod().DataFileSystem.WriteObject("WarpSystem", storedData); goto Finish; } } Finish: if (storedData.lastposition.ContainsKey(steamId) | !storedData.lastposition.ContainsKey(steamId)) { storedData.lastposition.Remove(steamId); Interface.GetMod().DataFileSystem.WriteObject("WarpSystem", storedData); float x = player.Entity.Position.x; float y = player.Entity.Position.y; float z = player.Entity.Position.z; var oldinfo = new OldPosInfo(x, y, z); storedData.lastposition.Add(steamId, oldinfo); Interface.GetMod().DataFileSystem.WriteObject("WarpSystem", storedData); } SendReply(player, teleportingto, info.WarpTimer, info.WarpName); timer.Once(info.WarpTimer, () => { int posx = UnityEngine.Random.Range(Convert.ToInt32(info.WarpX), info.RandomRange); int posz = UnityEngine.Random.Range(Convert.ToInt32(info.WarpZ), info.RandomRange); if (info.RandomRange == 0) { ForcePlayerPos(player, new Vector3(info.WarpX, info.WarpY, info.WarpZ)); } else { ForcePlayerPos(player, new Vector3(posx, info.WarpY, posz)); } SendReply(player, youhaveteleportedto, info.WarpName); }); } else { SendReply(player, "You are not allowed to use this warp!"); return; } } } break; case "help": if (permission.UserHasPermission(player.Id.ToString(), "warp.admin")) { SendReply(player, "[91FFB5]Available Commands[FFFFFF]"); SendReply(player, "[91FFB5]-[FFFFFF] /warp <add> <WarpName> <WarpTimer> <WarpRange> <WarpPermissionGroup>"); SendReply(player, "[91FFB5]-[FFFFFF] /warp limit"); //SendReply(player, "[91FFB5]-[FFFFFF] /warp random"); SendReply(player, "[91FFB5]-[FFFFFF] /warp remove <WarpName>"); SendReply(player, "[91FFB5]-[FFFFFF] /warp wipe"); SendReply(player, "[91FFB5]-[FFFFFF] /warp list"); SendReply(player, "[91FFB5]-[FFFFFF] /warp to <WarpName> || /warp list"); /*SendReply(player, "[91FFB5]-[FFFFFF] /<WarpName> => A shorter version of /warp to <WarpName> || /warp list"); * SendReply(player, "[91FFB5]Teleport all online players[FFFFFF]: \n[91FFB5]-[FFFFFF] /warp all <WarpName>"); * SendReply(player, "[91FFB5]Teleport all sleepers[FFFFFF]: \n[91FFB5]-[FFFFFF] /warp all sleepers <WarpName>");*/ } else { SendReply(player, "[91FFB5]Available Commands[FFFFFF]"); SendReply(player, "[91FFB5]-[FFFFFF] /warp list"); SendReply(player, "[91FFB5]-[FFFFFF] /warp limit"); //SendReply(player, "[91FFB5]-[FFFFFF] /warp random"); SendReply(player, "[91FFB5]-[FFFFFF] /warp to <WarpName> || /warp list"); //SendReply(player, "[91FFB5]-[FFFFFF] /<WarpName> => A shorter version of /warp to <WarpName> || /warp list"); } break; case "remove": if (!permission.UserHasPermission(player.Id.ToString(), "warp.admin")) { SendReply(player, "You do not have permission to use this command!"); return; } if (args.Length != 2) { SendReply(player, "/warp remove <WarpName>"); return; } foreach (WarpInfo info in storedData.WarpInfo) { if (info.WarpName.ToString() == args[1].ToString()) { storedData.WarpInfo.Remove(info); SendReply(player, youhaveremoved, info.WarpName); Interface.GetMod().DataFileSystem.WriteObject("WarpSystem", storedData); break; } } break; } }
void cmdWarp(BasePlayer player, string cmdd, string[] args) { if (args.Length == 0) { player.SendConsoleCommand("chat.say \"/warp help\" "); return; } bool isprisoner = Convert.ToBoolean(Jail?.Call("IsPrisoner", player)); ulong steamId = player.userID; double nextteletime; switch (args[0]) { case "limit": SendReply(player, "<color=#91FFB5>Current Warp Limits</color>"); if (storedData.cantele.TryGetValue(steamId, out nextteletime)) { int nexttele = Convert.ToInt32(nextteletime - GetTimeStamp()); if (nexttele <= 0) { nexttele = 0; } SendReply(player, $"You will be able to warp again in {nexttele.ToString()} seconds"); } SendReply(player, $"Warp Cooldown: <color=orage>{cooldown.ToString()}</color>"); SendReply(player, $"Warp Cooldown Enabled: <color=orage>{enablecooldown.ToString()}</color>"); SendReply(player, "<color=#91FFB5>*************</color>"); break; case "back": if (isprisoner) { SendReply(player, "You cant teleport out of the jail!"); return; } if (player.net.connection.authLevel >= backcmdauthlevel) { SendReply(player, "Teleporting to you last saved locations in {0} seconds.", warpbacktimer.ToString()); timer.Once(warpbacktimer, () => { if (WarpIfRunning == false && player.IsRunning()) { SendReply(player, cantwarpwhilerunning); return; } if (WarpIfWounded == false && player.IsWounded()) { SendReply(player, cantwarpwhilewounded); return; } if (WarpIfSwimming == false && player.IsSwimming()) { SendReply(player, cantwarpwhileswimming); return; } if (WarpIfBuildingBlocked == false & !player.CanBuild()) { SendReply(player, cantwarpwhilebuildingblocked); return; } if (WarpIfDucking == false && player.IsDucked()) { SendReply(player, cantwarpwhileducking); return; } ForcePlayerPos(player, new Vector3(storedData.lastposition[steamId].OldX, storedData.lastposition[steamId].OldY, storedData.lastposition[steamId].OldZ)); SendReply(player, backtolastloc); storedData.lastposition.Remove(steamId); Interface.GetMod().DataFileSystem.WriteObject("WarpSystem", storedData); }); } break; case "random": if (isprisoner) { SendReply(player, "You cant teleport out of the jail!"); return; } player.SendConsoleCommand($"chat.say \"/warp to {GetRandomId(player).ToString()}\" "); break; case "all": if (!permission.UserHasPermission(player.userID.ToString(), "warpsystem.admin")) { SendReply(player, "You do not have permission to use this command!"); return; } if (args.Length == 2) { foreach (BasePlayer current in BasePlayer.activePlayerList) { foreach (WarpInfo info in storedData.WarpInfo) { if (info.WarpName.ToString().ToLower() == args[1].ToString().ToLower() || info.WarpId.ToString() == args[1].ToString()) { ForcePlayerPos(current, new Vector3(info.WarpX, info.WarpY, info.WarpZ)); SendReply(current, "You got teleported to <color=#91FFB5>" + info.WarpName + "</color> by <color=orange>" + player.displayName + "</color>"); } } } } else if (args.Length == 3 && args[1].ToString() == "sleepers") { foreach (BasePlayer sleepers in BasePlayer.sleepingPlayerList) { foreach (WarpInfo info in storedData.WarpInfo) { if (info.WarpName.ToString().ToLower() == args[2].ToString().ToLower() || info.WarpId.ToString() == args[2].ToString()) { ForcePlayerPos(sleepers, new Vector3(info.WarpX, info.WarpY, info.WarpZ)); //SendReply(player, "You got teleported to <color=#91FFB5>" + info.WarpName + "</color> by <color=orange>" + player.displayName + "</color>"); } } } } else { SendReply(player, "<color=#91FFB5>Teleport all online players</color>: \n /warp all <WarpName>"); SendReply(player, "<color=#91FFB5>Teleport all sleepers</color>: \n /warp all sleepers <WarpName>"); return; } break; case "wipe": if (!permission.UserHasPermission(player.userID.ToString(), "warpsystem.admin")) { SendReply(player, "You do not have permission to use this command!"); return; } storedData.WarpInfo.Clear(); storedData.cantele.Clear(); Interface.GetMod().DataFileSystem.WriteObject("WarpSystem", storedData); SendReply(player, "You have wiped all the teleports!"); break; case "list": SendReply(player, "<color=#91FFB5>Current Warps</color>"); string maxusesrem; foreach (WarpInfo info in storedData.WarpInfo) { if (permission.UserHasGroup(steamId.ToString(), info.WarpPermissionGroup) || info.WarpPermissionGroup == "all") { if (info.WarpMaxUses == 0) { maxusesrem = "<color=red>UNLIMITED</color>"; } else if (!storedData.maxuses.ContainsKey(steamId)) { maxusesrem = info.WarpMaxUses.ToString(); } else { maxusesrem = storedData.maxuses[steamId][info.WarpName].ToString(); } SendReply(player, warplist.ToString(), info.WarpName, info.WarpPermissionGroup, info.WarpId, maxusesrem.ToString()); SendReply(player, "<color=#91FFB5>*************</color>"); } } SendReply(player, "<color=#91FFB5>*************</color>"); break; case "add": if (!permission.UserHasPermission(player.userID.ToString(), "warpsystem.admin")) { SendReply(player, "You do not have permission to use this command!"); return; } if (args.Length != 6) { SendReply(player, "/warp <add> <WarpName> <WarpTimer> <WarpRange> <WarpMaxUses> <WarpPermissionGroup>"); return; } foreach (WarpInfo info in storedData.WarpInfo) { if (args[1].ToString().ToLower() == info.WarpName.ToString().ToLower()) { SendReply(player, therealreadyis.ToString()); return; } } string permissionp = args[5]; string name = args[1]; int warpnum; int timerp = Convert.ToInt32(args[2]); int randomr = Convert.ToInt32(args[3]); int maxusess = Convert.ToInt32(args[4]); if (storedData.WarpInfo == null) { warpnum = 1; } else { warpnum = GetNewId(); } var data = new WarpInfo(name, player, timerp, permissionp, warpnum, randomr, maxusess); storedData.WarpInfo.Add(data); SendReply(player, warpadded, name.ToString()); Interface.GetMod().DataFileSystem.WriteObject("WarpSystem", storedData); if (!permission.GroupExists(args[5])) { permission.CreateGroup(args[5], "", 0); } cmd.AddChatCommand(name.ToString(), this, ""); cmd.AddChatCommand(warpnum.ToString(), this, ""); break; case "to": if (args.Length != 2) { SendReply(player, "/warp to <WarpName> || /warplist"); return; } if (isprisoner) { SendReply(player, "You cant teleport out of the jail!"); return; } foreach (WarpInfo info in storedData.WarpInfo) { if (info.WarpName.ToString().ToLower() == args[1].ToString().ToLower() || info.WarpId.ToString() == args[1].ToString()) { if (info.WarpPermissionGroup == "all" || permission.UserHasGroup(steamId.ToString(), info.WarpPermissionGroup)) { if (info.WarpMaxUses > 0) { if (!storedData.maxuses.ContainsKey(steamId)) { storedData.maxuses.Add( steamId, new Dictionary <string, int> { { info.WarpName, 1 } } ); } if (storedData.maxuses[steamId][info.WarpName] == 5) { SendReply(player, "You have reached the max uses for this Warp!"); return; } if (storedData.maxuses.ContainsKey(steamId)) { storedData.maxuses[steamId][info.WarpName] = storedData.maxuses[steamId][info.WarpName] + 1; } } if (enablecooldown == true) { if (storedData.cantele.TryGetValue(steamId, out nextteletime)) { if (GetTimeStamp() >= nextteletime) { storedData.cantele[steamId] = GetTimeStamp() + cooldown; Interface.GetMod().DataFileSystem.WriteObject("WarpSystem", storedData); goto Finish; } else { int nexttele = Convert.ToInt32(GetTimeStamp() - nextteletime); SendReply(player, youhavetowait, nexttele.ToString().Replace("-", "")); return; } } else { storedData.cantele.Add(steamId, GetTimeStamp() + cooldown); Interface.GetMod().DataFileSystem.WriteObject("WarpSystem", storedData); goto Finish; } } Finish: if (storedData.lastposition.ContainsKey(steamId) | !storedData.lastposition.ContainsKey(steamId)) { storedData.lastposition.Remove(steamId); Interface.GetMod().DataFileSystem.WriteObject("WarpSystem", storedData); float x = player.transform.position.x; float y = player.transform.position.y; float z = player.transform.position.z; var oldinfo = new OldPosInfo(x, y, z); storedData.lastposition.Add(steamId, oldinfo); Interface.GetMod().DataFileSystem.WriteObject("WarpSystem", storedData); } SendReply(player, teleportingto, info.WarpTimer, info.WarpName); timer.Once(info.WarpTimer, () => { if (WarpIfRunning == false && player.IsRunning()) { SendReply(player, cantwarpwhilerunning); return; } if (WarpIfWounded == false && player.IsWounded()) { SendReply(player, cantwarpwhilewounded); return; } if (WarpIfSwimming == false && player.IsSwimming()) { SendReply(player, cantwarpwhileswimming); return; } if (WarpIfBuildingBlocked == false & !player.CanBuild()) { SendReply(player, cantwarpwhilebuildingblocked); return; } if (WarpIfDucking == false && player.IsDucked()) { SendReply(player, cantwarpwhileducking); return; } int posx = UnityEngine.Random.Range(Convert.ToInt32(info.WarpX), info.RandomRange); int posz = UnityEngine.Random.Range(Convert.ToInt32(info.WarpZ), info.RandomRange); if (info.RandomRange == 0) { ForcePlayerPos(player, new Vector3(info.WarpX, info.WarpY, info.WarpZ)); } else { ForcePlayerPos(player, new Vector3(posx, info.WarpY, posz)); } SendReply(player, youhaveteleportedto, info.WarpName); }); } else { SendReply(player, "You are not allowed to use this warp!"); return; } } } break; case "help": if (permission.UserHasPermission(player.userID.ToString(), "warpsystem.admin")) { SendReply(player, "<color=#91FFB5>Available Commands</color>"); SendReply(player, "<color=#91FFB5>-</color> /warp <add> <WarpName> <WarpTimer> <WarpRange> <WarpMaxUses> <WarpPermissionGroup>"); SendReply(player, "<color=#91FFB5>-</color> /warp limit"); SendReply(player, "<color=#91FFB5>-</color> /warp random"); SendReply(player, "<color=#91FFB5>-</color> /warp remove <WarpName>"); SendReply(player, "<color=#91FFB5>-</color> /warp wipe"); SendReply(player, "<color=#91FFB5>-</color> /warp list"); SendReply(player, "<color=#91FFB5>-</color> /warp to <WarpName> || /warp list"); SendReply(player, "<color=#91FFB5>-</color> /<WarpName> => A shorter version of /warp to <WarpName> || /warp list"); SendReply(player, "<color=#91FFB5>Teleport all online players</color>: \n<color=#91FFB5>-</color> /warp all <WarpName>"); SendReply(player, "<color=#91FFB5>Teleport all sleepers</color>: \n<color=#91FFB5>-</color> /warp all sleepers <WarpName>"); } else { SendReply(player, "<color=#91FFB5>Available Commands</color>"); SendReply(player, "<color=#91FFB5>-</color> /warp list"); SendReply(player, "<color=#91FFB5>-</color> /warp limit"); SendReply(player, "<color=#91FFB5>-</color> /warp random"); SendReply(player, "<color=#91FFB5>-</color> /warp to <WarpName> || /warp list"); SendReply(player, "<color=#91FFB5>-</color> /<WarpName> => A shorter version of /warp to <WarpName> || /warp list"); } break; case "remove": if (!permission.UserHasPermission(player.userID.ToString(), "warpsystem.admin")) { SendReply(player, "You do not have permission to use this command!"); return; } if (args.Length != 2) { SendReply(player, "/warp remove <WarpName>"); return; } foreach (WarpInfo info in storedData.WarpInfo) { if (info.WarpName.ToString() == args[1].ToString()) { storedData.WarpInfo.Remove(info); SendReply(player, youhaveremoved, info.WarpName); Interface.GetMod().DataFileSystem.WriteObject("WarpSystem", storedData); break; } } break; } }
void cmdWarp(NetUser player, string cmdd, string[] args) { if (args.Length == 0) { if (permission.UserHasPermission(player.userID.ToString(), "warp.admin")) { SendReply(player, "[color cyan]Available Commands[color white]"); SendReply(player, "[color cyan]-[color white] /warp <add> <WarpName> <WarpTimer> <WarpRange> <WarpMaxUses> <WarpPermissionGroup>"); SendReply(player, "[color cyan]-[color white] /warp limit"); SendReply(player, "[color cyan]-[color white] /warp remove <WarpName>"); SendReply(player, "[color cyan]-[color white] /warp wipe"); SendReply(player, "[color cyan]-[color white] /warp list"); SendReply(player, "[color cyan]-[color white] /warp to <WarpName> || /warp list"); SendReply(player, "[color cyan]Teleport all online players[color white]: \n[color cyan]-[color white] /warp all <WarpName>"); } else { SendReply(player, "[color cyan]Available Commands[color white]"); SendReply(player, "[color cyan]-[color white] /warp list"); SendReply(player, "[color cyan]-[color white] /warp limit"); SendReply(player, "[color cyan]-[color white] /warp to <WarpName> || /warp list"); } return; } ulong steamId = player.userID; float nextteletime; switch (args[0]) { case "limit": SendReply(player, "[color cyan]Current Warp Limits[color white]"); if (storedData.cantele.TryGetValue(steamId, out nextteletime)) { int nexttele = Convert.ToInt32(nextteletime - Time.realtimeSinceStartup); if (nexttele <= 0) { nexttele = 0; } SendReply(player, $"You will be able to warp again in {nexttele.ToString()} seconds"); } SendReply(player, $"Warp Cooldown: [color orange]{cooldown.ToString()}[color white]"); SendReply(player, $"Warp Cooldown Enabled: [color orange]{enablecooldown.ToString()}[color white]"); SendReply(player, "[color cyan]*************[color white]"); break; case "back": if (permission.UserHasPermission(player.userID.ToString(), "canback")) { SendReply(player, "Teleporting to you last saved locations in {0} seconds.", warpbacktimer.ToString()); timer.Once(warpbacktimer, () => { ForcePlayerPos(player, new Vector3(storedData.lastposition[steamId].OldX, storedData.lastposition[steamId].OldY, storedData.lastposition[steamId].OldZ)); SendReply(player, backtolastloc); storedData.lastposition.Remove(steamId); Interface.GetMod().DataFileSystem.WriteObject("WarpSystem", storedData); }); } break; /*case "random": * player.SendConsoleCommand($"chat.say \"/warp to {GetRandomId(player).ToString()}\" "); * break;*/ case "all": if (!permission.UserHasPermission(player.userID.ToString(), "warp.admin")) { SendReply(player, "You do not have permission to use this command!"); return; } if (args.Length == 2) { foreach (PlayerClient current in PlayerClient.All) { foreach (WarpInfo info in storedData.WarpInfo) { if (info.WarpName.ToString().ToLower() == args[1].ToString().ToLower() || info.WarpId.ToString() == args[1].ToString()) { var management = RustServerManagement.Get(); management.TeleportPlayerToWorld(current.netPlayer, new Vector3(info.WarpX, info.WarpY, info.WarpZ)); PrintToChat("Everyone got teleported to [color cyan]" + info.WarpName + "[color white] by [color orange]" + player.displayName + "[color white]"); } } } } else { SendReply(player, "[color cyan]Teleport all online players[color white]: \n /warp all <WarpName, WarpId>"); return; } break; case "wipe": if (!permission.UserHasPermission(player.userID.ToString(), "warp.admin")) { SendReply(player, "You do not have permission to use this command!"); return; } storedData.WarpInfo.Clear(); storedData.cantele.Clear(); Interface.GetMod().DataFileSystem.WriteObject("WarpSystem", storedData); SendReply(player, "You have wiped all the teleports!"); break; case "list": SendReply(player, "[color cyan]Current Warps[color white]"); string maxusesrem; foreach (WarpInfo info in storedData.WarpInfo) { if (permission.UserHasGroup(steamId.ToString(), info.WarpPermissionGroup) || info.WarpPermissionGroup == "all") { if (info.WarpMaxUses == 0) { maxusesrem = "[color red]UNLIMITED[color white]"; } else if (!storedData.maxuses.ContainsKey(steamId)) { maxusesrem = info.WarpMaxUses.ToString(); } else { maxusesrem = storedData.maxuses[steamId][info.WarpName].ToString(); } SendReply(player, warplist.ToString(), info.WarpName, info.WarpPermissionGroup, info.WarpId, maxusesrem.ToString()); SendReply(player, "[color cyan]*************[color white]"); } } SendReply(player, "[color cyan]*************[color white]"); break; case "add": if (!permission.UserHasPermission(player.userID.ToString(), "warp.admin")) { SendReply(player, "You do not have permission to use this command!"); return; } if (args.Length != 6) { SendReply(player, "/warp <add> <WarpName> <WarpTimer> <WarpRange> <WarpMaxUses> <WarpPermissionGroup>"); return; } foreach (WarpInfo info in storedData.WarpInfo) { if (args[1].ToString().ToLower() == info.WarpName.ToString().ToLower()) { SendReply(player, therealreadyis.ToString()); return; } } string permissionp = args[5]; string name = args[1]; int warpnum; int timerp = Convert.ToInt32(args[2]); int randomr = Convert.ToInt32(args[3]); int maxusess = Convert.ToInt32(args[4]); if (storedData.WarpInfo == null) { warpnum = 1; } else { warpnum = GetNewId(); } var data = new WarpInfo(name, player, timerp, permissionp, warpnum, randomr, maxusess); storedData.WarpInfo.Add(data); SendReply(player, warpadded, name.ToString()); Interface.GetMod().DataFileSystem.WriteObject("WarpSystem", storedData); if (!permission.GroupExists(args[5])) { permission.CreateGroup(args[5], "", 0); } cmd.AddChatCommand(name.ToString(), this, ""); cmd.AddChatCommand(warpnum.ToString(), this, ""); break; case "to": if (args.Length != 2) { SendReply(player, "/warp to <WarpName> || /warplist"); return; } foreach (WarpInfo info in storedData.WarpInfo) { if (info.WarpName.ToString().ToLower() == args[1].ToString().ToLower() || info.WarpId.ToString() == args[1].ToString()) { if (info.WarpPermissionGroup == "all" || permission.UserHasGroup(steamId.ToString(), info.WarpPermissionGroup)) { if (info.WarpMaxUses > 0) { if (!storedData.maxuses.ContainsKey(steamId)) { storedData.maxuses.Add( steamId, new Dictionary <string, int> { { info.WarpName, 1 } } ); } if (storedData.maxuses[steamId][info.WarpName] == 5) { SendReply(player, "You have reached the max uses for this Warp!"); return; } if (storedData.maxuses.ContainsKey(steamId)) { storedData.maxuses[steamId][info.WarpName] = storedData.maxuses[steamId][info.WarpName] + 1; } } if (enablecooldown == true) { if (storedData.cantele.TryGetValue(steamId, out nextteletime)) { if (Time.realtimeSinceStartup >= nextteletime) { storedData.cantele[steamId] = Time.realtimeSinceStartup + cooldown; Interface.GetMod().DataFileSystem.WriteObject("WarpSystem", storedData); goto Finish; } else { int nexttele = Convert.ToInt32(nextteletime - Time.realtimeSinceStartup); SendReply(player, youhavetowait, nexttele.ToString()); return; } } else { storedData.cantele.Add(steamId, Time.realtimeSinceStartup + cooldown); Interface.GetMod().DataFileSystem.WriteObject("WarpSystem", storedData); goto Finish; } } Finish: if (storedData.lastposition.ContainsKey(steamId) | !storedData.lastposition.ContainsKey(steamId)) { storedData.lastposition.Remove(steamId); Interface.GetMod().DataFileSystem.WriteObject("WarpSystem", storedData); var cachedVector3 = player.playerClient.lastKnownPosition; float x = cachedVector3.x; float y = cachedVector3.y; float z = cachedVector3.z; var oldinfo = new OldPosInfo(x, y, z); storedData.lastposition.Add(steamId, oldinfo); Interface.GetMod().DataFileSystem.WriteObject("WarpSystem", storedData); } SendReply(player, teleportingto, info.WarpTimer, info.WarpName); timer.Once(info.WarpTimer, () => { int posx = UnityEngine.Random.Range(Convert.ToInt32(info.WarpX), info.RandomRange); int posz = UnityEngine.Random.Range(Convert.ToInt32(info.WarpZ), info.RandomRange); if (info.RandomRange == 0) { ForcePlayerPos(player, new Vector3(info.WarpX, info.WarpY, info.WarpZ)); } else { ForcePlayerPos(player, new Vector3(posx, info.WarpY, posz)); } SendReply(player, youhaveteleportedto, info.WarpName); }); } else { SendReply(player, "You are not allowed to use this warp!"); return; } } } break; case "help": if (permission.UserHasPermission(player.userID.ToString(), "warp.admin")) { SendReply(player, "[color cyan]Available Commands[color white]"); SendReply(player, "[color cyan]-[color white] /warp <add> <WarpName> <WarpTimer> <WarpRange> <WarpMaxUses> <WarpPermissionGroup>"); SendReply(player, "[color cyan]-[color white] /warp limit"); SendReply(player, "[color cyan]-[color white] /warp remove <WarpName>"); SendReply(player, "[color cyan]-[color white] /warp wipe"); SendReply(player, "[color cyan]-[color white] /warp list"); SendReply(player, "[color cyan]-[color white] /warp to <WarpName> || /warp list"); SendReply(player, "[color cyan]Teleport all online players[color white]: \n[color cyan]-[color white] /warp all <WarpName>"); } else { SendReply(player, "[color cyan]Available Commands[color white]"); SendReply(player, "[color cyan]-[color white] /warp list"); SendReply(player, "[color cyan]-[color white] /warp limit"); SendReply(player, "[color cyan]-[color white] /warp to <WarpName> || /warp list"); } break; case "remove": if (!permission.UserHasPermission(player.userID.ToString(), "warp.admin")) { SendReply(player, "You do not have permission to use this command!"); return; } if (args.Length != 2) { SendReply(player, "/warp remove <WarpName>"); return; } foreach (WarpInfo info in storedData.WarpInfo) { if (info.WarpName.ToString() == args[1].ToString()) { storedData.WarpInfo.Remove(info); SendReply(player, youhaveremoved, info.WarpName); Interface.GetMod().DataFileSystem.WriteObject("WarpSystem", storedData); break; } } break; } }