Raised This Month: $ Target: $400
 0% 

shake


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 05-31-2013 , 14:48   Re: shake
Reply With Quote #1

PHP Code:
stock FixedUnsigned16Float:valuescale )
{
    new 
output;

    
output floatround(value scale);
    if ( 
output )
        
output 0;
    if ( 
output 0xFFFF )
        
output 0xFFFF;

    return 
output;
}

// ScreenShake
stock Util_ScreenShake(idFloat:durationFloat:frequencyFloat:amplitude)
{
    static 
ScreenShake 0;
    if( !
ScreenShake )
    {
        
ScreenShake get_user_msgid("ScreenShake");
    }
    
message_beginid MSG_ONE MSG_ALLScreenShake_id);
    
write_shortFixedUnsigned16amplitude1<<12 ) ); // shake amount
    
write_shortFixedUnsigned16duration1<<12 ) ); // shake lasts this long
    
write_shortFixedUnsigned16frequency1<<) ); // shake noise frequency
    
message_end();
}

// ScreenFade
enum ( <<=){
    
FFADE_IN// Just here so we don't pass 0 into the function
    
FFADE_OUT 1// Fade out (not in)
    
FFADE_MODULATE// Modulate (don't blend)
    
FFADE_STAYOUT // ignores the duration, stays faded out until new ScreenFade message received
}

enum {
    
_Red,
    
_Green,
    
_Blue
};

stock UTIL_ScreenFade(const id=0,const iColor[3]={0,0,0},const Float:flFxTime=-1.0,const Float:flHoldTime=0.0,const iAlpha=0,const iFlags=FFADE_IN,bool:bReliable=false,bool:bExternal=false)
{
    if( 
id && !is_user_connected(id))
        return;

    new 
iFadeTime;
    if( 
flFxTime == -1.0 )
    {
        
iFadeTime 4;
    }
    else
    {
        
iFadeTime FixedUnsigned16flFxTime 1<<12 );
    }

    static 
msgScreenFade 0;
    if( !
msgScreenFade )
    {
        
msgScreenFade get_user_msgid("ScreenFade");
    }

    new 
MSG_DEST;
    if( 
bReliable )
    {
        
MSG_DEST id MSG_ONE MSG_ALL;
    }
    else
    {
        
MSG_DEST id MSG_ONE_UNRELIABLE MSG_BROADCAST;
    }

    if( 
bExternal )
    {
        
emessage_beginMSG_DESTmsgScreenFade_id );
        
ewrite_shortiFadeTime );
        
ewrite_shortFixedUnsigned16flHoldTime 1<<12 ) );
        
ewrite_shortiFlags );
        
ewrite_byteiColor[_Red] );
        
ewrite_byteiColor[_Green] );
        
ewrite_byteiColor[_Blue] );
        
ewrite_byteiAlpha );
        
emessage_end();
    }
    else
    {
        
message_beginMSG_DESTmsgScreenFade_id );
        
write_shortiFadeTime );
        
write_shortFixedUnsigned16flHoldTime 1<<12 ) );
        
write_shortiFlags );
        
write_byteiColor[_Red] );
        
write_byteiColor[_Green] );
        
write_byteiColor[_Blue] );
        
write_byteiAlpha );
        
message_end();
    }

->

PHP Code:
public shake(id)
{
    
UTIL_ScreenFade(id, {34,34,139}, 4.00.00175)
    
Util_ScreenShake(id3.0255.015.0// maxs : ( , 15.0, 255.0, 15.0)

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 05-31-2013 at 15:18.
ConnorMcLeod 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 16:14.


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