Exemplo n.º 1
0
        private void UpdateDoorIce(VehicleDoorIndex doorIndex, PtfxEntityBonePlayer waterDrop)
        {
            if (waterDrop.IsPlaying)
            {
                return;
            }

            waterDrop.Play();
            waterDrop.Play();
        }
Exemplo n.º 2
0
        public VehicleDoor this[VehicleDoorIndex index]
        {
            get
            {
                if (!_vehicleDoors.TryGetValue(index, out VehicleDoor vehicleDoor))
                {
                    vehicleDoor = new VehicleDoor(_owner, index);
                    _vehicleDoors.Add(index, vehicleDoor);
                }

                return(vehicleDoor);
            }
        }
Exemplo n.º 3
0
 // Cutting Door
 private void CutDoor(Vehicle vehicle, VehicleDoorIndex doorIndex)
 {
     if (IsVehiclePlayerControlled(vehicle))
     {
         List <object> passengers   = GetVehiclePlayers(vehicle);
         int           newDoorIndex = GetVehicleDoorEnumIndex(doorIndex);
         TriggerServerEvent("ExtractionSaw:SyncDoorCut", passengers, newDoorIndex);
     }
     else
     {
         vehicle.Doors[doorIndex].Break(true);
     }
 }
Exemplo n.º 4
0
 public VehicleDoor this[VehicleDoorIndex index]
 {
     get
     {
         VehicleDoor door = null;
         if (!this._vehicleDoors.TryGetValue(index, out door))
         {
             door = new VehicleDoor(this._owner, index);
             this._vehicleDoors.Add(index, door);
         }
         return(door);
     }
 }
Exemplo n.º 5
0
        // Get Closest Door To Remove
        private VehicleDoorIndex GetClosestDoorBone(Vehicle vehicle)
        {
            if (vehicle == null)
            {
                return((VehicleDoorIndex)(-1));
            }

            var FrontDriverDoorBone    = vehicle.Bones["door_dside_f"];
            var RearDriverDoorBone     = vehicle.Bones["door_dside_r"];
            var FrontPassengerDoorBone = vehicle.Bones["door_pside_f"];
            var RearPassengerDoorBone  = vehicle.Bones["door_pside_r"];
            var LocalPedPos            = LocalPlayer.Character.Position;

            VehicleDoorIndex ClosestDoorIndex = VehicleDoorIndex.FrontLeftDoor;
            EntityBone       ClosestBone      = FrontDriverDoorBone;

            // Checking For Closest Door
            if (World.GetDistance(LocalPedPos, ClosestBone.Position) > World.GetDistance(LocalPedPos, RearDriverDoorBone.Position))
            {
                ClosestBone      = RearDriverDoorBone;
                ClosestDoorIndex = VehicleDoorIndex.BackLeftDoor;
            }
            else if (World.GetDistance(LocalPedPos, ClosestBone.Position) > World.GetDistance(LocalPedPos, FrontPassengerDoorBone.Position))
            {
                ClosestBone      = FrontPassengerDoorBone;
                ClosestDoorIndex = VehicleDoorIndex.FrontRightDoor;
            }
            else if (World.GetDistance(LocalPedPos, ClosestBone.Position) > World.GetDistance(LocalPedPos, RearPassengerDoorBone.Position))
            {
                ClosestBone      = RearPassengerDoorBone;
                ClosestDoorIndex = VehicleDoorIndex.BackRightDoor;
            }

            if (World.GetDistance(LocalPedPos, ClosestBone.Position) < 1.3f)
            {
                return(ClosestDoorIndex);
            }
            else
            {
                return((VehicleDoorIndex)(-1));
            }
        }
Exemplo n.º 6
0
        // Returns VehicleDoorIndex Enum Integer
        private int GetVehicleDoorEnumIndex(VehicleDoorIndex doorIndex)
        {
            Debug.WriteLine($"Door Index: {doorIndex}");

            if (doorIndex == VehicleDoorIndex.FrontLeftDoor)
            {
                return(0);
            }
            else if (doorIndex == VehicleDoorIndex.FrontRightDoor)
            {
                return(1);
            }
            else if (doorIndex == VehicleDoorIndex.BackLeftDoor)
            {
                return(2);
            }
            else if (doorIndex == VehicleDoorIndex.BackRightDoor)
            {
                return(3);
            }
            return(-1);
        }
