Raised This Month: $51 Target: $400
 12% 

[INC] ScreenFade Util [RAGE Supported]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-14-2009 , 14:49   [INC] ScreenFade Util [RAGE Supported]
Reply With Quote #1

Rage version of this : - Clic on me -


Two stocks :

Code:
// Main util
UTIL_ScreenFade(id=0,iColor[3]={0,0,0},Float:flFxTime=-1.0,Float:flHoldTime=0.0,iAlpha=0,iFlags=FFADE_IN,bool:bReliable=false,bool:bExternal=false)

// Util from main util
UTIL_FadeToBlack(id,Float:fxtime=3.0,bool:bReliable=false,bool:bExternal=false)
Details :
  • fxtime and time in seconds (that's the main idea of this util).
  • Color, type : {0-255,0-255,0-255}
  • Alpha, type : 0-255
  • bReliable : if true, uses MSG_ONE or MSG_ALL, if false uses MSG_ONE_UNRELIABLE or MSG_BROADCAST
  • bExternal : if true uses emessage


How to use this stock with a cvar that handle color ?

Cvar should be like this :

Code:
    cvar_pointer = register_cvar("cvar_color", "RRRGGGBBB")
Even if some values are less than 100, you should put the 3 digits, aka 10 -> 010


Then to retrieve the color use :

PHP Code:
get_cvar_colorg_pCvar )
{
    new 
Color[3]

    new 
iTemp get_pcvar_num(g_pCvar)
    
Color[0] = iTemp 1000000
    iTemp 
%= 1000000
    Color
[1] = iTemp 1000
    Color
[2] = iTemp 1000

    
return Color

Example with 2 other ways (less efficient) to handle colors by cvars : -link-
Attached Files
File Type: inc screenfade_util.inc (2.0 KB, 4050 views)
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 03-24-2012 at 08:11.
ConnorMcLeod is offline
Dr.G
Senior Member
Join Date: Nov 2008
Old 03-14-2009 , 16:02   Re: ScreenFade Util
Reply With Quote #2

k+! well done
__________________
Dr.G is offline
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 03-21-2009 , 21:33   Re: [INC] ScreenFade Util
Reply With Quote #3

Hey,

Have a see here please : http://forums.alliedmods.net/showthread.php?t=88224
__________________
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
{PHILMAGROIN}
Senior Member
Join Date: Aug 2007
Location: In the middle of the des
Old 05-17-2009 , 11:58   Re: [INC] ScreenFade Util
Reply With Quote #4

so with this you would not be able to make a cvar "rgb" colors becuase there has to be a value in the {0,0,0} correct?
__________________
[B]
{PHILMAGROIN} is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 05-17-2009 , 12:38   Re: [INC] ScreenFade Util
Reply With Quote #5

they are rgb, {R, G, B}
__________________
xPaw is offline
{PHILMAGROIN}
Senior Member
Join Date: Aug 2007
Location: In the middle of the des
Old 05-17-2009 , 13:06   Re: [INC] ScreenFade Util
Reply With Quote #6

Quote:
Originally Posted by xPaw View Post
they are rgb, {R, G, B}
yes i know. but if you wanted to make a cvar so you could change those ingame. you couldn't with this correct?
__________________
[B]
{PHILMAGROIN} is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 05-17-2009 , 15:02   Re: [INC] ScreenFade Util
Reply With Quote #7

Quote:
Originally Posted by {PHILMAGROIN} View Post
yes i know. but if you wanted to make a cvar so you could change those ingame. you couldn't with this correct?
Like this?
PHP Code:
new gCvar];
public 
plugin_init( ) 
{
    
gCvar] = register_cvar"color_red""100" );
    
gCvar] = register_cvar"color_green""255" );
    
gCvar] = register_cvar"color_blue""0" );
}
funcid )
{
    new 
iColor];
    
iColor] = get_pcvar_numgCvar] );
    
iColor] = get_pcvar_numgCvar] );
    
iColor] = get_pcvar_numgCvar] );
    
UTIL_ScreenFadeidiColor1.0....... );


Last edited by SnoW; 05-17-2009 at 15:06.
SnoW is offline
Send a message via MSN to SnoW
{PHILMAGROIN}
Senior Member
Join Date: Aug 2007
Location: In the middle of the des
Old 05-17-2009 , 16:17   Re: [INC] ScreenFade Util
Reply With Quote #8

Quote:
Originally Posted by SnoW View Post
Like this?
PHP Code:
new gCvar];
public 
plugin_init( ) 
{
    
gCvar] = register_cvar"color_red""100" );
    
gCvar] = register_cvar"color_green""255" );
    
gCvar] = register_cvar"color_blue""0" );
}
funcid )
{
    new 
iColor];
    
iColor] = get_pcvar_numgCvar] );
    
iColor] = get_pcvar_numgCvar] );
    
iColor] = get_pcvar_numgCvar] );
    
UTIL_ScreenFadeidiColor1.0....... );

maybe. but i was thinking more like on cvar. like i_colors "255 0 0"
__________________
[B]
{PHILMAGROIN} is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 05-17-2009 , 16:24   Re: [INC] ScreenFade Util
Reply With Quote #9

Example with 3 way to handle colors by cvars :

way 1 is recommanded, way 2 is deprecated.

PHP Code:
#include <amxmodx>
#include "screenfade_util.inc"

new g_pCvarType1
    
g_pCvarType2
    
