Exemplo n.º 1
0
        private void NativeCallExample_KeyDown(object sender, GTA.KeyEventArgs e)
        {
            if (e.Key != Keys.L)
            {
                return;
            }

            GTA.Native.Pointer PedPointer = typeof(Ped);
            GTA.Native.Function.Call("GET_PLAYER_CHAR", Player, PedPointer);
            Ped PlayerChar = PedPointer;

            if (!GTA.Native.Function.Call <bool>("IS_CHAR_IN_ANY_CAR", PlayerChar))
            {
                Game.DisplayText("Not in a car!");
                return;
            }

            GTA.Native.Pointer CarPointer = typeof(Vehicle);
            GTA.Native.Function.Call("GET_CAR_CHAR_IS_USING", PlayerChar, CarPointer);

            GTA.Native.Pointer ModelPointer = typeof(Model);
            GTA.Native.Function.Call("GET_CAR_MODEL", CarPointer.ToInputParameter(), ModelPointer);

            String name = GTA.Native.Function.Call <String>("GET_DISPLAY_NAME_FROM_VEHICLE_MODEL", ModelPointer.ToInputParameter());

            Game.DisplayText("Car name: " + name);
        }
Exemplo n.º 2
0
        private void bombScript_KeyDown(object sender, GTA.KeyEventArgs e)
        {
            if (customCamEnabled || customCarCamEnabled)
            {
                for (int i = 0; i < numOfKeys; i++)
                {
                    if (e.Key == keyArray[i].key)
                    {
                        keyArray[i].pressed = true;
                    }
                }
            }
            if (customCarCamEnabled)
            {
                if (e.Key == keyArray[(int)numToKey.carCam_positionKey].key)
                {
                    isAdjustingCarCamPosition = !isAdjustingCarCamPosition;
                    if (!isAdjustingCarCamPosition)
                    {
                        customCarCam_offsPos = Player.Character.CurrentVehicle.GetOffset(customCarCam.Position);

                        customCarCam_headingDiff = customCarCam.Heading - Player.Character.CurrentVehicle.Heading;
                        customCarCam_directionDiff.X = -Player.Character.CurrentVehicle.Direction.X + customCarCam.Direction.X;
                        customCarCam_directionDiff.Y = -Player.Character.CurrentVehicle.Direction.Y + customCarCam.Direction.Y;
                        customCarCam_directionDiff.Z = -Player.Character.CurrentVehicle.Rotation.X + customCarCam.Rotation.X;
                        Game.Console.Print("pVeh.Z " + Player.Character.CurrentVehicle.Direction.Z.ToString() + " cCam.Z " + customCarCam.Direction.Z.ToString() + " diff " + customCarCam_directionDiff.Z);
                    }
                    else
                    {
                        camHeading = customCarCam.Heading;
                        camX = customCarCam.Position.X;
                        camY = customCarCam.Position.Y;
                        camZ = customCarCam.Position.Z;
                        camHeX = customCarCam.Direction.X;
                        camHeY = customCarCam.Direction.Y;
                        camHeZ = customCarCam.Direction.Z;
                    }

                }
            }
            if (e.Key == camKey)
            {
                if (!Player.Character.isInVehicle())
                {
                    customCamEnabled = !customCamEnabled;
                    if (customCamEnabled)
                    {
                        customCam.Position = Game.CurrentCamera.Position;
                        customCam.Direction = Game.CurrentCamera.Direction;
                        customCam.isActive = true;

                        camY = customCam.Position.Y;
                        camX = customCam.Position.X;
                        camZ = customCam.Position.Z;

                        camOldPos = customCam.Position;

                        camHeX = customCam.Direction.X;
                        camHeY = customCam.Direction.Y;
                        camHeZ = customCam.Direction.Z;

                        camHeading = customCam.Heading;
                        camFov = customCam.FOV;
                        camAngle = customCam.Roll;

                        Game.Console.Print("Custom cam enabled");

                        GTA.Native.Function.Call("SET_CHAR_COLLISION", Player.Character, 0);
                        GTA.Native.Function.Call("DISPLAY_RADAR", false);
                        Player.Character.Invincible = true;
                        Player.IgnoredByEveryone = true;
                        startPoint = Player.Character.Position;

                        GTA.Native.Function.Call("CAN_PHONE_BE_SEEN_ON_SCREEN", false);
                        GTA.Native.Function.Call("DISPLAY_HUD", false);
                        Player.Character.Visible = false;
                        if (useCameraObject)
                        {
            #if PLAYER_IS_CAMERA

            #endif

                            //GTA.Native.Function.Call("CREATE_OBJECT", "EC_BOMB", customCam.Position.X, customCam.Position.Y, customCam.Position.Z, test, 0);

            #if PLAYER_IS_CAMERA
                                GTA.Native.Function.Call("ATTACH_CAM_TO_PED", customCam, Player.Character);

                            if (Exists(cameraObj))
                            {
                             // GTA.Native.Function.Call("IS_OBJECT_STATIC", cameraObj, true);
                               //GTA.Native.Function.Call("SET_OBJECT_INITIAL_ROTATION_VELOCITY", cameraObj, 0.0f, 0.0f, 0.0f, 1);
                               // GTA.Native.Function.Call("SET_OBJECT_INITIAL_VELOCITY", cameraObj, 0.0f, 0.0f, 0.0f, 1);
                               //GTA.Native.Function.Call("SET_ACTIVATE_OBJECT_PHYSICS_AS_SOON_AS_IT_IS_UNFROZEN", cameraObj, false);
                               // GTA.Native.Function.Call("SET_OBJECT_PHYSICS_PARAMS", cameraObj, 0);
                                GTA.Native.Function.Call("ATTACH_CAM_TO_OBJECT", customCam, cameraObj);
                               // Player.Character.Position = Game.CurrentCamera.Position;
                               // GTA.Native.Function.Call("ATTACH_CAM_TO_PED", customCam, Player.Character);

                                customCam.DrunkEffectIntensity = 0.0f;
                                cameraObj.Collision = false;
                                cameraObj.Visible = false;
                                cameraObj.FreezePosition = false;
                                GTA.Native.Function.Call("SET_OBJECT_DYNAMIC", cameraObj, true);
                                GTA.Native.Pointer tempPointer = new GTA.Native.Pointer(typeof(float));
                                GTA.Native.Function.Call("GET_OBJECT_MASS", cameraObj, tempPointer);
                                cameraObjMass = tempPointer;
                                Game.Console.Print("Camera object spawned successfully");
                            }
                            else
                            {
                                useCameraObject = false;
                                Game.Console.Print("Failed to spawn camera-object");
                            }
            #endif

                        }
                    }
                    else
                    {
                        GTA.Native.Function.Call("CAN_PHONE_BE_SEEN_ON_SCREEN", true);
                        GTA.Native.Function.Call("SET_CHAR_VISIBLE", Player.Character, true);
                        GTA.Native.Function.Call("SET_CHAR_COLLISION", Player.Character, 1);
                        GTA.Native.Function.Call("DISPLAY_HUD", true);
                        GTA.Native.Function.Call("DISPLAY_RADAR", true);
                        //Player.Character.Visible = true;
                        Player.Character.Invincible = false;
                        Player.IgnoredByEveryone = false;
                        Player.Character.Position = startPoint;
                        Player.Character.GravityMultiplier = 1.0f;

                        customCam.isActive = false;
                        Game.Console.Print("Custom cam OFF");
                    }
                }
                else // if the player is in a vehicle, we apply the car-cam
                {
                    customCarCamEnabled = !customCarCamEnabled;
                    if (customCarCamEnabled)
                    {

                        customCarCam.Direction = Game.CurrentCamera.Direction;
                        customCarCam.FOV = Game.CurrentCamera.FOV;

                        customCarCam.Position = Player.Character.CurrentVehicle.GetOffsetPosition(defaultCarCamPos);

                        oldVehPos = Player.Character.CurrentVehicle.Position;

                        camY = customCarCam.Position.Y;
                        camX = customCarCam.Position.X;
                        camZ = customCarCam.Position.Z;

                        camHeX = customCarCam.Direction.X;
                        camHeY = customCarCam.Direction.Y;
                        camHeZ = customCarCam.Direction.Z;

                        camHeading = customCarCam.Heading;
                        camFov = customCarCam.FOV;
                        camAngle = customCarCam.Roll;

                        GTA.Native.Function.Call("SET_CAM_MOTION_BLUR", customCarCam, true);
                        customCarCam.isActive = true;
                        Game.Console.Print("Custom car cam enabled");
                        camMaxXdeviation = (float)Math.Sin(toRadian(maxHeadingDiff) * toRadian(-customCarCam_offsPos.Y));
                        camMaxYdeviation = (float)Math.Pow(customCarCam_offsPos.Y * customCarCam_offsPos.Y - camMaxXdeviation * camMaxXdeviation, 0.5);

                        float tempHeading = customCarCam.Heading;
                        if (tempHeading < 0)
                        {
                            tempHeading += 360;
                        }
                        customCarCam_headingDiff = customCarCam.Heading - Player.Character.CurrentVehicle.Heading;
                        customCarCam.Direction = Player.Character.CurrentVehicle.Direction;
                        customCarCam_directionDiff.X = -Player.Character.CurrentVehicle.Direction.X + customCarCam.Direction.X;
                        customCarCam_directionDiff.Y = -Player.Character.CurrentVehicle.Direction.Y + customCarCam.Direction.Y;
                        customCarCam_directionDiff.Z = -Player.Character.CurrentVehicle.Rotation.X + customCarCam.Rotation.X;
                    }
                    else
                    {
                        customCarCam.isActive = false;
                        Game.Console.Print("Custom car cam OFF");
                    }
                }
            }
        }