コード例 #1
0
        private void Respawn()
        {
            DateTime time = World.CurrentDate;

            // Prevent default death behavior
            Function.Call(Hash.TERMINATE_ALL_SCRIPTS_WITH_THIS_NAME, "respawn_controller");
            Ped playerPed = Game.Player.Character;

            Function.Call(Hash.NETWORK_REQUEST_CONTROL_OF_ENTITY, playerPed);
            Function.Call(Hash.NETWORK_RESURRECT_LOCAL_PLAYER, playerPed.Position.X, playerPed.Position.Y, playerPed.Position.Z, 0f, 0f, 0f);
            playerPed.IsInvincible = true;
            Function.Call(Hash.IGNORE_NEXT_RESTART, true);
            GTA.UI.Screen.StopEffects();

            // Custom death behavior
            Function.Call(Hash._RESET_LOCALPLAYER_STATE);
            Function.Call(Hash.RESET_PLAYER_ARREST_STATE, playerPed);
            playerPed.Ragdoll();
            Wait(5000);

            // Fade and respawn
            GTA.UI.Screen.FadeOut(2000);
            while (!GTA.UI.Screen.IsFadedOut)
            {
                Yield();
            }
            playerPed.CancelRagdoll();
            Function.Call(Hash.DISPLAY_HUD, true);
            Function.Call(Hash.DISPLAY_RADAR, true);
            GTA.Game.TimeScale = 1f;
            if (GameLoaded)
            {
                LoadGame();
            }
            else
            {
                World.CurrentDate = time;
            }
            Wait(2000);
            playerPed.IsInvincible = false;
            GTA.UI.Screen.FadeIn(2000);
        }