Raised This Month: $32 Target: $400
 8% 

Request Deathmsg event to include


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
eNNkds
Member
Join Date: Sep 2012
Location: Romania
Old 11-19-2022 , 12:08   Request Deathmsg event to include
Reply With Quote #1

Hello i tried to deathmsg event.
no compile error..
my question is if last line about bool is for user used blocks. will hide the victim used blocks after get i terrorist team?

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <cstrike>

#define PLUGIN    "hideNotUsed"
#define AUTHOR    "DarkGL"
#define VERSION    "1.0"

forward bb_round_started();

new 
pCvarTime ,
    
FloatfAmount    =    255.0 ,
    
FloatfOffset    =    0.0 ;

public 
plugin_init(){
    
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
pCvarTime    =    register_cvar"hideTime" "4.0" );

    
register_event"DeathMsg""DeathMsg""a" )
}
public 
DeathMsg( )
{
    new 
Victim read_data)
    new 
CsTeams:Team cs_get_user_teamVictim )
    
    if(!
is_user_connected(Victim))
    return 
PLUGIN_CONTINUE;
    {
        if( !
is_user_alive(Victim) ) return PLUGIN_HANDLED
        
if( Team == CS_TEAM_T )
           
set_task0.1 "hideAll" );
    }

public 
bb_round_started(){
    
    
fAmount    =    255.0;
    
    
fOffset    =    fAmount / ( get_pcvar_floatpCvarTime ) * 10.0 ) ;
    
    
setBlocksfAmount , .reset true );
    
    
set_task0.1 "hideAll" );
}

public 
hideAll(){
    if( 
fAmount <= 0.0 ){
        
        
setBlocksfAmount , .changeOrigin true );
        
        return ;
    }
    
    
fAmount    -=    fOffset;
    
    
setBlocksfAmount );
    
    
set_task0.1 "hideAll" );
}

setBlocksFloatfAmount boolchangeOrigin false boolreset false ){
    
    new 
szTarget16 ] ,
        
iEnt ;
    
    while( ( 
iEnt engfuncEngFunc_FindEntityByString iEnt "classname" "func_wall" ) ) != ){
        
        if( !
pev_validiEnt ) ){
            continue;
        }
        
        
peviEnt pev_targetname szTarget charsmaxszTarget ) );
        
        if( 
equalszTarget "ignore" ) || equalszTarget "barrier" ) || bb_is_used_blockiEnt ) ){
            continue;
        }
        
        if( 
reset ){
            
set_peviEnt pev_rendermode kRenderNormal );
            
set_peviEnt pev_renderamt 255.0 );
        }
        else if( !
changeOrigin ){
            
set_peviEnt pev_rendermode kRenderTransTexture );
            
set_peviEnt pev_renderamt fAmount );
        }
        
        if( 
changeOrigin ){
            
engfuncEngFunc_SetOrigin iEnt , { 9999.0 9999.0 9999.0 } );
        }
        
    }
}

boolbb_is_used_blockiEnt ){
    return 
peviEnt pev_iuser4 ) != 0;

eNNkds is offline
Send a message via Skype™ to eNNkds
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-19-2022 , 18:34   Re: Request Deathmsg event to include
Reply With Quote #2

You've written the code such that the code is only executed if the player is alive in an event that signifies that the player is dead. Therefore, no code will even be executed.

As for general advice, I'd say that unless you have a whole bunch of conditions that would cause you to return from a function before the main code executes, you should simply put the main code in the if statement with the conditional negated. I.e. instead of saying if the user is not connected then return do if the user is connected then execute the code. It makes the code easier to understand and can help prevent introducing bugs like this one.

Also, I'm not really sure what your question is about. If you are asking about a specific line of code, you need to call that out somehow. Probably the simplest is to add another code block to your post with just the code you're referencing so that we can be sure we're looking for the correct spot in the larger code.
__________________
fysiks is offline
Reply


Thread Tools
Display Modes

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 22:01.


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