Example #1
0
 public static void Sleep(Vector3 position)
 {
     Ped[] peds = World.GetNearbyPeds(position, 50f).Where(IsEnemy).ToArray();
     if (!peds.Any())
     {
         TimeSpan time = World.CurrentDayTime + new TimeSpan(0, 8, 0, 0);
         Game.Player.Character.IsVisible      = false;
         Game.Player.CanControlCharacter      = false;
         Game.Player.Character.FreezePosition = true;
         Game.FadeScreenOut(2000);
         Script.Wait(2000);
         World.CurrentDayTime                 = time;
         Game.Player.Character.IsVisible      = true;
         Game.Player.CanControlCharacter      = true;
         Game.Player.Character.FreezePosition = false;
         Game.Player.Character.ClearBloodDamage();
         Weather randWeather = RandoMath.GetRandomElementFromArray(Map.weathers);
         World.Weather = randWeather;
         Character.currentEnergyLevel  = 1f;
         Character.currentHungerLevel -= 0.15f;
         Character.currentThirstLevel -= 0.25f;
         Script.Wait(2000);
         Game.FadeScreenIn(2000);
     }
     else
     {
         UI.Notify("You cannot sleep here as there are ~r~hostiles~w~ nearby!");
     }
 }
Example #2
0
        public void VehicleSpawn(Vector3 position, float heading)
        {
            int tempMaxVehicles = maxVehicles;

            if (IsCityZone(Game.Player.Character.Position))
            {
                tempMaxVehicles = maxVehicles * 2;
            }
            if (vehicleCount >= tempMaxVehicles || position == Vector3.Zero || Extensions.DistanceBetweenV3(position, startingLoc) < minSpawnDistance || Extensions.DistanceBetweenV3(position, Game.Player.Character.Position) < minSpawnDistance)
            {
                return;
            }
            else
            {
                var model   = GetRandomVehicleModel();
                var vehicle = Extensions.SpawnVehicle(model, position, heading);
                int rnd     = RandoMath.CachedRandom.Next(0, 100);
                if (rnd <= 10)
                {
                    vehicle.EngineHealth = 1000.0f;
                }
                else
                {
                    vehicle.EngineHealth = 0.0f;
                }
                vehicle.DirtLevel = 14.0f;
                var vehicleDoors = vehicle.GetDoors();
                for (int i = 0; i < 5; i++)
                {
                    var door = RandoMath.GetRandomElementFromArray(vehicleDoors);
                    vehicle.OpenDoor(door, false, true);
                }
                for (int i = 0; i < 3; i++)
                {
                    List <int> windows = new List <int>();
                    if (Function.Call <bool>(Hash.IS_VEHICLE_WINDOW_INTACT, vehicle.Handle, i))
                    {
                        windows.Add(i);
                    }
                    if (windows.Count > 0)
                    {
                        int window = RandoMath.GetRandomElementFromList(windows);
                        Function.Call(Hash.SMASH_VEHICLE_WINDOW, vehicle.Handle, window);
                    }
                }
            }
        }
        public void Setup()
        {
            Function.Call(Hash.ADD_SCENARIO_BLOCKING_AREA, -10000.0f, -10000.0f, -1000.0f, 10000.0f, 10000.0f, 1000.0f, 0, 1, 1, 1);
            Function.Call(Hash.CLEAR_AREA, Game.Player.Character.Position.X, Game.Player.Character.Position.Y, Game.Player.Character.Position.Z, 1000F, false, false, false, false);
            Function.Call(Hash.SET_CREATE_RANDOM_COPS, false);
            Function.Call(Hash.SET_RANDOM_BOATS, false);
            Function.Call(Hash.SET_RANDOM_TRAINS, false);
            Function.Call(Hash.SET_GARBAGE_TRUCKS, false);
            Function.Call(Hash.DELETE_ALL_TRAINS);
            Function.Call(Hash.SET_PED_POPULATION_BUDGET, 0);
            Function.Call(Hash.SET_VEHICLE_POPULATION_BUDGET, 0);
            Function.Call(Hash.SET_ALL_LOW_PRIORITY_VEHICLE_GENERATORS_ACTIVE, false);
            Function.Call(Hash.SET_NUMBER_OF_PARKED_VEHICLES, 0);
            Function.Call((Hash)0xF796359A959DF65D, false);
            Function.Call(Hash.DISABLE_VEHICLE_DISTANTLIGHTS, true);
            Ped[] all_ped = World.GetAllPeds();
            if (all_ped.Length > 0)
            {
                foreach (Ped ped in all_ped)
                {
                    ped.Delete();
                }
            }
            Vehicle[] all_vecs = World.GetAllVehicles();
            if (all_vecs.Length > 0)
            {
                foreach (Vehicle vehicle in all_vecs)
                {
                    vehicle.Delete();
                }
            }
            World.SetBlackout(true);
            Weather rndWeather = RandoMath.GetRandomElementFromArray(weathers);

            World.TransitionToWeather(rndWeather, 0f);
            Function.Call(Hash.SET_CLOCK_TIME, 07, 00, 00);
            Function.Call(Hash.SET_CLOCK_DATE, 01, 01, 20);
        }
        public void Setup()
        {
            playerOldMaxWantedLevel = Game.MaxWantedLevel;
            playerOldMoney          = Game.Player.Money;
            playerOldPosition       = Game.Player.Character.Position;
            playerOldHeading        = Game.Player.Character.Heading;
            playerOldModel          = Game.Player.Character.Model;
            playerOldWeapons        = Game.Player.Character.Weapons;
            Game.MaxWantedLevel     = 0;
            Game.Player.WantedLevel = 0;
            Game.Player.Money       = 0;
            Model characterModel;

            PedHash[] characterMaleModels   = { PedHash.FreemodeMale01 };
            PedHash[] characterFemaleModels = { PedHash.FreemodeFemale01 };
            PedHash[] characterModels;
            if (playerGender == Gender.Male)
            {
                characterModels = characterMaleModels;
            }
            else
            {
                characterModels = characterFemaleModels;
            }
            characterModel = new Model(RandoMath.GetRandomElementFromArray(characterModels));
            characterModel.Request(500);
            if (characterModel.IsInCdImage && characterModel.IsValid)
            {
                while (!characterModel.IsLoaded)
                {
                    Script.Wait(100);
                }
                Function.Call(Hash.SET_PLAYER_MODEL, Game.Player, characterModel.Hash);
                if (playerGender == Gender.Male)
                {
                    Function.Call(Hash.SET_PED_HEAD_BLEND_DATA, Game.Player.Character.Handle, 44, 44, 0, 44, 44, 0, 1.0f, 1.0f, 0.0f, true);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 3, 12, 0, 0);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 4, 1, 0, 0);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 8, 0, 0, 0);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 11, 233, 0, 0);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 6, 24, 0, 0);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 2, 12, 0, 0);
                    Function.Call(Hash._SET_PED_HAIR_COLOR, Game.Player.Character.Handle, 57, 58);
                    Function.Call(Hash._SET_PED_EYE_COLOR, Game.Player.Character.Handle, 3);
                    Function.Call(Hash.SET_PED_HEAD_OVERLAY, Game.Player.Character.Handle, 1, 0, 1.0f);
                    Function.Call(Hash.SET_PED_HEAD_OVERLAY, Game.Player.Character.Handle, 2, 1, 1.0f);
                    Function.Call(Hash._SET_PED_HEAD_OVERLAY_COLOR, Game.Player.Character.Handle, 1, 1, 57, 58);
                    Function.Call(Hash._SET_PED_HEAD_OVERLAY_COLOR, Game.Player.Character.Handle, 2, 1, 57, 58);
                }
                else
                {
                    Function.Call(Hash.SET_PED_HEAD_BLEND_DATA, Game.Player.Character.Handle, 33, 33, 0, 33, 33, 0, 1.0f, 1.0f, 0.0f, true);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 2, 4, 0, 0);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 11, 243, 0, 0);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 3, 7, 0, 0);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 8, 0, 0, 0);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 6, 24, 0, 0);
                    Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Game.Player.Character.Handle, 4, 84, 0, 0);
                    Function.Call(Hash._SET_PED_HAIR_COLOR, Game.Player.Character.Handle, 11, 11);
                    Function.Call(Hash._SET_PED_EYE_COLOR, Game.Player.Character.Handle, 3);
                    Function.Call(Hash.SET_PED_HEAD_OVERLAY, Game.Player.Character.Handle, 2, 1, 1.0f);
                    Function.Call(Hash._SET_PED_HEAD_OVERLAY_COLOR, Game.Player.Character.Handle, 2, 1, 11, 11);
                }
            }
            characterModel.MarkAsNoLongerNeeded();
            Game.Player.Money = 0;
            Game.Player.Character.Position = new Vector3(478.8616f, -921.53f, 38.77953f);
            Game.Player.Character.Heading  = 266;
            var model = new Model("prop_beach_fire");

            model.Request(250);
            if (model.IsInCdImage && model.IsValid)
            {
                while (!model.IsLoaded)
                {
                    Script.Wait(50);
                }
                var CFpos = new Vector3(482.3683f, -921.3369f, 37.2f);
                campFire = World.CreateProp(model, CFpos, true, false);
            }
            model.MarkAsNoLongerNeeded();
            campFire.AddBlip();
            campFire.CurrentBlip.Sprite = (BlipSprite)436;
            campFire.CurrentBlip.Color  = BlipColor.Yellow;
            campFire.CurrentBlip.Name   = "Campfire";
            var model2 = new Model("prop_skid_tent_01");

            model2.Request(250);
            if (model2.IsInCdImage && model2.IsValid)
            {
                while (!model2.IsLoaded)
                {
                    Script.Wait(50);
                }
                var Tpos = new Vector3(478.2682f, -925.3043f, 36.8f);
                tent         = World.CreateProp(model2, Tpos, true, false);
                tent.Heading = 135;
            }
            model2.MarkAsNoLongerNeeded();
            tent.AddBlip();
            tent.CurrentBlip.Sprite = BlipSprite.CaptureHouse;
            tent.CurrentBlip.Color  = BlipColor.Blue;
            tent.CurrentBlip.Name   = "Tent";
            var model3 = new Model("prop_const_fence02a");

            model3.Request(250);
            if (model3.IsInCdImage && model3.IsValid)
            {
                while (!model3.IsLoaded)
                {
                    Script.Wait(50);
                }
                var Bpos = new Vector3(418.9457f, -890.5727f, 28.4f);
                barrier         = World.CreateProp(model3, Bpos, true, false);
                barrier.Heading = 270;
            }
            model3.MarkAsNoLongerNeeded();
            var model4 = new Model("prop_dumpster_02a");

            model4.Request(250);
            if (model4.IsInCdImage && model4.IsValid)
            {
                while (!model4.IsLoaded)
                {
                    Script.Wait(50);
                }
                var Dpos = new Vector3(459.4905f, -933.745f, 31.2f);
                dumpster         = World.CreateProp(model4, Dpos, true, false);
                dumpster.Heading = 270;
            }
            model4.MarkAsNoLongerNeeded();
            ResetCharacter();
        }