Exemplo n.º 1
0
        /// <summary>
        /// Menu closing sends "CharacterChanged (SelectedModelHash)" to server
        /// </summary>
        /// <param name="sender"></param>
        protected override void MainMenu_OnMenuClose(UIMenu sender)
        {
            //Destroy cameras, set this _camera to inactive
            Cam.RenderScriptCams(false, true, 0, false, false, 0);
            Cam.SetCamActive(_camera, false);
            Cam.DestroyCam(_camera, false);

            //Enable the players controls again
            RAGE.Elements.Player.LocalPlayer.SetGravity(true);
            Pad.EnableAllControlActions(0);

            //Let server know menu is closed to change if selected a ped to sync.
            RAGE.Events.CallRemote("ClientMenuClosed", SelectedModelHash.ToString(), selectedOutfit);

            PlayerHelper.FreezePlayer(false, false);

            ChatHelper.EnableChat(true);
            UiHelper.EnableHuds();

            _instructionLayer = ScaleformHelper.InstructionalButtons(KeyValuePairs);
            if (_debug)
            {
                Chat.Output("Skin selector Menu closed");
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Places the <see cref="_camera"/> in front of the player
        /// </summary>
        /// <param name="args">NULL</param>
        private void OnShowSkinSelector(object[] args)
        {
            if (_debug)
            {
                Chat.Output("Skin selector opening");
            }

            Vector3 position = new Vector3(_ply.Position.X, _ply.Position.Y, _ply.Position.Z);
            var     ply      = RAGE.Elements.Player.LocalPlayer;

            ply.Position = position;
            ply.SetHeading(343f);

            UiHelper.EnableHuds(false, false);

            ply.SetGravity(true);

            if (!_debug)
            {
                ChatHelper.EnableChat(false);
            }

            var     heading = ply.GetHeading();
            Vector3 offset  = RAGE.Game.Entity.GetOffsetFromEntityInWorldCoords(ply.Handle, 1f, 2f, 0f);

            _camera = Cam
                      .CreateCameraWithParams(Misc.GetHashKey("DEFAULT_SCRIPTED_CAMERA"), offset.X, offset.Y, offset.Z, 0f, 0f, 171.5f, 50f, true, 2);
            Cam.SetCamActive(_camera, true);
            Cam.RenderScriptCams(true, true, 0, false, false, 0);
            Cam.PointCamAtCoord(_camera, ply.Position.X, ply.Position.Y, ply.Position.Z);

            PlayerHelper.FreezePlayer(true, false);
            MainMenu.Visible = true;

            if (_debug)
            {
                Chat.Output("Skin selector opened");
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Teleports the player to their map waypoint (purple) not route (yellow)
        ///  </summary>
        /// <remarks>
        /// Disables chat and fades out the screen
        /// </remarks>
        private void TeleportToWaypoint()
        {
            //Sprite 8 is the waypoint blip (purple)
            var waypointCord = RAGE.Game.Ui.GetFirstBlipInfoId(8);

            if (waypointCord > 0)
            {
                RAGE.Game.Player.StopPlayerTeleport();

                ChatHelper.EnableChat(false);
                CamHelper.SetPlayerLoading(true);

                //var gametime = RAGE.Game.Utils.Timestep();
                var g = RAGE.Game.Misc.GetGameTimer();
                Chat.Output($"Game timer: {g}");

                //Get waypoint vector
                var wpPosition = RAGE.Game.Ui.GetBlipInfoIdCoord(waypointCord);
                RAGE.Game.Entity.SetEntityCoords(_player.Handle, wpPosition.X, wpPosition.Y, 700f, true, false, false, true);

                //_player.FreezePosition(true);

                float z = 0f;
                wpPosition.Z = 1000f;
                bool groundFound = false;

                RAGE.Game.Player.StartPlayerTeleport(wpPosition.X, wpPosition.Y, wpPosition.Z, 0f, true, true, false);

                for (int i = 0; i < 1000f; i++)
                {
                    Chat.Output($"{i}");
                    _player.Position.Z = wpPosition.Z;

                    if (RAGE.Game.Misc.GetGroundZFor3dCoord(wpPosition.X, wpPosition.Y,
                                                            i, ref z, false))
                    {
                        groundFound = true;
                        if (!RAGE.Game.Player.IsPlayerTeleportActive())
                        {
                            RAGE.Game.Player.StartPlayerTeleport(wpPosition.X, wpPosition.Y, z, 0f, true, true, false);
                        }
                        _player.Position.Z = wpPosition.Z;
                        Chat.Output($"ground found at ref {z}. count {i}");
                        break;
                    }

                    wpPosition.Z = z;
                    RAGE.Game.Invoker.Wait(25);
                }

                if (!groundFound)
                {
                    _player.Position.Z = 1000;
                    Chat.Output($"~r~Teleported: {_player.Position.X}, {_player.Position.Y}, {_player.Position.Z}");
                }
                {
                    Chat.Output($"~r~Teleported: {_player.Position.X}, {_player.Position.Y}, {_player.Position.Z}");
                }

                CamHelper.SetPlayerLoading(false, 750);
                ChatHelper.EnableChat(true);
                NotifyPic($"Teleported to map waypoint. {_player.Position.ToString()}", "Teleport", RageMpClientShared.NotifyChar.CHAR_BLIMP);
            }
            else
            {
                Chat.Output($"~r~Set a waypoint...");
            }
        }