public static VehicleJson FromJson(string json)
        {
            Debug.Log("Loading vehicle from json...");

            VehicleJson vehicleJson = JsonConvert.DeserializeObject <VehicleJson>(json);

            return(vehicleJson);
        }
        public string ToJson()
        {
            Player player = Game.Player;
            Ped    ped    = Game.Player.Character;

            GameWeather = World.Weather;
            GameDate    = DateTimeManager.CurrentDate;
            GameTime    = DateTimeManager.CurrentTime;

            OnFootCameraMode    = Function.Call <int>(GTA.Native.Hash.GET_FOLLOW_PED_CAM_VIEW_MODE);
            InVehicleCameraMode = Function.Call <int>(GTA.Native.Hash.GET_FOLLOW_VEHICLE_CAM_VIEW_MODE);

            Money     = player.Money;
            Bank      = 0;
            Hash      = ped.Model.Hash;
            X         = ped.Position.X;
            Y         = ped.Position.Y;
            Z         = ped.Position.Z;
            Heading   = ped.Heading;
            Health    = ped.HealthFloat;
            MaxHealth = ped.MaxHealthFloat;
            Armor     = ped.ArmorFloat;

            // loadout
            Weapon  = ped.Weapons.Current.Hash;
            Weapons = new LoadoutJson();
            Weapons.SetWeapons(ped);

            if (ped.CurrentVehicle != null)
            {
                PlayerManager.CurrentPlayerVehicle = ped.CurrentVehicle;
            }
            else if (ped.LastVehicle != null)
            {
                PlayerManager.CurrentPlayerVehicle = ped.LastVehicle;
            }

            if (PlayerManager.CurrentPlayerVehicle != null && !PlayerManager.CurrentPlayerVehicle.IsAlive)
            {
                PlayerManager.CurrentPlayerVehicle = null;
            }

            if (PlayerManager.CurrentPlayerVehicle != null && PlayerManager.CurrentPlayerVehicle.Exists())
            {
                CurrentVehicle = new VehicleJson();
                CurrentVehicle.SetVehicle(PlayerManager.CurrentPlayerVehicle);
            }

            return(JsonConvert.SerializeObject(this));
        }
 public PlayerJson()
 {
     Weapons        = null;
     CurrentVehicle = null;
 }