private bool CheckRequirements(Player player, WarpInfo warpInfo, [MaybeNullWhen(true)] out string errorMessage) { errorMessage = null; if (!this.CheckLevelRequirement(player, warpInfo)) { errorMessage = $"You need to be level {warpInfo.LevelRequirement} in order to warp"; return(false); } if (warpInfo.Gate?.Map is null) { errorMessage = "The warp target is not initialized"; return(false); } if (warpInfo.Gate.Map.TryGetRequirementError(player, out var message)) { errorMessage = message; return(false); } // Money check should be last to avoid getting zen when other checks failed if (!this.CheckMoneyRequirement(player, warpInfo)) { errorMessage = $"You need {warpInfo.Costs} in order to warp"; return(false); } return(true); }
private static ILearner LoadLearner(IObjectModel objectModel, IDetector detector) { // initial positive patch synthesis info WarpInfo initPosPatchWarpInfo = new WarpInfo(0.01f, 0.01f, 10); PositivePatchSynthesisInfo initPosPatchSynthesisInfo = new PositivePatchSynthesisInfo( 100, 10, initPosPatchWarpInfo, 0.2 ); WarpInfo runtimePosPatchWarpInfo = new WarpInfo(0.01f, 0.01f, 10); PositivePatchSynthesisInfo runtimePosPatchSynthesisInfo = new PositivePatchSynthesisInfo( 100, 10, runtimePosPatchWarpInfo, 0.2 ); // initial negative patch picking info NegativePatchPickingInfo initNegPatchPickInfo = new NegativePatchPickingInfo(50, 10, 0.2f); NegativePatchPickingInfo runtimeNegPatchPickInfo = new NegativePatchPickingInfo(100, 10, 0.2f); Learner learner = new Learner( objectModel, detector, initPosPatchSynthesisInfo, initNegPatchPickInfo, runtimePosPatchSynthesisInfo, runtimeNegPatchPickInfo, 0.95f, 0.57f ); return(learner); }
void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.tag == "Warp" && !action) { WarpInfo warpInfo = other.GetComponent <WarpInfo>(); string type = warpInfo.type; if (type == "Door") { //Start Zoom effect & pass warp info along to it GameObject newZoom = Instantiate(ZoomPrefab, new Vector3(transform.position.x, transform.position.y, transform.position.z - 1.5f), Quaternion.identity); newZoom.GetComponent <ZoomLoad>().SetVariables(warpInfo.location, warpInfo.coordinates, warpInfo.cameraCoordinates); } else if (type == "Pan") //Hit camera's edge and prepares to pan the camera in the moving direction { string param = other.GetComponent <WarpInfo>().location; } } else if (other.gameObject.tag == "Coin") { money += other.GetComponent <Coin>().value; Destroy(other.gameObject); } else if (other.gameObject.tag == "Key") { keys++; AudioSource.PlayClipAtPoint(keySFX, 0.9f * Camera.main.transform.position + 0.1f * transform.position, .75f); Destroy(other.gameObject); } }
private bool CheckLevelRequirement(Player player, WarpInfo warpInfo) { if (warpInfo.LevelRequirement <= player.Attributes?[Stats.Level]) { return(true); } return(false); }
private bool CheckMoneyRequirement(Player player, WarpInfo warpInfo) { if (player.TryRemoveMoney(warpInfo.Costs)) { return(true); } return(false); }
/// <summary> /// Warps the player. /// </summary> /// <param name="player">The player.</param> /// <param name="warpInfo">The warp information.</param> public void WarpTo(Player player, WarpInfo warpInfo) { if (this.CheckRequirements(player, warpInfo, out var errorMessage)) { player.WarpTo(warpInfo.Gate !); } else { player.ViewPlugIns.GetPlugIn <IShowMessagePlugIn>()?.ShowMessage(errorMessage, MessageType.BlueNormal); } }
/// <summary> /// Warps the player. /// </summary> /// <param name="player">The player.</param> /// <param name="warpInfo">The warp information.</param> public void WarpTo(Player player, WarpInfo warpInfo) { if (warpInfo.LevelRequirement > player.Attributes[Stats.Level]) { return; // todo: check if we need failed packet } if (player.TryRemoveMoney((int)warpInfo.Costs)) { player.WarpTo(warpInfo.Gate); } // todo: else maybe send failed packet? }
/// <summary> /// Warps the player. /// </summary> /// <param name="player">The player.</param> /// <param name="warpInfo">The warp information.</param> public void WarpTo(Player player, WarpInfo warpInfo) { if (warpInfo.LevelRequirement <= player.Attributes[Stats.Level] && player.TryRemoveMoney(warpInfo.Costs)) { player.WarpTo(warpInfo.Gate); } else { // no further action required. } }
/// <inheritdoc/> public override void HandlePacket(Player player, byte[] packet) { if (packet[3] != 2) ////is always 2 i guess? { return; } ushort warpInfoId = NumberConversionExtensions.MakeWord(packet[8], packet[9]); WarpInfo warpInfo = this.GetWarpInfo(warpInfoId); this.warpAction.WarpTo(player, warpInfo); }
public static Image <Gray, byte> GeneratePatch( Image <Gray, byte> frame, IBoundingBox bb, WarpInfo warpInfo, double gaussianSigma, Size newSize ) { Image <Gray, byte> patch; // warp if (warpInfo != null) { patch = GenerateSimilarPatch(frame, bb, warpInfo.MaxShift, warpInfo.MaxScale, warpInfo.MaxAngle); } else { patch = frame.GetPatch(bb.Center, Size.Round(bb.Size)); } // add noise if (gaussianSigma != 0) { double sigmaX = gaussianSigma * patch.Width; double sigmaY = gaussianSigma * patch.Height; CvInvoke.cvSmooth( patch, patch, SMOOTH_TYPE.CV_GAUSSIAN, 0, 0, sigmaX, sigmaY ); } // resize if (newSize != Size.Empty) { patch = patch.Resize(newSize.Width, newSize.Height, INTER.CV_INTER_LINEAR); } return(patch); }
private void UpdateWarpInfo(ControlPointsControl.ControlPoint controlPointData) { if (ActiveProjector == null) { WarpInfo.Visibility = Visibility.Hidden; return; } WarpInfo.Visibility = Visibility.Visible; WarpInfo.Update(controlPointData); var distanceFromProjector = 50; if (ActiveProjector == _projectors[0]) { Canvas.SetLeft(WarpInfo, ActiveProjector.Projector.Resolution.Width + distanceFromProjector); } else { Canvas.SetLeft(WarpInfo, ActiveProjector.Projector.Resolution.Width - ActiveProjector.Projector.Overlap - distanceFromProjector - WarpInfo.Width); } }
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(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(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; } }