AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Trying to get a user's screen to go black for 2 seconds... (https://forums.alliedmods.net/showthread.php?t=29850)

Geesu 06-14-2006 00:56

Trying to get a user's screen to go black for 2 seconds...
 
I'm useing screenfade....

But how do I get the duration to last for 2 seconds? I'm just not sure what "type" i.e. ms or s the message accepts...

I'm doing:

Create_ScreenFade( iAttacker, 2, (1<<10), (1<<12), 0, 0, 0, 255 );


Code:
stock Create_ScreenFade(id, duration, holdtime, fadetype, red, green, blue, alpha){     message_begin( MSG_ONE,gmsgScreenFade,{0,0,0},id )              write_short( duration )         // fade lasts this long duration     write_short( holdtime )         // fade lasts this long hold time     write_short( fadetype )         // fade type (in / out)     write_byte( red )               // fade red     write_byte( green )             // fade green     write_byte( blue )              // fade blue     write_byte( alpha )             // fade alpha     message_end() }

Thanks,
Josh

Emp` 06-14-2006 01:07

i believe that the duration is in decisecs, so try 20 instead of 2

Geesu 06-14-2006 01:10

nope :/

Emp` 06-14-2006 01:11

i don't know why, but i would also try duration and holdtime both at 20

Geesu 06-14-2006 01:15

hehe yea i did that too :/ Been trying a bunch of diff. combos... My current solution is to loop a set_task at 0.1 seconds... it works but i'd prefer just giving it a longer time :/

jtp10181 06-14-2006 01:16

This is a stock from superhero

Code:
stock setScreenFlash(id, red, green, blue, decisecs, alpha) {     if (!is_user_connected(id)) return     message_begin(MSG_ONE,get_user_msgid("ScreenFade"),{0,0,0},id)     write_short( 1<<decisecs ) // fade lasts this long duration     write_short( 1<<decisecs ) // fade lasts this long hold time     write_short( 1<<12 ) // fade type (in / out)     write_byte( red ) // fade red     write_byte( green ) // fade green     write_byte( blue ) // fade blue     write_byte( alpha ) // fade alpha     message_end() }

and here is an example of it being used

Code:
            new alphanum = damage * 2             if (alphanum > 200) alphanum = 200             else if (alphanum < 40) alphanum = 40             setScreenFlash(attacker, 255, 10, 10, 10, alphanum )  //Red Screen Flash

this ends up being a pretty quick red flash with a varying alpha ammount.

Some colors are not allowed so you might want to try another color first (like the one I use here works for sure). Another option would be to use a message logger and then enable that cvar "fadetoblack". Catch that message and then replicate it.

Emp` 06-14-2006 01:18

hehe, thats actually what ive got going on in my pokemod... another thing you could do is
Code:

                message_begin(MSG_ONE,gmsgFade,{0,0,0},id)
                write_short( 15 )
                write_short( 15 )
                write_short( 12 )
                write_byte( r )
                write_byte( g )
                write_byte( b )
                write_byte( alpha )
                message_end()

and then when you want it to end you can just do your create_screenfade.

anyone got an answer, im curious now also.

edit: jtp, i dont know if it was you i talked to, but with that, it still wouldnt go over 1 second.

VEN 06-14-2006 05:57

jtp10181: Let's say i input 50 decisecs (5 seconds) duration will be 1_125_899_906_842_624, doesn't seems to be correct. ;)

Below is the my method.


For int seconds:
Code:
#define SECONDS_TO_SCREENFADE_UNITS(%1) ((1<<12) * (%1))

For float and int seconds (a bit slower):
Code:
#define SECONDS_TO_SCREENFADE_UNITS(%1) floatround(float((1<<12)) * (%1))

jtp10181 06-14-2006 09:47

yeah I don't know how the seconds works really, thats just what was in there when I started working on SH. Like I said, best bet would be to catch a message and then copy it.


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

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