Raised This Month: $ Target: $400
 0% 

Problem with lasermine, crash the server


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Netsys
Senior Member
Join Date: Feb 2010
Old 08-18-2012 , 20:30   Problem with lasermine, crash the server
Reply With Quote #1

Hi, i have a problem with the lasermine, i'm testing the server without lasermine and its run right.

Think:
PHP Code:
/* Lasermine think */
public lasermine_thinkentity )
{
    
/* Lasermine disabled? */
    
if( !get_pcvar_numcvar[CVAR_HUMAN_LASERMINE] ) )
        return;
    
    
/* Check if valid entity */
    
if( !is_valid_ententity ) )
        return;
    
    static 
Float:fCurrTime;
    
fCurrTime get_gametime();
    
    switch( 
entity_get_intentity EV_INT_iuser4 ) ) 
    { 
        case 
0
        { 
            static 
Float:fPowerupTime;
            
fPowerupTime entity_get_floatentity EV_FL_fuser2 );
            
            if( 
fCurrTime fPowerupTime )
            {
                
entity_set_intentity EV_INT_iuser4 );
                
emit_soundentity CHAN_VOICE g_sound_lm[2] , 0.5 ATTN_NORM 175 );
                
                
/* Check if player stuck in the lasermine */
                
static Float:originF[3], classname[32], owneriuser4playerrecovery;
                
entity_get_vectorentity EV_VEC_origin originF );
                
owner entity_get_intentity EV_INT_iuser3 );
                
player = -1;
                
iuser4 1;
                
recovery false;
                
                
                while( ( 
player find_ent_in_sphereplayer originF 7.5 ) ) != )
                {
                    if( !
is_valid_entplayer ) )
                        continue;
                        
                    
entity_get_stringplayer EV_SZ_classname classname charsmaxclassname ) );
                    
                    if( 
equalclassname "player" ) )
                    {
                        if( !
is_user_valid_connectedplayer ) )
                            continue;
                        
                        if( 
owner != player && !recovery )
                        {
                            
g_lm[owner]++;
                            
colored_printowner "^x04[%s]^x01 Has recuperado^x03 1^x01 lasermine"TAG_PRINT );
                            
recovery true;
                        }
                        
                        
iuser4 2;
                    }
                }
                
                
entity_set_intentity EV_INT_solid SOLID_BBOX );
                
entity_set_intentity EV_INT_iuser4 iuser4 );
            }
            
            
/* Set rendering */
            
set_renderingentity kRenderFxGlowShell 255 kRenderNormal );

            
/* Next think */
            
entity_set_floatentity EV_FL_nextthink fCurrTime 0.1 );
        }
        case 
1:
        {
            static 
Float:vEnd[3],Float:vOrigin[3];
            
entity_get_vectorentity EV_VEC_origin vOrigin );
            
entity_get_vectorentity EV_VEC_vuser1 vEnd );
            
            static 
victimFloat:vHitOrigin[3];
            
victim trace_lineentity vOrigin vEnd vHitOrigin );
            
            
/* Is valid victim? */
            
if( is_user_valid_alivevictim ) ) 
            { 
                
/* Is a zombie? */
                
if( g_zombie[victim] ) 
                { 
                    
entity_set_intentity EV_INT_iuser4 );
                    
entity_set_floatentity EV_FL_nextthink fCurrTime 0.01 );
                    return;
                } 
            } 
            else 
                
vEnd vHitOrigin 
            
            
/* Lasermine death by a zombie? */
            
if( entity_get_intentity EV_INT_flags ) & FL_KILLME || entity_get_floatentity EV_FL_health) <= 0.0 
            { 
                
entity_set_intentity EV_INT_iuser4 );
                
entity_set_floatentity EV_FL_nextthink fCurrTime 0.01 );
                return;
            } 
            
            static 
Float:fBeamthinkFloat:laser_end[3];
            
fBeamthink entity_get_floatentity EV_FL_fuser3 );
            
entity_get_vectorentity EV_VEC_vuser2 laser_end );
            
            if( 
fBeamthink fCurrTime || !xs_vec_equallaser_end vEnd ) ) 
            { 
                if( !
xs_vec_equallaser_end vEnd ) ) 
                { 
                    
message_beginMSG_BROADCAST SVC_TEMPENTITY );
                    
write_byte99 );
                    
write_shortentity ); 
                    
message_end( );
                } 
                
                
