AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   black screen fade (https://forums.alliedmods.net/showthread.php?t=72932)

whosyourdaddy 06-18-2008 19:35

black screen fade
 
what is the script to fade a person screen black for 15 seconds?

Exolent[jNr] 06-18-2008 21:02

Re: black screen fade
 
What to add in plugin:
Code:

new g_MaxPlayers;
new g_msgScreenFade;

public plugin_init()
{
    g_MaxPlayers = get_maxplayers();
    g_msgScreenFade = get_user_msgid("ScreenFade");
}

make_ScreenFade(plr, Float:fDuration, red, green, blue, alpha)
{
        new i = plr ? plr : get_player();
        if( !i )
        {
                return 0;
        }
       
        message_begin(plr ? MSG_ONE : MSG_ALL, g_msgScreenFade, {0, 0, 0}, plr);
        write_short(floatround(4096.0 * fDuration, floatround_round));
        write_short(floatround(4096.0 * fDuration, floatround_round));
        write_short(4096);
        write_byte(red);
        write_byte(green);
        write_byte(blue);
        write_byte(alpha);
        message_end();
       
        return 1;
}

get_player()
{
        for( new plr = 1; plr <= g_MaxPlayers; plr++ )
        {
                if( is_user_connected(plr) )
                {
                        return plr;
                }
        }
       
        return 0;
}

How to use:
Code:

// plr is the player index
// fDuration is the time in seconds to be displayed
// red, green, and blue are the RGB colors for the final color
// alpha is the transparency of the color

Example:
Code:

public my_func(id)
{
    make_ScreenFade(id, 15.0, 0, 0, 0, 255);
}


Exolent[jNr] 06-19-2008 00:46

Re: black screen fade
 
Well, apparently, you can't copy my code correctly.
So, I'll change the tags to [code] tags.

And the id is the index that you are using in the plugin.
If you don't know how to use simple functions, I can't help you.

whosyourdaddy 06-19-2008 00:48

Re: black screen fade
 
lol sorry i kidna think i found out how to use it but can u make it [code] please, im just a little tired

whosyourdaddy 06-19-2008 01:37

Re: black screen fade
 
it works great thank you alot

whosyourdaddy 06-19-2008 03:09

Re: black screen fade
 
im kinda having a time issue im using this atm
Code:

make_ScreenFade(id, get_cvar_float("rules_hudmessage_time"), 0, 0, 0, 255);
and my rules_hudmessage_time is 35, i also tried switching it with 35.0 but the black screen seems to be workign only for 3 seconds and then it fades away

edited* i noticed u cant do more then 30 seconds so i thought i could do like a set_task but im not sure how to do it.. this is what im currently doing
Code:

public my_func(id)
{
  make_ScreenFade(id, 29.0, 0, 0, 0, 255);
      set_task(24, my_funcc(id))
 
}
 
public my_funcc(id)
{
  make_ScreenFade(id, 10.0, 0, 0, 0, 255);
 
}

but of course the set_task is wrong, how would i fix it

Exolent[jNr] 06-19-2008 12:05

Re: black screen fade
 
Code:

public my_func(id)
{
    new Float:length = get_cvar_float("rules_hudmessage_time");
    /* you should convert this to pcvar */
   
    make_ScreenFade(id, length, 0, 0, 0, 255);
    set_task(length, "task_Blind", id);
}

public task_Blind(id)
{
    new Float:length = <your value here>;
    make_ScreenFade(id, length, 0, 0, 0, 255);
}


whosyourdaddy 06-19-2008 14:11

Re: black screen fade
 
woot it works perfectly now, but is there a way to put something in it so it waits till the player is dead and then it does the screen fades?

Sn!ff3r 06-19-2008 14:13

Re: black screen fade
 
Quote:

till the player is dead and then it does the screen fades?
Your english is bad... maybe you want
Code:

mp_fadetoblack 1
?

whosyourdaddy 06-19-2008 14:15

Re: black screen fade
 
well what i doing is having a black screen pop up and then the rules for our server in a hud message but i want this to happen once the player dies, think you can write what i need to put in the script please.

mabye something like

if(!is_user_alive(id))
{
my_func(id)
}

or put like a set task on it so it will wait till the user dies or something and then does my function


All times are GMT -4. The time now is 03:07.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.