g_pCvarType3_Redg_pCvarType3_Greeng_pCvarType3_Blue

public plugin_init()
{
    
register_plugin("color test""0.1""noob")

    
g_pCvarType1 register_cvar("color_type1""000200000")

    
g_pCvarType2 register_cvar("color_type2""0 200 0")

    
g_pCvarType3_Red register_cvar("color_type3_red""0")
    
g_pCvarType3_Green register_cvar("color_type3_green""200")
    
g_pCvarType3_Blue register_cvar("color_type3_blue""0")

    
register_clcmd("say test1""test1")
    
register_clcmd("say test2""test2")
    
register_clcmd("say test3""test3")
}

public 
test1id )
{
    
UTIL_ScreenFade(idget_cvar_color1(g_pCvarType1), 10.010.0250)
    return 
PLUGIN_HANDLED
}

public 
test2id )
{
    
UTIL_ScreenFade(idget_cvar_color2(g_pCvarType2), 10.010.0250)
    return 
PLUGIN_HANDLED
}

public 
test3id )
{
    
UTIL_ScreenFade(idget_cvar_color3(g_pCvarType3_Redg_pCvarType3_Greeng_pCvarType3_Blue), 10.010.0250)
    return 
PLUGIN_HANDLED
}

stock get_cvar_color1g_pCvar // 4 natives // 1 if don't use clamp
{
    new 
Color[3]

    new 
iTemp get_pcvar_num(g_pCvar)
    
Color[0] = clamp(iTemp 10000000255)
    
iTemp %= 1000000
    Color
[1] = clamp(iTemp 10000255)
    
Color[2] = clamp(iTemp 10000255)

    return 
Color
}

stock get_cvar_color2g_pCvar // 8 natives // 5 if don't use clamp
{
    new 
Color[3]

    new 
szColor[12// "RRR GGG BBB"
    
get_pcvar_string(g_pCvarszColorcharsmax(szColor))

    new 
szRed[4], szGreen[4], szBlue[4]
    
parse(szColorszRedcharsmax(szRed), szGreencharsmax(szGreen), szBluecharsmax(szBlue))
    
Color[0] = clamp(str_to_num(szRed), 0255)
    
Color[1] = clamp(str_to_num(szGreen), 0255)
    
Color[2] = clamp(str_to_num(szBlue), 0255)

    return 
Color
}

stock get_cvar_color3g_pCvar_Redg_pCvar_Greeng_pCvar_Blue // 6 natives // 3 if don't use clamp
{
    new 
Color[3]

    
Color[0] = clamp(get_pcvar_num(g_pCvar_Red), 0255)
    
Color[1] = clamp(get_pcvar_num(g_pCvar_Green), 0255)
    
Color[2] = clamp(get_pcvar_num(g_pCvar_Blue), 0255)

    return 
Color

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 04-04-2010 at 03:46.
ConnorMcLeod is offline
{PHILMAGROIN}
Senior Member
Join Date: Aug 2007
Location: In the middle of the des
Old 05-17-2009 , 18:00   Re: [INC] ScreenFade Util
Reply With Quote #10

Quote:
Originally Posted by ConnorMcLeod View Post
Something like this ? :

PHP Code:
new iColor[3] = GetColorCVAR_POINTER )

GetColorCVAR_POINTER )
{
    new 
szColors[16], szRed[4], szGreen[4], szBlue[4]
    
get_pcvar_string(CVAR_POINTERszColorscharsmax(szColors))

    new 
iColor[3]
    
iColor[0] = GetColorByte(szRed)
    
iColor[1] = GetColorByte(szGreen)
    
iColor[2] = GetColorByte(szBlue)

    return 
iColor
}

GetColorByte(szColor[4])
{
    new 
iByte str_to_num(szColor)
    if( 
iByte )
    {
        return 
0
    
}
    if( 
iByte 0xFF )
    {
        return 
0xFF
    
}
    return 
iByte

ive been looking trying to understand this and its not working very well haha. but what i think might be right is i would make a cvar from what you have given me which would be like
PHP Code:
iColor register_cvar"i_color""255 0 0" 
is that correct?

Edit: so ive been messing around with it. and nothing. here is the latest method I have tried:
PHP Code:
     #include <amxmodx>
#include <screenfade_util>

new gCvar_Color;

public 
plugin_init() 
{
    
register_pluginPLUGINVERSIONAUTHOR );
    
    
register_event"DeathMsg" "fwDeathMsg" "a" );
    
    
gCvar_Color register_cvar"stk_Color""255 0 0" )
    
}

public 
fwDeathMsg(id
{
            if( 
get_pcvar_numgCvar_Screenfade ))
            { 
            new 
Color_redColor_greenColor_blue;
            new 
color[16], red[4], green[4], blue[4];
            
get_pcvar_string(gCvar_Colorcolor15);
            
parse(colorred3green3blue3);
            
            
Color_red str_to_num(red);
            
Color_green str_to_num(green);
            
Color_blue str_to_num(blue);
                
            
UTIL_ScreenFadeid, {gCvar_Color},1.0,0.0,75  );
            }
        }
    }

this isnt all of the code but its what i have done to it. the error is: Error: Must be a constant expression; assumed zero on line 57 <--- that is the UTIL_ScreenFade line the last line of code. any ideas?
__________________
[B]

Last edited by {PHILMAGROIN}; 05-17-2009 at 18:36.
{PHILMAGROIN} is offline
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 10:52.


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