AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   ScreenFade And How to Control it! (https://forums.alliedmods.net/showthread.php?t=10726)

TotalNoobScripter 02-27-2005 13:42

ScreenFade And How to Control it!
 
Code:

message_begin(MSG_ONE, get_user_msgid("ScreenFade"), {0,0,0}, victimer)
write_short( 1<<2 )
write_short( 1<<2 )
write_short( 1<<2 )
write_byte( 200 ) // Red
write_byte( 0 ) // Green
write_byte( 0 ) // Blue
write_byte( 100 ) // Alpha
message_end()

what exactly does the 3 write shorts do, and instead of a number why is it 1<<2 ?

TotalNoobScripter 02-27-2005 14:01

Better yet, can someone give me the file name of the include that gives more info on this? That is if there is an include, because I'm assuming messages arent included in anything, they just set half-life stuff.

PM 02-27-2005 14:44

HLSdk, Multiplayer Source/dlls/util.cpp, UTIL_ScreenFadeWrite:

Code:

        MESSAGE_BEGIN( MSG_ONE, gmsgFade, NULL, pEntity->edict() );                // use the magic #1 for "one client"
               
                WRITE_SHORT( fade.duration );                // fade lasts this long
                WRITE_SHORT( fade.holdTime );                // fade lasts this long
                WRITE_SHORT( fade.fadeFlags );                // fade type (in / out)
                WRITE_BYTE( fade.r );                                // fade red
                WRITE_BYTE( fade.g );                                // fade green
                WRITE_BYTE( fade.b );                                // fade blue
                WRITE_BYTE( fade.a );                                // fade blue

        MESSAGE_END();

As you can see, the last comment is a bit misleading, it IS alpha. I'm not sure about the difference between duration and holdTime, but:
Code:

        fade.duration = FixedUnsigned16( fadeTime, 1<<12 );                // 4.12 fixed
        fade.holdTime = FixedUnsigned16( fadeHold, 1<<12 );                // 4.12 fixed

Maybe you can see more in these terms ^^

xeroblood 02-27-2005 21:25

Re: ScreenFade And How to Control it!
 
Quote:

Originally Posted by TotalNoobScripter
... and instead of a number why is it 1<<2 ?

1<<2 is basically 4, so you could just put the number 4 there...

That is called bit-shifting, and the math is basically:

1<<X

1 * 2 ^ X
or
1 * 2 to the power of X

Example:

1<<3
1 * 2 ^ 3
1 * 2 * 2 * 2
= 8


Also, I have been working on the ScreenFade myself for a new plugin Im making, I wrote this bit of code to test the different uses of the screenfade:
Code:
#include <amxmodx> public plugin_init() {     register_clcmd( "amx_fade", "DoFade" ) } public DoFade( id ) {     new iArgs[7] = { 9000, 1000, 5, 0, 0, 0, 255 }     if( read_argc() > 1 )     {         new szArgs[7][5]         for( new i = 0; i < 7; i++ )         {             read_argv( (i+1), szArgs[i], 4 )             iArgs[i] = str_to_num( szArgs[i] )         }     }     UAIO_FadeScreen( id, iArgs )     return PLUGIN_HANDLED } stock UAIO_FadeScreen( iUser, iArgs[] ) {     message_begin( MSG_ONE, get_user_msgid("ScreenFade"), {0,0,0}, iUser )     write_short( iArgs[0] )     // Fade Time     write_short( iArgs[1] )     // Fade Hold     write_short( iArgs[2] )     // Fade Type (in/out)     write_byte ( iArgs[3] )     // Red     write_byte ( iArgs[4] )     // Green     write_byte ( iArgs[5] )     // Blue     write_byte ( iArgs[6] )     // Alpha     message_end()     return }

Its usage is simple:
amx_fade <time> <hold> <type> <r> <g> [b] <a>

A good example would be:
Fade Into Black: 9000 1000 5 0 0 0 255
Fade Back Out: 9000 1000 2 0 0 0 255

The 9000 gives it a nice long fade time, but in my experiments, anything over 9999 gave a shorter fade time.. weird...

Also, I was trying to make one command do the same as both, Fade in, Hold fade, then Fade out... But it seems you have to Fade in, Hold and then Fade back out on your own..

Twilight Suzuka 02-27-2005 21:53

Its because large numbers confuse the engine, and it sub's in its own.


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

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