Raised This Month: $ Target: $400
 0% 

ScreenFade And How to Control it!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
TotalNoobScripter
Senior Member
Join Date: Aug 2004
Old 02-27-2005 , 13:42   ScreenFade And How to Control it!
Reply With Quote #1

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 is offline
Send a message via AIM to TotalNoobScripter
TotalNoobScripter
Senior Member
Join Date: Aug 2004
Old 02-27-2005 , 14:01  
Reply With Quote #2

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.
TotalNoobScripter is offline
Send a message via AIM to TotalNoobScripter
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 02-27-2005 , 14:44  
Reply With Quote #3

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 ^^
__________________
hello, i am pm
PM is offline
xeroblood
BANNED
Join Date: Mar 2004
Location: Toronto, Canada
Old 02-27-2005 , 21:25   Re: ScreenFade And How to Control it!
Reply With Quote #4

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..
xeroblood is offline
Send a message via MSN to xeroblood
Twilight Suzuka
bad
Join Date: Jul 2004
Location: CS lab
Old 02-27-2005 , 21:53  
Reply With Quote #5

Its because large numbers confuse the engine, and it sub's in its own.
__________________
Twilight Suzuka is offline
Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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