Log in to reply
 

How to Set Screen Fade out / Fade in Effect?



  • Hi All,

    As the title says, I am trying to add a screen fade out and then fade in effect but I am unable to get so.

    Below is the native and code I am trying to use

    GTA.Native.Function.Call(Hash.DO_SCREEN_FADE_OUT, 3000);

    and then this

    if (GTA.Native.Function.Call<bool>(Hash.IS_SCREEN_FADED_OUT))
    {GTA.Native.Function.Call(Hash.DO_SCREEN_FADE_IN, 3000);}

    The problem is, screen fades out well, but then goes in infinite black loading screen. Any clue what am I missing around here?



  • @ashishcw Bump!!! Anyone?
    @stillhere @LeeC2202 @aimless @Frazzlee @rappo @Jitnaught @sollaholla



  • @ashishcw Are you doing the IS_SCREEN_FADED_OUT check in onTick() or similar?



  • @LeeC2202 In similar function. But I also tried, using fade in and fade out native without the bool condition.
    e.g. GTA.Native.Function.Call(Hash.DO_SCREEN_FADE_OUT, 3000);
    Wait(XSeconds);
    GTA.Native.Function.Call(Hash.DO_SCREEN_FADE_IN, 3000);

    But it doesn't work too. :(



  • @ashishcw It will work fine without, I use it in my Auto-Snap mod with just a line like this Function.Call(Hash.DO_SCREEN_FADE_IN, FadeTimer); but you have to check if it has faded out every frame.

    Just one other slight digression... you only waited 4 hours before bumping and tagging people. Remember the timezone differences and give people more time to respond... I have waited days before getting answers sometimes. Metaphorically banging on people's doors might not always get the response you desire.



  • @ashishcw When you used the Wait function, did you put the time in as seconds or as milliseconds?



  • @ashishcw

    Game.FadeScreenOut(1000);
    Wait(1000);
    // Code here
    Wait(1000);
    Game.FadeScreenIn(1000);
    
    // 1000 is milliseconds.
    


  • @sollaholla The wait statement removes the black screen. When I was trying to get it anyways



  • @ashishcw I've always tended to use this kind of system, so it's pure habit now to stick with it

    enum PlaybackState { FadeIn, FadeOut, NormalUpdating, BlackScreenProcessing };
    
    // Inside Class declarations
    PlaybackState PlayState;
    int FadeTimer = 1000;
    
    // In OnTick or whatever Update function system you use
    switch (PlayState)
    {
    	// FadeIn state, waits until the screen is fully faded in and then changes state
    	case PlaybackState.FadeIn:
    		if (Function.Call<bool>(Hash.IS_SCREEN_FADED_IN))
    		{
    			PlayState = PlaybackState.NormalUpdating;
    		}
    		break;
    	// This state is for when the screen is fully faded in
    	case PlaybackState.NormalUpdating:
    		// Do normal update processing here
    		
    		// Call this when you want to fade the screen out
    		// Function.Call(Hash.DO_SCREEN_FADE_OUT, FadeTimer);
    		break;
    	case PlaybackState.FadeOut:
    		if (Function.Call<bool>(Hash.IS_SCREEN_FADED_OUT))
    		{
    			PlayState = PlaybackState.BlackScreenProcessing;
    		}
    		break;
    	// This state is for when the screen is fully faded out
    	case PlaybackState.BlackScreenProcessing:
    		// Do any processing here when the screen is blacked out
    		
    		// Call this when you want to fade the screen in
    		// Function.Call(Hash.DO_SCREEN_FADE_IN, FadeTimer);
    		PlayState = PlaybackState.FadeIn;
    		break;
    }


  • @Jitnaught I use milliseconds.(3000 for 3 seconds)

    @sollaholla I tried that bro, but it didn't work Thanks for your input though.

    @LeeC2202 Thank you so much for the mechanism, which helped me get the basic Idea. and Finally got the solution by modifying your existing method.

    @all Thank you all for your inputs and time, much appreciated.

    So here is the solution I've found.

    So the first Line of code is obviously
    GTA.Native.Function.Call(Hash.DO_SCREEN_FADE_OUT, 3000);

    and the later part

    if (Function.Call<bool>(Hash.IS_SCREEN_FADED_OUT))
    {
    GTA.Native.Function.Call(Hash.DO_SCREEN_FADE_IN, 3000);
    }

    So for all not known how to use fade in / fade out effect, solution is, to add the later part in tick function, so where game will be constantly checking if the screen has faded out. Apart from it I didn't find any other solution working(I could be wrong here).



  • @ashishcw what version of shvdn or the game are you on, the code i posted works fine. i use it in all my mods..



  • @sollaholla I am sorry, it was something wrong with my code. Upon removal of the code, this method works fine too. Thank you so much for it. (:
    P.S. I use version 1.0.944.2 of Scripthook plugin.



  • @ashishcw said in How to Set Screen Fade out / Fade in Effect?:

    GTA.Native.Function.Call(Hash.DO_SCREEN_FADE_OUT, 3000);
    and the later part
    if (Function.Call<bool>(Hash.IS_SCREEN_FADED_OUT))
    {
    GTA.Native.Function.Call(Hash.DO_SCREEN_FADE_IN, 3000);
    }

    :D I actually commented those lines out in the code above to show what to call... not easy to see the comments with the colour schemes that is used on here though, I must confess.

    I think it's important to understand the fundamental difference between both methods, so you choose the one most suitable for your needs.

    Using Wait will pause processing, so if you are drawing on-screen elements, menus, or processing camera movements, object motion etc... those will all pause, or disappear.

    Using states will continue processing but us it requires onTick execution, it's not always the right choice for every situation.

    Knowing about both types and understanding how they function, will make it much easier for you to chose the one you think works best.

    This short video explains it better than my rambling words. :D



  • @LeeC2202 Yes, that is very rightly said, using the wait function will pause the entire script and the below functions/methods will be on hold till the wait(int) int time is over.

    Also, one more thing to note here, I started using int waittime < Game.Gametime more often then wait(int) standalone function.

    The major difference in both,
    Wait Function will pause the entire script for the said time and waittime will just pause that particular function/method.

    BTW, thanks for the video for quick understanding of difference between it. (:



  • @ashishcw said in How to Set Screen Fade out / Fade in Effect?:

    Also, one more thing to note here, I started using int waittime < Game.Gametime more often then wait(int) standalone function.

    I have never used wait in any sense, so I'm not sure how that works... can you give an example please? It could be interesting to know something that pauses the script on a function only level.

    Edit: Sorry, I'm doing something I tell others not to do and that's ask questions that are not part of the main topic. Sorry, I should know better. :(



  • This post is deleted!

Log in to reply
 

Looks like your connection to GTA5-Mods.com Forums was lost, please wait while we try to reconnect.