Ejemplo n.º 1
2
 public static bool IsVehicleEmpty(Vehicle veh)
 {
     if (veh == null) return true;
     if (!veh.IsSeatFree(VehicleSeat.Driver)) return false;
     for (int i = 0; i < veh.PassengerSeats; i++)
     {
         if (!veh.IsSeatFree((VehicleSeat)i))
             return false;
     }
     return true;
 }
Ejemplo n.º 2
0
        public static int GetRPMColor(GTA.Vehicle entity)
        {
            double CurrentRPM = Math.Round((double)entity.CurrentRPM, 2);
            int    RPMColor;

            if (CurrentRPM <= 0.25)
            {
                RPMColor = 6;
            }
            else if (CurrentRPM <= 0.60)
            {
                RPMColor = 3;
            }
            else if (CurrentRPM <= 0.80)
            {
                RPMColor = 7;
            }
            else if (CurrentRPM <= 0.95)
            {
                RPMColor = 5;
            }
            else
            {
                RPMColor = 4;
            }
            return(RPMColor);
        }
Ejemplo n.º 3
0
 public void AddVehicle(Vehicle v)
 {
     if (vehs.Add(v))
     {
         AmoutCars++;
     }
 }
Ejemplo n.º 4
0
 public static void AddVehicle(Vehicle p)
 {
     if (!_vehicleCache.ContainsKey(p.Handle))
     {
         _vehicleCache.Add(p.Handle, p);
     }
 }
 public override void StreamIn()
 {
     gameReference = World.CreateVehicle(new Model(model), position);
     gameReference.RotationQuaternion = orientation;
     will_respawn = false;
     Client.instance.prepareVehicle(this);
 }
        public Engine GetEngine( Vehicle vehicle )
        {
            if ( vehicle == null || !this.IsEnable( vehicle ) )
            {
                return null;
            }
            EngineData engineData;
            if ( this._vehicles.ContainsKey( vehicle.Handle ) )
            {
                engineData = this._vehicles[ vehicle.Handle ];
                engineData.UpdateUsage();
            }
            else
            {
                if ( this._vehicles.Count > this._maxSize )
                {
                    this._vehicles.Remove( this._vehicles.Last().Key );
                }

                engineData = new EngineData( new Engine( vehicle.EngineRunning ? 30 : 0, vehicle ), DateTime.Now );
                this._vehicles.Add( vehicle.Handle, engineData );
            }
            this.Sort();
            return engineData.Engine;
        }
Ejemplo n.º 7
0
        private void MOD_Tick(object sender, EventArgs e)
        {
            if (ActiveFlag)
            {
                V = GTA.World.CreateVehicle("BLISTA", Player.Character.Position.Around(5.0f));
                if (!Exists(V)) { return; }

                if (Exists(V)) { V.NoLongerNeeded(); }

                V.CreatePedOnSeat(VehicleSeat.Driver);
                V.CreatePedOnSeat(VehicleSeat.RightFront);

                peds[0] = V.GetPedOnSeat(VehicleSeat.Driver);
                peds[1] = V.GetPedOnSeat(VehicleSeat.RightFront);

                for (int i = 0; i < 2; i++)
                {
                    if (Exists(peds[i]))
                    {
                        peds[i].NoLongerNeeded();
                    }
                }

                V = null;
                ActiveFlag = false;
            }
        }
Ejemplo n.º 8
0
 public DamageBars()
 {
     NowV = null;
     Interval = 50;
     this.Tick += new EventHandler(this.Bombat_Tick);
     this.PerFrameDrawing += new GraphicsEventHandler(this.Kyori_PerFrameDrawing);
 }
