Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    2. News

    1. Red Dead Redemption 2

      1. News
      2. Red Dead Online
    1. GTA Online

      1. After Hours
      2. Find Lobbies & Players
      3. Guides & Strategies
      4. Vehicles
      5. Content Creator
      6. Help & Support
    2. Crews

      1. Events
      2. Recruitment
    1. Grand Theft Auto Series

    2. GTA Next

    3. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    4. GTA IV

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA Mods
    5. GTA Chinatown Wars

    6. GTA Vice City Stories

    7. GTA Liberty City Stories

    8. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    9. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    10. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    11. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    12. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    3. Featured Mods

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption

    2. Rockstar Games

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Programming
      5. Movies & TV
      6. Music
      7. Sports
      8. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Forum Support

    2. Site Suggestions

Sign in to follow this  
123iamking

GTA 4 cutscene native function

Recommended Posts

123iamking

I start working on GTA4 cutscene script, but I got problem with stop the cutscene.
The cutscene starts fine with : START_CUTSCENE_NOW (stringCutscenename);

but when the cutscene comes to finish or I press key to skip the cutscene, the loading screen never stops. If I try to force the cutscene stop with STOP_CUTSCENE(), the game will crash.

The native function: CLEAR_NAMED_CUTSCENE seems doing nothing.

Does anyone how to start and stop a cutscene properly?

 

PS: sorry, this post should be posted to the coding forum, I didn't notice the sub-forum.

Edited by 123iamking

Share this post


Link to post
Share on other sites
Jitnaught

Have you tried using the DO_SCREEN_FADE_IN native to stop the loading screen?

Share this post


Link to post
Share on other sites
123iamking

Have you tried using the DO_SCREEN_FADE_IN native to stop the loading screen?

I forgot to mention. I did try DO_SCREEN_FADE_OUT to stop the loading screen, but the loading screen keep coming back.

Share this post


Link to post
Share on other sites
Jitnaught

DO_SCREEN_FADE_OUT is the opposite of what you want to do.

Share this post


Link to post
Share on other sites
123iamking

DO_SCREEN_FADE_OUT is the opposite of what you want to do.

Silly me, I forgot :p Thank for reminding me, I keep thinking: "Hey! Loading screen, Get out!" :)

But I still wonder how to properly start and stop the cutscene because I don't know if I missed some native functions like CLEAR_NAMED_CUTSCENE would cause lost memory or something.

Edited by 123iamking

Share this post


Link to post
Share on other sites
NTAuthority

yes, one should use CLEAR_NAMED_CUTSCENE, but it only does something if the argument matches the string passed to INIT_CUTSCENE/START_CUTSCENE_NOW.

Share this post


Link to post
Share on other sites
123iamking

yes, one should use CLEAR_NAMED_CUTSCENE, but it only does something if the argument matches the string passed to INIT_CUTSCENE/START_CUTSCENE_NOW.

Thank you :) , so the properly code should be something like this:

 

INIT_CUTSCENE( "cutsceneName" ); //Init cutsceneSTART_CUTSCENE_NOW( "cutsceneName" ) //start cutsceneWhile(!HAS_CUTSCENE_LOADED()) //Wait till cutscene is loaded{ wait(0); }while (true) //checking loop{   if(HAS_CUTSCENE_FINISHED() || AnyKeyIsPress())//Wait till finish or player press any key{CLEAR_NAMED_CUTSCENE( "cutsceneName" ) //clean the memory - I guessDO_SCREEN_FADE_IN( 500 ); //fix the never-stop loading screen}}

Of course the code above is not usable, but that's the ideal. Is the code right?

Edited by 123iamking

Share this post


Link to post
Share on other sites
NTAuthority

your skipping method seems weird too, how about WAS_CUTSCENE_SKIPPED? it seems to read a flag that's written to by a control check in the cutscene manager...

Share this post


Link to post
Share on other sites
123iamking

your skipping method seems weird too, how about WAS_CUTSCENE_SKIPPED? it seems to read a flag that's written to by a control check in the cutscene manager...

Thank you for reminding me :) so I gonna update like this

 

INIT_CUTSCENE( "cutsceneName" ); //Init cutsceneSTART_CUTSCENE_NOW( "cutsceneName" ) //start cutsceneWhile(!HAS_CUTSCENE_LOADED()) //Wait till cutscene is loaded{ wait(0); }while (true) //checking loop{   if(HAS_CUTSCENE_FINISHED() || WAS_CUTSCENE_SKIPPED())//Wait till finish or skipped  {    CLEAR_NAMED_CUTSCENE( "cutsceneName" ) //clean the memory - I guess    DO_SCREEN_FADE_IN( 500 ); //fix the never-stop loading screen    break; //out of the loop  }}

Is that code correct?

