Esempio n. 1
0
 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);
     }
 }
Esempio n. 2
0
 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);
     })));
 }
Esempio n. 3
0
        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>");
        }
Esempio n. 4
0
 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));
     }
 }
Esempio n. 5
0
        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>");
        }
        public static void Run(SvPlayer player, string message)
        {
            string arg1 = GetArgument.Run(1, false, true, message);

            if (string.IsNullOrEmpty(arg1))
            {
                player.SendChatMessage(ArgRequired);
                return;
            }
            bool parsedSuccessfully = int.TryParse(arg1, out int arg1int);

            if (!parsedSuccessfully)
            {
                player.SendChatMessage(NotValidArg);
                return;
            }
            if (arg1int < 0 || arg1int > IDs_Vehicles.Length)
            {
                player.SendChatMessage($"<color={errorColor}>Error: The ID must be between 1 and {IDs_Vehicles.Length}.</color>");
                return;
            }
            var shPlayer = player.player;
            var pos      = shPlayer.GetPosition();

            if (!player.player.IsOutside())
            {
                player.SendChatMessage($"<color={errorColor}>Cannot spawn inside a building.</color>");
                return;
            }
            if (arg1.Length > 4)
            {
                SvMan.AddNewEntity(ShManager.GetEntity(arg1int), shPlayer.manager.places[0], new Vector3(pos.x, pos.y + 10F, pos.z), shPlayer.GetRotation(), false);
            }
            else
            {
                SvMan.AddNewEntity(ShManager.GetEntity(IDs_Vehicles[arg1int - 1]), shPlayer.manager.places[0], new Vector3(pos.x, pos.y + 7F, pos.z), shPlayer.GetRotation(), false);
            }
            player.SendChatMessage($"<color={infoColor}>Spawning in vehicle with the ID: </color><color={argColor}>{arg1}</color>");
        }