Exemplo n.º 7
0
        private void ToggleVehicleDoor(VehicleDoorIndex vehDoorIndex)
        {
            var closeVeh = GTAHelpers.GetClosestVehicle();

            if (closeVeh?.LockStatus != VehicleLockStatus.Unlocked)
            {
                closeVeh = Client.Get <VehicleHandler>().GetClosestVehicleWithKeys(6.0f);
            }

            if (closeVeh != null && closeVeh.HasDecor("Vehicle.ID"))
            {
                var vehDoor = closeVeh.Doors[vehDoorIndex];

                if (vehDoor.IsOpen)
                {
                    vehDoor.Close();
                }
                else
                {
                    vehDoor.Open();
                }
            }
        }
Exemplo n.º 8
0
        public bool Contains(VehicleDoorIndex door)
        {
            switch (door)
            {
            case VehicleDoorIndex.FrontLeftDoor:
                return(_owner.Bones.Contains("door_dside_f"));

            case VehicleDoorIndex.FrontRightDoor:
                return(_owner.Bones.Contains("door_pside_f"));

            case VehicleDoorIndex.BackLeftDoor:
                return(_owner.Bones.Contains("door_dside_r"));

            case VehicleDoorIndex.BackRightDoor:
                return(_owner.Bones.Contains("door_pside_r"));

            case VehicleDoorIndex.Hood:
                return(_owner.Bones.Contains("bonnet"));

            case VehicleDoorIndex.Trunk:
                return(_owner.Bones.Contains("boot"));
            }
            return(false);
        }
