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

Solved Hooking ScreenFade


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
davidto1995
Member
Join Date: Jul 2010
Location: hong kong
Old 05-02-2021 , 03:25   Hooking ScreenFade
Reply With Quote #1

I tried to hook ScreenFade messages and block some of them.

PHP Code:
register_messageget_user_msgid"ScreenFade" ) , "msgScreenFade" ); // Hook ScreenFade messages 
PHP Code:
public msgScreenFademsg_id msg_dest msg_entity )
{

    new 
boolplayer_blinded boolget_xvar_numXVar_IsAllHumanBlind );

    
client_printprint_chat "player_blinded: %i" player_blinded );

    if( 
player_blinded )
    {

        return 
PLUGIN_HANDLED;

    }
    else
    {

        return 
PLUGIN_CONTINUE;

    }


PHP Code:
stock fade_user_screen(idFloat:duration 1.0Float:fadetime 1.0ScreenFadeFlags:flags ScreenFade_FadeIn0025575bool:reliable true)
{
    if(
id && !is_user_connected(id))
        return 
0;

    static 
MSG_ScreenFade;

    if(!
MSG_ScreenFade)
        
MSG_ScreenFade get_user_msgid("ScreenFade");

    
message_begin(get_msg_destination(idreliable), MSG_ScreenFade, .player id);
    
write_short(float_to_short(fadetime));
    
write_short(float_to_short(duration));
    
write_short(_:flags);
    
write_byte(r);
    
write_byte(g);
    
write_byte(b);
    
write_byte(a);
    
message_end();

    return 
1;

However, except at the time when a player spawned ( client_print() called ), the ScreenFade message is not hooked at any time during the game ( no client_print() called ).

Last edited by davidto1995; 05-06-2021 at 11:24.
davidto1995 is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 05-02-2021 , 07:47   Re: Hooking ScreenFade
Reply With Quote #2

If you're trying to hook screenfade sent by other plugins they need to send it using emessage_*()/ewrite_*() natives.

Code:
/* These are the same as above, except that the messages sent  *  are also sent to all other plugins and Metamod plugins.  * This means that if you send one of these messages, other plugins will  *  be notified, which was previously impossible.   * BE CAREFUL! Using these incorrectly, or not for their intended purpose,  *  could cause infinite recursion or something just as bad.  * NOTE! These natives are experimental.  */ native emessage_begin(dest, msg_type, const origin[3] = {0,0,0}, player = 0); native emessage_end(); native ewrite_byte(x); native ewrite_char(x); native ewrite_short(x); native ewrite_long(x); native ewrite_entity(x); native ewrite_angle(x); native ewrite_coord(x); native ewrite_string(const x[]);
__________________
Black Rose is offline
davidto1995
Member
Join Date: Jul 2010
Location: hong kong
Old 05-05-2021 , 19:10   Re: Hooking ScreenFade
Reply With Quote #3

Thanks it is solved.
davidto1995 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