plus, I extracted the way to show subtitle from the R*'s code

 

        bool CheckStreamingSubtitle()        {            int I;            for (I = 0; I <= (8 - 1); I++)            {                if (GTA.Native.Function.Call<bool>("IS_STREAMING_ADDITIONAL_TEXT", I))                {                    return true;                }            }            return false;        }        void LoadSubtitle(string uParam0, int uParam1)        {            bool bVar4;            bVar4 = true;            while (bVar4)            {                if (!GTA.Native.Function.Call<bool>("HAS_THIS_ADDITIONAL_TEXT_LOADED", uParam0, uParam1))                {                    if (!CheckStreamingSubtitle())                    {                        GTA.Native.Function.Call("REQUEST_ADDITIONAL_TEXT", uParam0, uParam1);                    }                    Wait(0);                }                else                {                    bVar4 = false;                }            }            return;        }void Cutsene()//Vlad's cutscene for examble{LoadSubtitle("VLAD1", 0);LoadSubtitle("V1AUD", 6);GTA.Native.Function.Call("START_CUTSCENE_NOW", "VLA1_A");            }
Edited by 123iamking

Share this post


Link to post
Share on other sites
123iamking

maybe there is other code. The script now is so unstable, it got crash when I skipped the cutscene, and it's kind of slower than the cutscene started by SNT
Here is my code

        byte Start = 0;        string szCutscene = "VLA1_A";        public Movie()        {            this.KeyDown += new GTA.KeyEventHandler(MyMovies);            Tick += checkTick;                        Interval = 500;        }        void checkTick(object sender, EventArgs e)        {                        switch (Start)            {                case 0:                                        break;                case 1:                    if (GTA.Native.Function.Call<bool>("HAS_CUTSCENE_LOADED"))                        Start = 2;                    break;                case 2:                                        if (GTA.Native.Function.Call<bool>("HAS_CUTSCENE_FINISHED") || GTA.Native.Function.Call<bool>("WAS_CUTSCENE_SKIPPED"))                    {                        Start = 0;                        GTA.Native.Function.Call("CLEAR_NAMED_CUTSCENE", szCutscene);                        Wait(1000);                        GTA.Native.Function.Call("DO_SCREEN_FADE_IN", 500);                    }                    break;            }        }        void Cutscene()        {            GTA.Native.Function.Call("INIT_CUTSCENE", szCutscene);            //LoadSubtitle("VLAD1", 0);            //LoadSubtitle("V1AUD", 6);            GTA.Native.Function.Call("START_CUTSCENE_NOW", szCutscene);            Start = 1;        }        public void MyMovies(object sender, GTA.KeyEventArgs e)        {            if (e.Key == Keys.Y)            {                Cutscene();                            }                    }

Share this post


Link to post
Share on other sites
sjaak327

I know this is a late response, but I just saw this thread.

 

Maybe it would be of any help, but this is how I do it in the simple trainer:

 

I have some logic to prevent cutscenes whilst on an actual mission (as it would crash the game) also some stuff to disable various radio functions and ensuring the player model used is Nico (crash otherwise).

 

but the actual starting of the cutscenes goes like this:

 

if ((GetAsyncKeyState(MenuKeyEnter) & 1) != 0)			{			Char c;			int model;			Vehicle car;			u32 playerIndex = ConvertIntToPlayerIndex(GetPlayerId());			GetPlayerChar(playerIndex, &c);			GetCharModel(c,&model);								if (!GetMissionFlag()==1)				{					if (model==1862763509)					{					cutscene=CutScene[CutNum].cutscene;					int cut=CutScene[CutNum].cutscenenumber;												if (IsCharInAnyCar©)						{						DisableFrontEndRadio();						RadioDis=true;						}											if (MobileRadio==1)						{						SetMobilePhoneRadioState(0);						SetMobileRadioEnabledDuringGameplay(0);						MobileRadio=0;						MobileRadioDis=true;						}						if (cut>0)						{						LoadAllObjectsNow();						}						if (cut==2)						{						RequestIpl("shipintro");						IPL=true;						}					StartCutsceneNow(cutscene);					m_State=StateCS;					DMenu=false;					}					else					{					PrintStringWithLiteralStringNow("STRING","You need to change the Model to Niko!",5000,1);					}				}				else				{				PrintStringWithLiteralStringNow("STRING","Mission in Progess, cannot play Cut Scene Now",5000,1);				}			}		}
where cutscene is from a array containing the actual cutscene names (such as rom1_b for cousin bellic).

 

since I am using the customthread (instead of customfiber) I cannot use wait, so I change states

 

 