Exemplo n.º 9
0
        // Handles cutting | saw storage and grab | saw pickup and drop
        private async Task OnTick()
        {
            await Task.FromResult(0);

            if (ScriptReady)
            {
                if (CurrentSaw == null)
                {
                    Vehicle truck = GetVehicleInArea();

                    // Grabbing saw from vehicle
                    if (truck != null)
                    {
                        var CheckedVehicle = CheckCastedVehicle(truck);
                        if (CheckedVehicle != null)
                        {
                            World.DrawMarker(MarkerType.HorizontalCircleSkinny, truck.GetOffsetPosition(CheckedVehicle.MarkerPos), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(1f, 1f, 1f), System.Drawing.Color.FromArgb(255, 0, 0), false, false, true, null, null, false);
                            if (World.GetDistance(LocalPlayer.Character.Position, truck.GetOffsetPosition(CheckedVehicle.MarkerPos)) <= 1.2f)
                            {
                                Screen.DisplayHelpTextThisFrame($"~INPUT_PICKUP~ Retrieve Saw");
                                if (Game.IsControlJustPressed(1, Control.Pickup))
                                {
                                    await RetrieveSaw();
                                }
                            }
                        }
                    }

                    // Pickup Saw From Ground
                    var LocalPedPos        = LocalPlayer.Character.Position;
                    var closestSaw         = API.GetClosestObjectOfType(LocalPedPos.X, LocalPedPos.Y, LocalPedPos.Z, 5f, (uint)API.GetHashKey(SawModel), false, true, true);
                    var closestSawPos      = API.GetEntityCoords(closestSaw, false);
                    var closestSawDistance = World.GetDistance(LocalPedPos, API.GetEntityCoords(closestSaw, false));

                    if (closestSaw != 0 && !LocalPlayer.Character.IsInVehicle() && API.GetEntityAttachedTo(closestSaw) == 0)
                    {
                        World.DrawMarker(MarkerType.HorizontalCircleSkinny, closestSawPos, new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(1f, 1f, 1f), System.Drawing.Color.FromArgb(255, 0, 0), false, false, true, null, null, false);
                        if (closestSawDistance <= 1.2f)
                        {
                            Screen.DisplayHelpTextThisFrame($"~INPUT_PICKUP~ Pickup Saw");
                            if (Game.IsControlJustPressed(1, Control.Pickup))
                            {
                                await PickupSaw(closestSaw);
                            }
                        }
                    }
                }
                else
                {
                    Game.DisableControlThisFrame(1, Control.Attack);
                    Game.DisableControlThisFrame(1, Control.Attack2);
                    Game.DisableControlThisFrame(1, Control.Jump);
                    Game.DisableControlThisFrame(1, Control.Aim);
                    Game.DisableControlThisFrame(1, Control.Enter);
                    if (LocalPlayer.Character.Weapons.Current.Hash != WeaponHash.Unarmed)
                    {
                        API.SetCurrentPedWeapon(LocalPlayer.Character.Handle, (uint)WeaponHash.Unarmed, true);
                    }

                    Vehicle truck   = GetVehicleInArea();
                    Vehicle vehicle = GetVehicleFromCast();

                    // Storing saw to vehicle
                    if (truck != null)
                    {
                        var CheckedVehicle = CheckCastedVehicle(truck);
                        if (CheckedVehicle != null)
                        {
                            World.DrawMarker(MarkerType.HorizontalCircleSkinny, truck.GetOffsetPosition(CheckedVehicle.MarkerPos), new Vector3(0f, 0f, 0f), new Vector3(0f, 0f, 0f), new Vector3(1f, 1f, 1f), System.Drawing.Color.FromArgb(255, 0, 0), false, false, true, null, null, false);
                            if (World.GetDistance(LocalPlayer.Character.Position, truck.GetOffsetPosition(CheckedVehicle.MarkerPos)) <= 1.2f)
                            {
                                Screen.DisplayHelpTextThisFrame($"~INPUT_PICKUP~ Store Saw");
                                if (Game.IsControlJustPressed(1, Control.Pickup))
                                {
                                    StoreSaw();
                                }
                            }
                        }
                    }
                    else
                    {
                        // Dropping Saw
                        if (Game.IsControlJustPressed(1, Control.Detonate))
                        {
                            await DropSaw();
                        }
                    }

                    // Cutting Logic
                    if (KeyHolding && GetClosestDoorBone(vehicleBeingCut) != (VehicleDoorIndex)(-1) && !vehicleBeingCut.Doors[GetClosestDoorBone(vehicleBeingCut)].IsBroken)
                    {
                        if (Game.IsDisabledControlPressed(1, Control.Attack))
                        {
                            if (Game.GameTime > KeyHoldStartTime)
                            {
                                KeyHolding       = false;
                                KeyHoldStartTime = 0;
                                TriggerServerEvent("ExtractionSaw:StopSawCutSync", CurrentSawNetHandle);
                                VehicleDoorIndex doorIndex = GetClosestDoorBone(vehicle);
                                CutDoor(vehicleBeingCut, doorIndex);
                            }
                            BarTimerBar bar = new BarTimerBar("Cutting Door");
                            bar.Percentage = 1f - (float)(((KeyHoldStartTime - Game.GameTime) / 1000) * 0.1m) - 0.1f;
                            bar.Draw(0);
                        }
                        else
                        {
                            KeyHoldStartTime = 0;
                            KeyHolding       = false;
                            TriggerServerEvent("ExtractionSaw:StopSawCutSync", CurrentSawNetHandle);
                        }
                    }
                    else
                    {
                        if (Game.IsDisabledControlPressed(1, Control.Attack) && GetClosestDoorBone(vehicle) != (VehicleDoorIndex)(-1))
                        {
                            KeyHoldStartTime = Game.GameTime + (CutTimer * 1000);
                            vehicleBeingCut  = vehicle;
                            KeyHolding       = true;
                        }
                    }

                    // Saw Particle Syncing
                    if (KeyHolding)
                    {
                        LoopParticles();
                    }
                }
            }
        }
Exemplo n.º 10
0
 internal VehicleDoor(Vehicle owner, VehicleDoorIndex index)
 {
     _owner = owner;
     Index  = index;
 }
 internal VehicleDoor(GTA.Vehicle owner, VehicleDoorIndex index)
 {
     this._owner = owner;
     this.Index  = index;
 }