AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Fade code (https://forums.alliedmods.net/showthread.php?t=131118)

zombieplague 07-01-2010 09:02

Fade code
 
Anyone have the fading code ? is like flash bang style, I want it fade the player screen and it will return to normal in 5 second time

infek 07-01-2010 14:00

Re: Fade code
 
This is how wrecked helped me a while back so here you go
PHP Code:

/**
 * Sends screenfade message to a player
 *
 * @param id        Player index to screenfade
 * @param r       Red value in rgb format
 * @param g       Green value in rgb format
 * @param b          Blue value in rgb format
 * @param alpha     Fade alpha
 * @param holdtime  Float on how long to hold
 */
 
stock ScreenFade(idrgbalphaFloat:holdtime)
{
    new 
_holdtime floatround(holdtime 10.0),
        
duration  floatround(_holdtime 1.25);
    
message_begin(MSG_ONE_UNRELIABLEget_user_msgid"ScreenFade" ), { 00}, id);
    
write_short(1<<duration); // duration
    
write_short(1<<_holdtime); // holdtime
    
write_short(2);    // fade out
    
write_byte(r);
    
write_byte(g);
    
write_byte(b);
    
write_byte(alpha);
    
message_end();


Usage example:
Code:

ScreenFade( id, 255, 0, 0, 120, 10.0 )
That would make a screenfade (red, semi-transparent) for 10 seconds. The 6th parameter must be a float.

ConnorMcLeod 07-01-2010 15:01

Re: Fade code
 
http://forums.alliedmods.net/showthread.php?t=87623

shuttle_wave 07-02-2010 03:39

Re: Fade code
 
this is how i do my screen fade

PHP Code:

new g_msgScreenFade;

public 
plugin_init
{
     
//..........YOU THINGS THERE...........

      
g_msgScreenFade    get_user_msgid("ScreenFade");

}

// Sets screen to white, then fades out
ScreenFade(index)
{
    
message_begin(MSG_ONE_UNRELIABLEg_msgScreenFade, {000}, index);
    
write_short(floatround((1<<12) * 0.5));
    
write_short(floatround((1<<12) * 0.1));
    
write_short(1<<12);
    
write_byte(255);
    
write_byte(255);
    
write_byte(255);
    
write_byte(255);
    
message_end();
}


// JUST USE ScreenFade(id); to make a screen fade 



All times are GMT -4. The time now is 14:47.

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