the state is like this:

 

 

	case StateCS:		{			if (HasCutsceneFinished()) 			{ 			ClearNamedCutscene(cutscene);			Char c;			Player playerIndex = ConvertIntToPlayerIndex(GetPlayerId());			GetPlayerChar(playerIndex, &c);			SetCharHeading(c,180.0f);			SetCamBehindPed©;			SetPlayerControl(playerIndex,1);			DoScreenFadeIn(500);			m_State=StateDefault;				if (IPL==true)				{				RemoveIpl("shipintro");				IPL=false;				}				if (MobileRadioDis==true)				{				SetMobilePhoneRadioState(1);				SetMobileRadioEnabledDuringGameplay(1);				MobileRadio=1;				MobileRadioDis=false;				}				if (RadioDis==true)				{				EnableFrontEndRadio();				RadioDis=false;				}			DMenu=true;			}		}		break;
No need to code anything for skipping, as it is handled by the game's functions :) Edited by sjaak327

Share this post


Link to post
Share on other sites
123iamking
					cutscene=CutScene[CutNum].cutscene;					int cut=CutScene[CutNum].cutscenenumber;						if (cut>0)						{						LoadAllObjectsNow();						}						if (cut==2)						{						RequestIpl("shipintro");						IPL=true;						}	
where cutscene is from a array containing the actual cutscene names (such as rom1_b for cousin bellic).

 

 

 

Thank you, so to load a cutscene properly, we have to "LoadAllObjectsNow" first, and If the cutscene is "shipintro", we have to "RequestIpl".

But can you explain me more about LoadAllObjectsNow() and RequestIpl() actually do, like: LoadAllObjectsNow() really does load all objects of the game? and what IPL and what kinds of cutscene would need Request_IPL (in case I do cutscene in EFLC) ?

Edited by 123iamking

Share this post


Link to post
Share on other sites
123iamking

As I try to put the Load_All_Objects_Now to the script, it still doesn't fix the problem, (I haven't add the RequestIpl("shipintro"); yet because I only try to run the cutscene VLA1_A for now), here my entire script, please help me point out where it go wrong

using System;using System.Windows.Forms;using GTA;using System.Collections.Generic;using System.Drawing;namespace GtaCutscene{    public class Movie : Script    {        byte Start = 0;        string szCutscene = "VLA1_A";        public Movie()        {            this.KeyDown += new GTA.KeyEventHandler(MyMovies);            Tick += checkTick;                        Interval = 500;        }        bool CheckStreamingSubtitle()        {                        for (int I = 0; I <= (8 - 1); I++)            {                if (GTA.Native.Function.Call<bool>("IS_STREAMING_ADDITIONAL_TEXT", I))                {                    return true;                }            }            return false;        }        void LoadSubtitle(string uParam0, int uParam1)        {            bool bVar4 = true;            while (bVar4)            {                if (!GTA.Native.Function.Call<bool>("HAS_THIS_ADDITIONAL_TEXT_LOADED", uParam0, uParam1))                {                    if (!CheckStreamingSubtitle())                    {                        GTA.Native.Function.Call("REQUEST_ADDITIONAL_TEXT", uParam0, uParam1);                    }                    Wait(0);                }                else                {                    bVar4 = false;                }            }            return;        }                void checkTick(object sender, EventArgs e)        {                        switch (Start)            {                case 0:                                        break;                case 1:                    if (GTA.Native.Function.Call<bool>("HAS_CUTSCENE_LOADED"))                    {                        GTA.Native.Function.Call("LOAD_ALL_OBJECTS_NOW");                                                Start = 2;                    }                    break;                case 2:                                        if (GTA.Native.Function.Call<bool>("HAS_CUTSCENE_FINISHED") || GTA.Native.Function.Call<bool>("WAS_CUTSCENE_SKIPPED"))                    {                        Start = 0;                        GTA.Native.Function.Call("CLEAR_NAMED_CUTSCENE", szCutscene);                        Player.Character.Heading = 180.0f;                        GTA.Native.Function.Call("SET_CAM_BEHIND_PED", Player.Character);                        GTA.Native.Function.Call("SET_PLAYER_CONTROL", Player.Index,1);                        Wait(1000);                        GTA.Native.Function.Call("DO_SCREEN_FADE_IN", 500);                    }                    break;            }        }        void Cutscene()        {            if (GTA.Native.Function.Call<bool>("GET_MISSION_FLAG"))                return;            if(GTA.Native.Function.Call<bool>("IS_CHAR_IN_ANY_CAR",Player.Character))                return;            GTA.Native.Function.Call("INIT_CUTSCENE", szCutscene);            //LoadSubtitle("VLAD1", 0);            //LoadSubtitle("V1AUD", 6);            GTA.Native.Function.Call("START_CUTSCENE_NOW", szCutscene);            Start = 1;        }        public void MyMovies(object sender, GTA.KeyEventArgs e)        {            if (e.Key == Keys.Y)            {                Cutscene();                            }                    }    }}
Edited by 123iamking

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.