Ejemplo n.º 9
0
 public static int GetFreePassengerSeat(Vehicle veh)
 {
     if (veh == null) return -3;
     for (int i = 0; i < veh.PassengerSeats; i++) {
         if (veh.IsSeatFree((VehicleSeat)i))
             return i;
     }
     return -3;
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Initialize the class
 /// </summary>
 /// <param name="baseVehicle">Target vehicle</param>
 /// <param name="dropInterval">Interval between flares</param>
 /// <param name="maxDropTime">Max time to drop flares</param>
 /// <param name="dropOffset">Spawn offset relative to base vehicle</param>
 /// <param name="forceType">The type of directional force to apply on spawn</param>
 /// <param name="forceMultiplier">Force multiplier</param>
 public IRFlareSequence(Vehicle baseVehicle, int dropInterval, int maxDropTime, Vector3 dropOffset, ForceType forceType, float forceMultiplier)
 {
     this.baseVehicle = baseVehicle;
     this.dropInterval = dropInterval;
     this.maxDropTime = maxDropTime;
     this.dropOffset = dropOffset;
     this.forceType = forceType;
     this.forceMultiplier = forceMultiplier;
 }
Ejemplo n.º 11
0
 public static Dictionary<int, int> GetVehicleMods(Vehicle veh)
 {
     var dict = new Dictionary<int, int>();
     for (int i = 0; i < 50; i++)
     {
         dict.Add(i, veh.GetMod((VehicleMod)i));
     }
     return dict;
 }
Ejemplo n.º 12
0
 public CarpetBomb(Vehicle vehicle, Vector3 dropOffset)
 {
     this.vehicle = vehicle;
     this.dropTimer = new Timer(300);
     this.dropOffset = dropOffset;
     this.updatedVel = new Vector3();
     this.bombs = new List<Bomb>();
     this.bombsDropped = 0;
     this.bombSoundID = -1;
 }
Ejemplo n.º 13
0
        private bool IsTaxi(Vehicle vec)
        {
            Model model = vec.Model;

            if ((long)(model.Hash) == 3338918751 || model.Hash == 0x480DAF95 ||model.Hash == -956048545 || model.Hash == 1884962369 ||  model == Model.TaxiCarModel)
            {
                return true;
            }
            return false;
        }
Ejemplo n.º 14
0
        private void Bakurai_Tick(object sender, EventArgs e)
        {
            if(Game.isGameKeyPressed(GameKey.Attack) && !Player.Character.isInVehicle()){
                car = GTA.World.GetClosestVehicle(Player.Character.Position, 10.0f);
                if (Exists(car))
                {

                }
            }
        }
Ejemplo n.º 15
0
 public void prepareVehicle(Vehicle vehicle)
 {
     if (vehicle.Exists())
     {
         vehicle.EngineRunning = true;
         vehicle.InteriorLightOn = true;
         vehicle.HazardLightsOn = true;
         vehicle.Repair();
     }
 }
Ejemplo n.º 16
0
        public static string GetRPMText(GTA.Vehicle entity)
        {
            var length    = (int)(entity.CurrentRPM * 20);
            var RpmString = "|";

            if (length > 0)
            {
                RpmString = new string('|', length);
            }

            RpmString += new string('|', new Random().Next(2));
            return(RpmString);
        }
Ejemplo n.º 17
0
        private void LoadVehicle(VehicleModel m)
        {
            myMenu.Visible = false;

            GTA.Vehicle vehicle = GTA.World.CreateVehicle(
                new GTA.Model(m.VehicleHash), // or straight m.VehicleHash,
                Game.Player.Character.Position + Game.Player.Character.ForwardVector * 4.0f,
                Game.Player.Character.Heading + 90
                );


            m.ApplyToVehicle(vehicle);
            vehicle.PlaceOnGround();
        }
Ejemplo n.º 18
0
 void GetSquadIntoVehicle(List<Entity> Squad, Vehicle Vehicle)
 {
     int max_seats = Function.Call<int>(Hash.GET_VEHICLE_MAX_NUMBER_OF_PASSENGERS, Vehicle);
     for (int i = -1; i < max_seats; i++)
     {
         if (i == Squad.Count - 1)
         {
             break;
         }
         if (Function.Call<bool>(Hash.IS_VEHICLE_SEAT_FREE, Vehicle, i) && (CanWeUse(Squad[i + 1])))
         {
             Function.Call<bool>(Hash.TASK_ENTER_VEHICLE, Squad[i + 1], Vehicle, -1, i, 2.0, 16, 0);
         }
     }
 }
Ejemplo n.º 19
0
        protected override void depopulateDestructibleElements(bool removePhysicalElements = false)
        {
            if (vehicle != null && vehicle.Exists())
            {
                if (vehicle.CurrentBlip != null)
                {
                    vehicle.CurrentBlip.Remove();
                }

                if (removePhysicalElements)
                {
                    vehicle.Delete();
                    vehicle = null;
                }
            }
        }
Ejemplo n.º 20
0
        public static Vehicle GetVehicle(int handle)
        {
            Vehicle r = null;

            if (handle == 0 || handle == -1)
            {
                return r;
            }

            if (!_vehicleCache.TryGetValue(handle, out r))
            {
                r = new Vehicle(handle);
                AddVehicle(r);
            }

            return r;
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Returns a comprehensive name for the vehicle.
        /// </summary>
        /// <param name="veh">Vehicle</param>
        /// <param name="showClassName">Set to true to show the class name</param>
        /// <returns>[Model of the vehicle] - [Plate's number] ([Class name of the vehicle])</returns>
        public static string GetVehicleFriendlyName(GTA.Vehicle veh, bool showClassName = true)
        {
            string friendlyname = "";

            int modelClass = Function.Call<int>(Hash.GET_VEHICLE_CLASS_FROM_NAME, veh.Model.Hash);
            string modelClassName = Game.GetGXTEntry("VEH_CLASS_" + modelClass.ToString());

            string model = Function.Call<string>(Hash.GET_DISPLAY_NAME_FROM_VEHICLE_MODEL, veh.Model.Hash);
            string modelName = Game.GetGXTEntry(model);

            if (showClassName)
                friendlyname = modelName + " - " + veh.NumberPlate + " (" + modelClassName + ")";
            else
                friendlyname = modelName + " - " + veh.NumberPlate;

            return friendlyname;
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Check if the vehicle is the player "official" vehicle (the one with the colored blip).
        /// </summary>
        /// <param name="veh">Vehicle to check</param>
        /// <returns>True if the vehicle is an official player vehicle</returns>
        public static bool IsPlayerOfficialVehicle(GTA.Vehicle veh)
        {
            // Michael
            if ((uint)veh.Model.Hash == (uint)VehicleHash.Tailgater && veh.NumberPlate == "5MDS003 ")
                return true;

            // Franklin
            if (((uint)veh.Model.Hash == (uint)VehicleHash.Buffalo2 && veh.NumberPlate == " FC1988 ") ||
                ((uint)veh.Model.Hash == (uint)VehicleHash.Bagger && veh.NumberPlate == "  FC88  "))
                return true;

            // Trevor
            if ((uint)veh.Model.Hash == (uint)VehicleHash.Bodhi2 && veh.NumberPlate == "BETTY 32")
                return true;

            return false;
        }
Ejemplo n.º 23
0
		public Rival(Vector3 pos, float heading, Model car)
		{
			Character = World.CreateRandomPed(pos);
			Vehicle = World.CreateVehicle(car, pos, heading);
			Function.Call(Hash.SET_PED_INTO_VEHICLE, Character.Handle, Vehicle.Handle, (int)VehicleSeat.Driver);
			Vehicle.IsPersistent = false;
			Vehicle.FreezePosition = true;

            Function.Call(Hash.SET_VEHICLE_MOD_KIT, Vehicle.Handle, 0);
            Vehicle.SetMod(VehicleMod.Engine, 3, false);
            Vehicle.SetMod(VehicleMod.Brakes, 2, false);
            Vehicle.SetMod(VehicleMod.Transmission, 2, false);
            Vehicle.SetMod(VehicleMod.Suspension, 3, false);
            
			Character.MaxDrivingSpeed = 500f;
			Character.DrivingStyle = (DrivingStyle)MainDrivingStyle;
			Character.DrivingSpeed = 200f;
            Function.Call(Hash.SET_DRIVER_ABILITY, Character.Handle, 100f);
        }
Ejemplo n.º 24
0
        private void Bombat_Tick(object sender, EventArgs e)
        {
            v = player.CurrentVehicle;
            if (!Exists(v))
            {
                Reset();
                return;
            }
            float Body = v.Health;
            float Petrol = v.PetrolTankHealth;
            float Engine = v.EngineHealth;

            SetAlls(bod,Body);
            SetAlls(pet, Petrol);
            SetAlls(eng, Engine);

            Old[bod] = Body;
            Old[pet] = Petrol;
            Old[eng] = Engine;
        }
Ejemplo n.º 25
0
        private void Bombat_Tick(object sender, EventArgs e)
        {
            pV = Player.Character.CurrentVehicle;
            if (Exists(pV))
            {
                float dB, dE, dP;
                dB = OldB - pV.Health;
                dE = OldE - pV.EngineHealth;
                dP = OldP - pV.PetrolTankHealth;

                if (dB > 0)
                {
                    B.AddDamage(dB);
                }
                if (dE > 0 && pV.EngineHealth>0)
                {
                    E.AddDamage(dE);
                }
                if (dP > 0 && pV.PetrolTankHealth>0)
                {
                    P.AddDamage(dP);
                }
                OldB = pV.Health;
                OldE = pV.EngineHealth;
                OldP = pV.PetrolTankHealth;

                E.Decrease();
                P.Decrease();
                B.Decrease();

            }
            else
            {
                E.Reset();
                P.Reset();
                B.Reset();
                OldB = 0;
                OldE = 0;
                OldP = 0;
            }
        }
Ejemplo n.º 26
0
        void Bombat_KeyDown(object sender, GTA.KeyEventArgs e)
        {
            inputCheckerBomb.AddInputKey(e.Key);

            if (inputCheckerBomb.Check(0) == true)
            {
                if (AllF)
                {
                    Game.DisplayText("Heli OFF", 4000);
                    AllF = false;
                    Reset();

                }
                else
                {
                    Game.DisplayText("Heli ON", 4000);
                    AllF = true;
                    heli = null;
                    driver = null;
                }
            }
        }
Ejemplo n.º 27
0
        private void Bombat_Tick(object sender, EventArgs e)
        {
            if (Player.Character.isInVehicle())
            {

                if (NowV == null || NowV != Player.Character.CurrentVehicle)
                {
                    NowV = Player.Character.CurrentVehicle;

                    xP = cP = NowV.PetrolTankHealth;
                    xE = cE = NowV.EngineHealth;
                    xB = cB = NowV.Health;
                }
                if (cP != NowV.PetrolTankHealth && NowV.PetrolTankHealth>=0.0f) { cP = NowV.PetrolTankHealth; dP = 0; }
                if (cB != NowV.Health && NowV.Health >=0.0f) { cB = NowV.Health; dB = 0; }
                if (cE != NowV.EngineHealth && NowV.EngineHealth>0.0f) { cE = NowV.EngineHealth; dE = 0; }
            }
            else
            {
                NowV = null;
            }
        }
Ejemplo n.º 28
0
        public void OnKeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.F2)
                foreach (var v in World.GetNearbyVehicles(Game.Player.Character.Position, 10))
                    v.Delete();

            if (e.KeyCode == Keys.K)
                Function.Call(Hash.SET_TIME_SCALE, 1.0f);
            if (e.KeyCode == Keys.F3)
                Game.Player.Character.Position = _busPosition;

            if (e.KeyCode == Keys.J && _isTransitioning)
            {
                _driver.Delete();
                Game.Player.Character.SetIntoVehicle(Game.Player.Character.CurrentVehicle, VehicleSeat.Driver);
                Function.Call(Hash.SET_TIME_SCALE, 1f);
                _isTransitioning = false;
            }

            if (e.KeyCode == Keys.F && World.GetDistance(Game.Player.Character.Position, _startPosition) < 2f &&
                !_activateMod)
            {
                //Check for previous spawned busses
                foreach (var b in World.GetActiveBlips().Where(b => (b.Color == BlipColor.Blue)))
                    b.Remove();
                foreach (
                    var v in
                        World.GetAllVehicles().Where(v => (v.GetPedOnSeat(VehicleSeat.Driver).Model == "A_C_Chimp")))
                    v.Delete();
                _activateMod = true;
                _bus = World.CreateVehicle("Bus", _busPosition);
                _driver =_bus.CreatePedOnSeat(VehicleSeat.Driver, new Model("A_C_Chimp"));
                _busBlip = _bus.AddBlip();
                _busBlip.Color = BlipColor.Blue;
                _busBlip.Name = "Bus";
                _busBlip.ShowRoute = _busBlip.IsFriendly = true;
            }
        }
Ejemplo n.º 29
0
        public RappelEntry(Vector3 helipad, Vector3 target)
        {
            _target = target;
            int counter = 0;
            var mav = new Model(VehicleHash.Polmav);
            do
            {
                mav.Request();
                Script.Yield();
                counter++;
            } while (!mav.IsLoaded && counter < 20000);
            counter = 0;
            var pedmod = new Model(PedHash.Pilot01SMY);
            do
            {
                pedmod.Request();
                Script.Yield();
                counter++;
            } while (!pedmod.IsLoaded && counter < 20000);
            heli = Function.Call<Vehicle>(Hash.CREATE_VEHICLE, mav.Hash, helipad.X, helipad.Y, helipad.Z, 0f, false, false);
            heli.Livery = 0;
            pilot = Function.Call<Ped>(Hash.CREATE_PED, 26, pedmod.Hash, helipad.X, helipad.Y, helipad.Z, 0f, false, false);
            Function.Call(Hash.SET_BLOCKING_OF_NON_TEMPORARY_EVENTS, pilot.Handle, 1);
            Function.Call(Hash.SET_PED_FLEE_ATTRIBUTES, pilot.Handle, 0, 0);
            Function.Call(Hash.SET_PED_COMBAT_ATTRIBUTES, pilot.Handle, 17, 1);
            Function.Call(Hash.SET_PED_INTO_VEHICLE, pilot.Handle, heli.Handle, (int)VehicleSeat.Driver);
            /*
            void TASK_HELI_MISSION(Ped ped, Vehicle vehicle, Any p2, Any p3,
              float posX, float posY, float posZ, int mode, float speed1,
                float radius, float heading, int height1, int height2, float p13, int p14)

            modes:
            0, 1 - no takeoff?
            4 - Get height first, then fly mantaining heading
            6 - fly to point first, achieve heading later.
            20 - ignore height
            */
        }
        public static void CreateDeloreonintruck(Vector3 truckposition)
        {
            if (!(Docstruck == null))
            {
                Docstruck.Delete();
            }
            Model gmcvan = new Model("GMCVAN");
            if (gmcvan.IsValid)
            {
                Docstruck = World.CreateVehicle(gmcvan, truckposition);
                Docstruck.Rotation = new Vector3(0, 0, 102);
                Docstruck.OpenDoor(VehicleDoor.Trunk, false, true);

                Vector3 position = Docstruck.GetOffsetInWorldCoords(new Vector3(0, -10, 0));

                TimeTravel.instantDelorean.Deloreanlist.Add(new TimeCircuits());
                TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon = World.CreateVehicle(new Model("BTTF"), position);
                TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.Rotation = new Vector3(0, 0, 102);
                TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.IsInvincible = true;
                TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.CanBeVisiblyDamaged = false;
                if (!(Doc == null))
                {
                    Doc.Delete();
                }
                Doc = TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.CreatePedOnSeat(VehicleSeat.Driver, new Model("S_M_M_Doctor_01"));
                Doc.RelationshipGroup = (int)Relationship.Companion;

                Einstein = World.CreatePed(PedHash.Chop, Docstruck.GetOffsetInWorldCoords(new Vector3(-20, 0, 0)));
                Einstein.RelationshipGroup = (int)Relationship.Companion;
                Einstein.IsInvincible = true;

                TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.DirtLevel = 0;
                TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.PrimaryColor = VehicleColor.BrushedAluminium;
                TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.SecondaryColor = VehicleColor.BrushedAluminium;
                TimeTravel.instantDelorean.Deloreanlist[TimeTravel.instantDelorean.Deloreanlist.Count - 1].Deloreon.NumberPlate = "OutATime";
            }
        }
Ejemplo n.º 31
0
        private void TextureDrawingExample_PerFrameDrawing(System.Object sender, GTA.GraphicsEventArgs e)
        {
            if (!Player.CanControlCharacter) { return; }
            RectangleF radar = e.Graphics.GetRadarRectangle(FontScaling.Pixel);  // this retrieves the rectangle of the radar on screen
            float size = radar.Width * 0.75f;  // scale the size of the gauge according to the size of the radar

            // calculate the center of the radar
            float radarCenterX = radar.X + radar.Width * 0.5f;
            float radarCenterY = radar.Y + radar.Height * 0.5f;

            Vehicle v = Player.Character.CurrentVehicle;
            if (Exists(v))
            {

                float H, P, E;
                H = v.Health;
                P = v.PetrolTankHealth;
                E = v.EngineHealth;

                if (H > 1000.0f) { H = 1000.0f; }
                if (H < 0.0f) { H = 0.0f; }

                if (P > 1000.0f) { P = 1000.0f; }
                if (P < 0.0f) { P = 0.0f; }

                if (E > 1000.0f) { E = 1000.0f; }
                if (E < 0.0f) { E = 0.0f; }

                float body = (H / 1000.0f) * (float)Math.PI;  // here we calulate the radians required for the rotation of the needle
                float Petro = P * (float)Math.PI / 1000;
                float Engine = E * (float)Math.PI / 1000;

                e.Graphics.Scaling = FontScaling.Pixel;  // Pixel is the default setting, but you could also use any other scaling instead

                // The gauge itself is easy to draw, since no rotation is required. The upper left corner of the image is at the center of the radar.
                // The source images only use white color. This allows us to draw the image in any color we want using the last parameter.
                //e.Graphics.DrawSprite(Gauge, new RectangleF(radarCenterX, radarCenterY, size, size), System.Drawing.Color.Black);

                // The needle is more complicated due to the rotation.
                // We build a matrix here to position the needle exactly as required.
                e.Graphics.DrawSprite(Needle,
                   Matrix.Translation(-0.5f, 0.0f, 0.0f) *               // first we shift the texture half of it's size to the left, because the needle is in the horizontal center of the texture
                   Matrix.Scaling(size, size, 1.0f) *                    // now we scale the image to the desired size
                   Matrix.RotationZ(body) *                               // here we apply the rotation based on our RPM value (given in radians)
                   Matrix.Translation(radarCenterX, radarCenterY, 0.0f), // and finally we move the image to the desired location on the screen (the center of the radar in this case)
                   Color.Blue);

                e.Graphics.DrawSprite(Needle,
            Matrix.Translation(-0.5f, 0.0f, 0.0f) *               // first we shift the texture half of it's size to the left, because the needle is in the horizontal center of the texture
            Matrix.Scaling(size, size, 1.0f) *                    // now we scale the image to the desired size
            Matrix.RotationZ(Petro) *                               // here we apply the rotation based on our RPM value (given in radians)
            Matrix.Translation(radarCenterX, radarCenterY, 0.0f), // and finally we move the image to the desired location on the screen (the center of the radar in this case)
            Color.Red);

             e.Graphics.DrawSprite(Needle,
             Matrix.Translation(-0.5f, 0.0f, 0.0f) *               // first we shift the texture half of it's size to the left, because the needle is in the horizontal center of the texture
             Matrix.Scaling(size, size, 1.0f) *                    // now we scale the image to the desired size
             Matrix.RotationZ(Engine) *                               // here we apply the rotation based on our RPM value (given in radians)
             Matrix.Translation(radarCenterX, radarCenterY, 0.0f), // and finally we move the image to the desired location on the screen (the center of the radar in this case)
             Color.Green);
            }

            if (!Exists(v2))
            {
                v2 = Player.Character.CurrentVehicle;
                if (v2 == null) { return; }
            }
            else
            {
                if (Player.Character.isInVehicle())
                {
                    v2 = Player.Character.CurrentVehicle;
                }
            }

            if (v2 == null) { return; }

            if (v2.PetrolTankHealth < 0 && v2.isAlive)
            {
                int S;
                S = (int)Math.Abs(v2.PetrolTankHealth) % 100;

                float Rot1 = (-S * 2 * (float)Math.PI / 100) - (float)Math.PI;
                float Rot2 = (v2.PetrolTankHealth * 2 * (float)Math.PI / 1000) - (float)Math.PI;

             e.Graphics.DrawSprite(Needle,
             Matrix.Translation(-0.5f, 0.0f, 0.0f) *               // first we shift the texture half of it's size to the left, because the needle is in the horizontal center of the texture
             Matrix.Scaling(size, size, 1.0f) *                    // now we scale the image to the desired size
             Matrix.RotationZ(Rot1) *                               // here we apply the rotation based on our RPM value (given in radians)
             Matrix.Translation(radarCenterX, radarCenterY, 0.0f), // and finally we move the image to the desired location on the screen (the center of the radar in this case)
             Color.Yellow);
                         e.Graphics.DrawSprite(Needle,
             Matrix.Translation(-0.5f, 0.0f, 0.0f) *               // first we shift the texture half of it's size to the left, because the needle is in the horizontal center of the texture
             Matrix.Scaling(size, size, 1.0f) *                    // now we scale the image to the desired size
             Matrix.RotationZ(Rot2) *                               // here we apply the rotation based on our RPM value (given in radians)
             Matrix.Translation(radarCenterX, radarCenterY, 0.0f), // and finally we move the image to the desired location on the screen (the center of the radar in this case)
             Color.Yellow);
            }
        }
Ejemplo n.º 32
0
        protected override void depopulateDestructibleElements(bool removePhysicalElements = false)
        {
            base.depopulateDestructibleElements(removePhysicalElements);

            if (introPed != null && introPed.Exists())
            {
                introPed.Delete();
                introPed = null;
            }

            if (nadineMorano != null && nadineMorano.Exists())
            {
                nadineMorano.MarkAsNoLongerNeeded();

                if (removePhysicalElements)
                {
                    nadineMorano.Delete();
                    nadineMorano = null;
                }
            }

            if (Joe.bike != null && Joe.bike.Exists())
            {
                Joe.bike.MarkAsNoLongerNeeded();

                if (removePhysicalElements)
                {
                    Joe.bike.Delete();
                    Joe.bike = null;
                }
            }

            foreach (Ped spectator in firstSongSpectatorsPeds)
                if (spectator != null && spectator.Exists())
                {
                    spectator.MarkAsNoLongerNeeded();
                    if (removePhysicalElements)
                        spectator.Delete();
                }

            firstSongSpectatorsPeds.Clear();

            foreach (Ped spectator in secondSongCopsPeds)
                if (spectator != null && spectator.Exists())
                {
                    spectator.MarkAsNoLongerNeeded();
                    if (removePhysicalElements)
                        spectator.Delete();
                }

            secondSongCopsPeds.Clear();

            foreach (Ped spectator in thirdSongSpectatorsPeds)
                if (spectator != null && spectator.Exists())
                {
                    spectator.MarkAsNoLongerNeeded();
                    if (removePhysicalElements)
                        spectator.Delete();
                }

            thirdSongSpectatorsPeds.Clear();
        }
Ejemplo n.º 33
0
        public override void checkRequiredElements()
        {
            base.checkRequiredElements();

            while (Joe.bike == null || !Joe.bike.Exists()) {
                Joe.bike = World.CreateVehicle(VehicleHash.TriBike, bikePositionAtHome);

                for (int i = 0; i < this.getObjectives().Count; i++)
                {
                    AbstractObjective objective = this.getObjectives()[i];
                    if (objective is GoToPositionInVehicle)
                    {
                        ((GoToPositionInVehicle)objective).setVehicle(Joe.bike);

                        if (objective.Checkpoint != null)
                        {
                            objective.Checkpoint.removeEntities();
                            if (i < 3)
                            {
                                objective.Checkpoint.addEntity(Joe.bike, bikePositionAtHome, 0);
                            }
                            else if (i < 6)
                            {
                                objective.Checkpoint.addEntity(Joe.bike, roadFaceToPoliceStationPosition, 0);
                            }
                            else
                            {
                                objective.Checkpoint.addEntity(Joe.bike, thirdSongBikePosition, -90);
                            }
                        }
                    }
                }
            }
            Joe.bike.EnginePowerMultiplier = 100;
            Joe.bike.IsInvincible = true;
            Joe.bike.CanTiresBurst = false;

            ModelManager.Instance.setDemagoModel(DemagoModel.Joe);

            Ped player = Game.Player.Character;
            player.MaxHealth = 300;
            Function.Call(Hash.SET_PED_MAX_HEALTH, player, player.MaxHealth);
            player.Health = 300;

            CameraShotsList.Instance.reset();
            AudioManager.Instance.FilesSubFolder = @"joe\joe";
            Subtitles.SubtitlesPath = @"musics\joe\joe." + DemagoScript.language + ".st";
        }
Ejemplo n.º 34
0
        /// <summary>
        /// Spawns a copy of a vehicle.
        /// </summary>
        /// <param name="coordinates">Position of the new vehicle</param>
        /// <param name="heading">Heading of the new vehicle</param>
        /// <param name="oldVeh">Vehicle to copy</param>
        /// <returns>New vehicle handle</returns>
        public static GTA.Vehicle SpawnCopyVehicle(Vector3 coordinates, float heading, GTA.Vehicle oldVeh)
        {
            GTA.Vehicle veh = GTA.World.CreateVehicle(oldVeh.Model, coordinates, heading);

            try
            {
                // Plate
                veh.NumberPlate = oldVeh.NumberPlate;
                veh.NumberPlateType = oldVeh.NumberPlateType;

                // Wheels
                veh.WheelType = oldVeh.WheelType;

                // Mods
                bool customTire1 = Function.Call<bool>(Hash.GET_VEHICLE_MOD_VARIATION, oldVeh, 23);
                bool customTire2 = Function.Call<bool>(Hash.GET_VEHICLE_MOD_VARIATION, oldVeh, 24);  // Bike only

                if (Function.Call<int>(Hash.GET_NUM_MOD_KITS, oldVeh) != 0)
                {
                    veh.InstallModKit();

                    foreach (VehicleMod mod in Enum.GetValues(typeof(VehicleMod)))
                    {
                        if (mod == VehicleMod.FrontWheels)
                            veh.SetMod(VehicleMod.FrontWheels, oldVeh.GetMod(VehicleMod.FrontWheels), Function.Call<bool>(Hash.GET_VEHICLE_MOD_VARIATION, oldVeh, 23));
                        else if (mod == VehicleMod.BackWheels)
                            veh.SetMod(VehicleMod.FrontWheels, oldVeh.GetMod(VehicleMod.FrontWheels), Function.Call<bool>(Hash.GET_VEHICLE_MOD_VARIATION, oldVeh, 24));
                        else
                            veh.SetMod(mod, oldVeh.GetMod(mod), false);
                    }
                    foreach (VehicleToggleMod mod in Enum.GetValues(typeof(VehicleToggleMod)))
                        veh.ToggleMod(mod, oldVeh.IsToggleModOn(mod));
                    
                }
                veh.WindowTint = oldVeh.WindowTint;

                // Tire's smoke color
                veh.TireSmokeColor = oldVeh.TireSmokeColor;
                veh.CanTiresBurst = oldVeh.CanTiresBurst;

                // Neons
                foreach (VehicleNeonLight neon in Enum.GetValues(typeof(VehicleNeonLight)))
                    veh.SetNeonLightsOn(neon, oldVeh.IsNeonLightsOn(neon));

                // Color
                veh.ClearCustomPrimaryColor();
                veh.ClearCustomSecondaryColor();

                if (oldVeh.IsPrimaryColorCustom)
                    veh.CustomPrimaryColor = oldVeh.CustomPrimaryColor;
                if (oldVeh.IsSecondaryColorCustom)
                    veh.CustomSecondaryColor = oldVeh.CustomSecondaryColor;

                veh.PrimaryColor = oldVeh.PrimaryColor;
                veh.SecondaryColor = oldVeh.SecondaryColor;
                veh.PearlescentColor = oldVeh.PearlescentColor;
                veh.RimColor = oldVeh.RimColor;
                veh.DashboardColor = oldVeh.DashboardColor;
                veh.TrimColor = oldVeh.TrimColor;

                // Convertible
                // 0 -> up ; 1->lowering down ; 2->down ; 3->raising up
                if (oldVeh.IsConvertible)
                    veh.RoofState = oldVeh.RoofState;

                // Extra
                for (int i = 1; i < 15; i++)
                    veh.ToggleExtra(i, oldVeh.IsExtraOn(i));
                
                // Liveries
                veh.Livery = oldVeh.Livery;
                SetVehicleLivery2(veh, GetVehicleLivery2(oldVeh));

                // Misc
                veh.NeedsToBeHotwired = false;
                veh.IsStolen = false;
            }
            catch (Exception e)
            {
                Console.Write("Error: SpawnCopyVehicle - " + e.Message);
            }

            return veh;
        }
Ejemplo n.º 35
0
        public static void Work()
        {
            if (IsWorking == false)
            {

                currentMoney = Game.Player.Money;
                Script.Wait(30);
                IsWorking = true;
                CustomPlayer.isWorking = true;
                GTA.Game.FadeScreenOut(1000);
                Script.Wait(1000);
                taxi1 = World.CreateVehicle(GTA.Native.VehicleHash.Taxi, new Vector3(-548f, 301f, 83f), 275f);
                Script.Wait(100);
                hours = Function.Call<int>(Hash.GET_CLOCK_HOURS);
                Script.Wait(30);
                Player.Character.SetIntoVehicle(taxi1, VehicleSeat.Driver);
                Script.Wait(1000);
                GTA.Game.FadeScreenIn(2000);
                Script.Wait(0);
                taxiblip = taxi1.AddBlip();
                taxiblip.Sprite = BlipSprite.PersonalVehicleCar;
                taxiblip.Color = BlipColor.Yellow;
                CustomPlayer.sendMessage("Press " + Style.YELLOW + "[E]" + Style.NORMAL +" to start Taxi Missions, Return back to quit working!");
            }
            else
            {
                Quit();
            }
        }
Ejemplo n.º 36
0
 /// <summary>
 /// Number of livery2 available for the vehicle.
 /// Livery2 know usage is the roof of the TORNADO5 (Benny's custom)
 /// </summary>
 /// <param name="veh">Vehicle</param>
 /// <returns>Number of livery</returns>
 public static int GetVehicleLivery2Count(GTA.Vehicle veh)
 {
     return Function.Call<int>((Hash)0x5ECB40269053C0D4, veh);
 }
Ejemplo n.º 37
0
 /// <summary>
 /// Get the current index of livery2 for the vehicle.
 /// Livery2 know usage is the roof of the TORNADO5 (Benny's custom)
 /// </summary>
 /// <param name="veh">Vehicle</param>
 /// <returns>Current livery</returns>
 public static int GetVehicleLivery2(GTA.Vehicle veh)
 {
     return Function.Call<int>((Hash)0x60190048C0764A26, veh);
 }
Ejemplo n.º 38
0
 /// <summary>
 /// Set the current index of livery2 for the vehicle.
 /// Livery2 known usage is the roof of the TORNADO5 (Benny's custom)
 /// </summary>
 /// <param name="veh">Vehicle</param>
 /// <param name="liveryNumber">Livery ID to set to the vehicle</param>
 public static void SetVehicleLivery2(GTA.Vehicle veh, int liveryNumber)
 {
     Function.Call((Hash)0xA6D3A8750DC73270, veh, liveryNumber);
 }
Ejemplo n.º 39
0
 /// <summary>
 /// Set the angle of the engines of a vehicle using Vertical Take Off and Landing (ie: HYDRA).
 /// </summary>
 /// <param name="veh">Vehicle using Vertical Take Off and Landing</param>
 /// <param name="angle">Value from 0.0 (engines are horizontal) to 1.0 (engines are vertical)</param>
 public static void SetVOTLAngle(GTA.Vehicle veh, float angle)
 {
     Function.Call((Hash)0x9AA47FFF660CB932, veh, angle);
 }
Ejemplo n.º 40
0
 /// <summary>
 /// Translate the model hash into its real name.
 /// </summary>
 /// <param name="veh">Vehicle</param>
 /// <returns>Vehicle model name</returns>
 public static string GetModelName(GTA.Vehicle veh)
 {
     string model = Function.Call<string>(Hash.GET_DISPLAY_NAME_FROM_VEHICLE_MODEL, veh.Model.Hash);
     return Game.GetGXTEntry(model);
 }
Ejemplo n.º 41
0
        /// <summary>
        /// Called every tick to process all plugin logic.
        /// </summary>
        public override void Process()
        {
            // If on duty and Z is down
            if (LPlayer.LocalPlayer.IsOnDuty && (Functions.IsKeyDown(Keys.Z) || (Functions.IsControllerInUse() && Functions.IsControllerKeyDown(GamepadButtonFlags.DPadRight))))
            {
                DelayedCaller.Call(
                    delegate
                {
                    LPlayer.LocalPlayer.Ped.DrawTextAboveHead("Test", 500);
                },
                    this,
                    500);

                if (this.lcpdfrPed == null || this.lcpdfrPed.Exists() || this.lcpdfrPed.IsAliveAndWell)
                {
                    // Create a ped
                    this.lcpdfrPed = new LPed(LPlayer.LocalPlayer.Ped.Position, "F_Y_HOOKER_01");
                    this.lcpdfrPed.NoLongerNeeded();
                    this.lcpdfrPed.AttachBlip();
                    this.lcpdfrPed.ItemsCarried = LPed.EPedItem.Drugs;
                    LPed.EPedItem item = this.lcpdfrPed.ItemsCarried;
                    this.lcpdfrPed.PersonaData = new PersonaData(DateTime.Now, 0, "Sam", "T", false, 1337, true);
                }
            }

            // If our ped exists and has been arrested, kill it
            if (this.lcpdfrPed != null && this.lcpdfrPed.Exists())
            {
                if (this.lcpdfrPed.HasBeenArrested && this.lcpdfrPed.IsAliveAndWell)
                {
                    this.lcpdfrPed.Die();
                }
            }

            if (Functions.IsKeyDown(Keys.B))
            {
                if (Functions.IsPlayerPerformingPullover())
                {
                    LHandle pullover = Functions.GetCurrentPullover();
                    if (pullover != null)
                    {
                        LVehicle vehicle = Functions.GetPulloverVehicle(pullover);
                        if (vehicle != null && vehicle.Exists())
                        {
                            vehicle.AttachBlip().Color = BlipColor.Cyan;
                            if (vehicle.HasDriver)
                            {
                                // Change name of driver to Sam T.
                                LPed driver = vehicle.GetPedOnSeat(VehicleSeat.Driver);
                                if (driver != null && driver.Exists())
                                {
                                    // Modify name.
                                    driver.PersonaData = new PersonaData(DateTime.Now, 0, "Sam", "T", true, 0, false);

                                    string name = driver.PersonaData.FullName;
                                    Functions.PrintText("--- Pulling over: " + name + " ---", 10000);

                                    // Looking up the driver will make the vehicle explode.
                                    Functions.PedLookedUpInPoliceComputer += delegate(PersonaData data)
                                    {
                                        if (data.FullName == name)
                                        {
                                            DelayedCaller.Call(delegate { if (vehicle.Exists())
                                                                          {
                                                                              vehicle.Explode();
                                                                          }
                                                               }, this, Common.GetRandomValue(5000, 10000));
                                        }
                                    };
                                }
                            }
                        }
                    }
                }
                else
                {
                    // Disable pullovers for vehicle in front.
                    GTA.Vehicle vehicle = World.GetClosestVehicle(LPlayer.LocalPlayer.Ped.GetOffsetPosition(new Vector3(0, 10, 0)), 5f);
                    if (vehicle != null && vehicle.Exists())
                    {
                        LVehicle veh = LVehicle.FromGTAVehicle(vehicle);
                        if (veh != null)
                        {
                            veh.DisablePullover = true;
                            veh.AttachBlip();
                        }
                    }
                }
            }

            // Kill all partners.
            if (Functions.IsKeyDown(Keys.N))
            {
                LHandle partnerManger = Functions.GetCurrentPartner();
                LPed[]  peds          = Functions.GetPartnerPeds(partnerManger);
                if (peds != null)
                {
                    foreach (LPed partner in peds)
                    {
                        if (partner.Exists())
                        {
                            partner.Die();
                        }
                    }
                }
            }

            // Send RequestBackup message in network game.
            if (Functions.IsKeyDown(Keys.X))
            {
                if (Networking.IsInSession && Networking.IsConnected)
                {
                    if (Networking.IsHost)
                    {
                        Vector3 position = LPlayer.LocalPlayer.Ped.Position;

                        // Tell client we need backup.
                        DynamicData dynamicData = new DynamicData(Networking.GetServerInstance());
                        dynamicData.Write(position);
                        Networking.GetServerInstance().Send("API_Example", ENetworkMessages.RequestBackup, dynamicData);
                    }
                }
            }
        }
Ejemplo n.º 42
0
        /// <summary>
        ///     Draw a specified entity
        /// </summary>
        /// <param name="e">The entity to draw</param>
        private void DrawEntity(Entity e)
        {
            if (!e.IsOnScreen || e.IsOccluded) return;

            var textScale = .25f;

            //Set text color
            var c = Color.FromArgb(150, Color.White);
            if (_selectedEntity != null && e.Equals(_selectedEntity)) c = Color.Red;
            else {
                switch (GTAFuncs.GetEntityType(e)) {
                    case GTAFuncs.EntityType.Ped:
                        c = new Ped(e.Handle).IsPlayer
                            ? Color.FromArgb(150, Color.CornflowerBlue)
                            : Color.FromArgb(150, Color.Yellow);
                        break;
                    case GTAFuncs.EntityType.Vehicle:
                        c = Color.FromArgb(150, Color.DeepPink);
                        break;
                    case GTAFuncs.EntityType.Prop:
                        c = Color.FromArgb(150, Color.Green);
                        break;
                }
            }

            //Create entity info lines
            var lines = new List<string>();

            switch(GTAFuncs.GetEntityType(e)) {
                case GTAFuncs.EntityType.Ped:
                    Ped ped = new Ped(e.Handle);
                    if (ped.IsPlayer) {
                        Player pl = GTAFuncs.GetPedPlayer(ped);
                        lines.Add(pl.Name);
                        lines.Add("Player #" + pl.Handle);
                        if (GTAFuncs.GetPlayerInvincible(pl)) lines.Add("INVINCIBLE");
                    }
                    lines.Add("Ped #" + ped.Handle);
                    e = ped;
                    break;
                case GTAFuncs.EntityType.Vehicle:
                    Vehicle v = new Vehicle(e.Handle);
                    lines.Add("Vehicle #" + v.Handle);
                    lines.Add(v.FriendlyName);
                    lines.Add(v.DisplayName);
                    e = v;
                    break;
                case GTAFuncs.EntityType.Prop:
                    Prop prop = new Prop(e.Handle);
                    lines.Add("Prop #" + prop.Handle);
                    lines.Add("Model: " + prop.Model.Hash);
                    e = prop;
                    break;
                default:
                    lines.Add("Entity #" + e.Handle);
                    break;
            }

            Entities.Add(e.Handle, e);

            //Draw entity info
            var screenPos = GTAFuncs.WorldToScreen(e.Position);
            var contain =
                new Rectangle(
                    new Point((int) screenPos.X,
                        (int)screenPos.Y + (GTAFuncs.GetEntityType(e) == GTAFuncs.EntityType.Ped && new Ped(e.Handle).IsInVehicle() ? lines.Count * -10 : 0)),
                    new Size(50, (lines.Count*11) - 1));

            for (var i = 0; i < lines.Count; i++) {
                GTAFuncs.SetTextDropShadow(2, Color.FromArgb(255, 0, 0, 0));
                new UIText(lines[i], new Point(0, (i*10)), textScale, Color.FromArgb(255, c), 0, true).Draw(
                    new Size(contain.Location));
                GTAFuncs.SetTextDropShadow(0, Color.Transparent);
            }

            EntityClickBoxes.Add(e, contain);
            DrawEntBox(e, c);
        }
Ejemplo n.º 43
0
 //RADIO OFF
 void RadioOff()
 {
     GTA.Vehicle veh = Game.Player.Character.CurrentVehicle;
     veh.RadioStation = GTA.RadioStation.RadioOff;
 }