ShowLaservOrigin vEnd );
                
entity_set_floatentity EV_FL_fuser3 fCurrTime 10.0 ); 
            } 
            
            
entity_set_floatentity EV_FL_nextthink fCurrTime 0.12 );
        }
        case 
2
        { 
            
entity_set_floatentity EV_FL_nextthink 0.0 ); 
            
            
/* Create explosion */
            
CrearDamageentity  );
            
            
emit_soundentity CHAN_BODY g_sound_lm[1] , 0.2 ATTN_NORM SND_STOP PITCH_NORM );
            
emit_soundentity CHAN_VOICE g_sound_lm[2] , 0.5 ATTN_NORM SND_STOP ,  75 );
            
            
/* Remove entity */
            
remove_entityentity ); 
        }
    }

Explosion:
PHP Code:
CrearDamageentity )
{
    
/* Create explosion effect */
    
static Float:originF[3];
    
entity_get_vectorentity EV_VEC_origin originF );
    
    
engfuncEngFunc_MessageBegin MSG_PVS SVC_TEMPENTITY originF);
    
write_byteTE_EXPLOSION );
    
engfuncEngFunc_WriteCoord originF[0] );
    
engfuncEngFunc_WriteCoord originF[1] );
    
engfuncEngFunc_WriteCoord originF[2] );
    
write_shortg_lmExplosionSpr );
    
write_byte30 );
    
write_byte15 );
    
write_byte);
    
message_end( ); 
    
    static 
Float:vic_originF[3],  iddamagethpFloat:distFloat:pos_ptd[3];
    
    for( 
id 1id <= g_maxplayersid++ )
    {
        if( !
is_user_valid_aliveid ) )
            continue;
        
        
/* Get origin of the victim */
        
entity_get_vectorid EV_VEC_origin vic_originF );
        
        
/* Calculate the distance */
        
dist get_distance_foriginFvic_originF );
        
        if( 
dist 220.0 
            continue;
        
        
xs_vec_copyvic_originFpos_ptd );
        
        for(new 
03i++) 
        { 
            
pos_ptd[i] -= originF[i];
            
pos_ptd[i] *= get_pcvar_float(cvar[CVAR_HUMAN_LASERMINE_EXP]);
        } 
        
        
entity_set_vectorid EV_VEC_velocity pos_ptd ); 
        
entity_set_vectorid EV_INT_impulse pos_ptd ); 
        
        
/* If a zombie? */
        
if( !g_zombie[id] )
            continue;
            
        
/* If frozen? */
        
if( g_frozen[id] || g_nodamage[id] )
            continue;
        
        
damaget floatround( ( ( 5000.0 dist ) / 220.0 ) - 5000.0 );
        
damaget = -damaget;
        
        
hp = ( get_user_healthid ) - damaget );
        
        if( 
hp <= 
            
hp 1;
        
        
/* Set the health */
        
set_user_healthid hp );
        
        
message_beginMSG_ONE_UNRELIABLE g_msgDamage id );
        
write_byte21 );
        
write_byte20 ); 
        
write_longDMG_BLAST 
        
engfuncEngFunc_WriteCoord originF[0] );
        
engfuncEngFunc_WriteCoord originF[1] );
        
engfuncEngFunc_WriteCoord originF[2] );
        
message_end( ) 
    }

Show laser:
PHP Code:
ShowLaser( const Float:v_Origin[3] , const Float:v_EndOrigin[3] )

    
message_beginMSG_BROADCAST SVC_TEMPENTITY )
    
write_byteTE_BEAMPOINTS )
    
engfuncEngFunc_WriteCoord v_Origin[0] )
    
engfuncEngFunc_WriteCoord v_Origin[1] )
    
engfuncEngFunc_WriteCoord v_Origin[2] )
    
engfuncEngFunc_WriteCoord v_EndOrigin[0] );
    
engfuncEngFunc_WriteCoord v_EndOrigin[1] );
    
engfuncEngFunc_WriteCoord v_EndOrigin[2] );
    
write_shortg_lmSpr );
    
write_byte);
    
write_byte);
    
write_byte);
    
write_byte);
    
write_byte);
    
write_byte);
    
write_byte);
    
write_byte255 );
    
write_byte100 );
    
write_byte255 );
    
message_end( );

And i was asking if it could be possible to make a better code

Last edited by Netsys; 08-18-2012 at 20:35.
Netsys is offline
 


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 05:41.


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