public static void Run(string json, string link, bool enabled) { try { if (!enabled) { return; } if (DebugLevel >= 2) { Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] Creating POST request to {link}"); } var formData = Encoding.UTF8.GetBytes(json); var www = new WWW(link, formData); SvMan.StartCoroutine(WaitForRequest(www)); if (DebugLevel >= 2) { Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] Post request sent!"); } } catch (Exception ex) { ErrorLogging.Run(ex); } }
public static void WriteToFile(string fileName, string websiteLink, Action <bool> callback) { SvMan.StartCoroutine(GetContentWWW(websiteLink, new Action <string>((output) => { if (output != null) { File.WriteAllText(fileName, output); } callback?.Invoke(output != null); }))); }
public static void Run(SvPlayer player, string message) { var arg1 = GetArgument.Run(1, false, true, message); if (string.IsNullOrEmpty(arg1.Trim())) { player.SendChatMessage(ArgRequired); return; } if (!Variables.KitsHandler.List.Any(x => x.Name == arg1)) { player.SendChatMessage($"<color={errorColor}>That kit doesn't exist.</color>"); return; } var obj = Variables.KitsHandler.List.FirstOrDefault(x => x.Name == arg1); if (!HasPermission.Run(player, obj.ExecutableBy, false, player.player.job.jobIndex)) { player.SendChatMessage($"<color={errorColor}>You do not have access to that kit.</color>"); return; } if (obj.Disabled) { player.SendChatMessage($"<color={errorColor}>That kit is currently disabled.</color>"); return; } if (obj.CurrentlyInCooldown.ContainsKey(player.player.username)) { player.SendChatMessage($"<color={errorColor}>You already used this kit. Please wait</color> <color={argColor}>{obj.CurrentlyInCooldown[player.player.username]}</color> <color={errorColor}>second(s) before executing this command again.</color>"); return; } if (obj.Price > 0) { if (player.player.MyMoneyCount() < obj.Price) { player.SendChatMessage($"<color={errorColor}>You do not have enough money to get this kit. (You have: {player.player.MyMoneyCount()} | Needed: {obj.Price})</color>"); return; } player.player.TransferMoney(DeltaInv.RemoveFromMe, obj.Price, true); } foreach (var item in obj.Items) { player.player.TransferItem(DeltaInv.AddToMe, item.Id, item.Amount, true); } if (obj.Delay > 0) { SvMan.StartCoroutine(Variables.KitsHandler.StartCooldown(player.player.username, obj)); } player.SendChatMessage($"<color={infoColor}>You've been given the kit</color> <color={argColor}>{arg1}</color><color={infoColor}>.{(obj.Delay > 0 ? $" You can get this kit again in {obj.Delay} seconds." : "")}</color>"); }
void SetupDelayable(JsonType obj) { if (!(obj is IExpandableFileDelayable objDelayable)) { return; } foreach (var player in objDelayable.CurrentlyInCooldown.ToList()) { if (player.Value <= 0) { objDelayable.CurrentlyInCooldown.Remove(player.Key); continue; } SvMan.StartCoroutine(StartCooldown(player.Key, obj, player.Value)); } }
public static void Run(SvPlayer player, string message) { var arg1 = GetArgument.Run(1, false, true, message); if (string.IsNullOrEmpty(arg1.Trim())) { player.SendChatMessage(ArgRequired); return; } if (!Variables.WarpHandler.List.Any(x => x.Name == arg1)) { player.SendChatMessage($"<color={errorColor}>That warp doesn't exist.</color>"); return; } var obj = Variables.WarpHandler.List.FirstOrDefault(x => x.Name == arg1); if (!HasPermission.Run(player, obj.ExecutableBy, false, player.player.job.jobIndex)) { player.SendChatMessage($"<color={errorColor}>You do not have access to that warp.</color>"); return; } if (obj.Disabled) { player.SendChatMessage($"<color={errorColor}>That warp is currently disabled.</color>"); return; } if (obj.CurrentlyInCooldown.ContainsKey(player.player.username)) { player.SendChatMessage($"<color={errorColor}>You already went to that warp. Please wait</color> <color={argColor}>{obj.CurrentlyInCooldown[player.player.username]}</color> <color={errorColor}>second(s) before executing this command again.</color>"); return; } if (obj.Price > 0) { if (player.player.MyMoneyCount() < obj.Price) { player.SendChatMessage($"<color={errorColor}>You do not have enough money to pay for this warp. (You have: {player.player.MyMoneyCount()} | Needed: {obj.Price})</color>"); return; } player.player.TransferMoney(DeltaInv.RemoveFromMe, obj.Price, true); } player.ResetAndSavePosition(new Vector3(obj.Position.X, obj.Position.Y, obj.Position.Z), new Quaternion(obj.Rotation.X, obj.Rotation.Y, obj.Rotation.Z, obj.Rotation.W), obj.Position.PlaceIndex); if (obj.Delay > 0) { SvMan.StartCoroutine(Variables.WarpHandler.StartCooldown(player.player.username, obj)); } player.SendChatMessage($"<color={infoColor}>You've been teleported to the warp named</color> <color={argColor}>{arg1}</color><color={infoColor}>.{(obj.Delay > 0 ? $" You can teleport to this warp again in {obj.Delay} seconds." : "")}</color>"); }