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

Save health of entity


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ghost95v
Senior Member
Join Date: Apr 2014
Location: somewhere in universe
Old 03-01-2015 , 07:25   Save health of entity
Reply With Quote #1

Hello there, im wondering if i can save the HP of this TripMine entity when i Re- Plant it.
i mean when i Plant the Mine, i do some damage on it, and i Take it,
- and when i plant it again to give the last Health of it. Thnx very much.

PHP Code:
#pragma semicolon 1

#include < amxmodx >
#include < fakemeta >
#include < engine >

native zp_get_user_zombieiPlayer );
native zp_get_user_ammo_packsiPlayer );
native zp_set_user_ammo_packsiPlayeriPacks );
native zp_is_lnj_round( );

#define MAX_ENTITIES        600
#define MAX_PLAYERS        32
#define MINE_ON            1
#define MINE_OFF            0
#define TASK_CREATE        84765
#define TASK_REMOVE        86766
#define MINE_COST            6
#define MINE_CLASSNAME        "zp_trip_mine"
#define MINE_MODEL_EXPLODE    "sprites/zerogxplode.spr"
#define MINE_MODEL_VIEW        "models/zombie_plague/lasermine.mdl"
#define MINE_SOUND_ACTIVATE    "weapons/mine_activate.wav"
#define MINE_SOUND_CHARGE        "weapons/mine_charge.wav"
#define MINE_SOUND_DEPLOY        "weapons/mine_deploy.wav"
#define MINE_HEALTH        650.0
#define entity_get_owner(%0)        entity_get_int( %0, EV_INT_iuser2 )
#define entity_get_status(%0)        entity_get_int( %0, EV_INT_iuser1 )
#define entity_get_classname(%0,%1)    entity_get_string( %0, EV_SZ_classname, %1, charsmax( %1 ) )

new g_iTripMines33 ];
new 
g_iPlantedMines33 ];
new 
g_iPlanting33 ];
new 
g_iRemoving33 ];
new 
g_hExplode;

public 
plugin_init( )
{
    
register_plugin"[ZP] Trip Mines""1.0""Hattrick" );
    
    
register_clcmd"say /lm""Command_Buy" );
    
register_clcmd"say lm""Command_Buy" );
    
    
register_clcmd"CreateLaser""Command_Plant" );
    
register_clcmd"TakeLaser""Command_Take" );
    
    
register_logevent"Event_RoundStart"2"1=Round_Start" );
    
    
register_thinkMINE_CLASSNAME"Forward_Think" );
}

public 
plugin_precache( )
{
    
engfuncEngFunc_PrecacheModelMINE_MODEL_VIEW );
    
    
engfuncEngFunc_PrecacheSoundMINE_SOUND_ACTIVATE );
    
engfuncEngFunc_PrecacheSoundMINE_SOUND_CHARGE );
    
engfuncEngFunc_PrecacheSoundMINE_SOUND_DEPLOY );
    
    
g_hExplode engfuncEngFunc_PrecacheModelMINE_MODEL_EXPLODE );
}

public 
client_disconnectiPlayer )
{
    
g_iTripMinesiPlayer ] = 0;
    
g_iPlantingiPlayer ] = false;
    
g_iRemovingiPlayer ] = false;
    
    if( 
g_iPlantedMinesiPlayer ] )
    {
        
Func_RemoveMinesByOwneriPlayer );
        
        
g_iPlantedMinesiPlayer ] = 0;
    }
    
    
remove_taskiPlayer TASK_REMOVE );
    
remove_taskiPlayer TASK_CREATE );
}

public 
Command_BuyiPlayer )
{
    if( !
is_user_aliveiPlayer ) )
    {
        
client_printiPlayerprint_chat"[ZP] You should be alive" );
        
        return 
PLUGIN_CONTINUE;
    }
    
    if( 
zp_get_user_zombieiPlayer ) )
    {
        
client_printiPlayerprint_chat"[ZP] You should be human" );
        
        return 
PLUGIN_CONTINUE;
    }
    
    if( 
zp_get_user_ammo_packsiPlayer ) < MINE_COST )
    {
        
client_printiPlayerprint_chat"[ZP] You need %i ammo packs"MINE_COST );
        
        return 
PLUGIN_CONTINUE;
    }
    
    if( 
zp_is_lnj_round( ) )
    {
        
client_printiPlayerprint_chat"[ZP] You can't buy a tripmine into an armageddon round" );
        
        return 
PLUGIN_CONTINUE;
    }
    
    
zp_set_user_ammo_packsiPlayerzp_get_user_ammo_packsiPlayer ) - MINE_COST );
    
    
g_iTripMinesiPlayer ]++;
    
    
client_printiPlayerprint_chat"[ZP] You bought a trip mine. Press 'p' to plant it or 'v' to take it" );
    
    
client_cmdiPlayer"bind p CreateLaser" );
    
client_cmdiPlayer"bind v TakeLaser" );
    
    return 
PLUGIN_CONTINUE;
}

public 
Command_PlantiPlayer )
{
    if( !
is_user_aliveiPlayer ) )
    {
        
client_printiPlayerprint_chat"[ZP] You should be alive" );
        
        return 
PLUGIN_CONTINUE;
    }
    
    if( 
zp_get_user_zombieiPlayer ) )
    {
        
client_printiPlayerprint_chat"[ZP] You should be human" );
        
        return 
PLUGIN_CONTINUE;
    }
    
    if( !
g_iTripMinesiPlayer ] )
    {
        
client_printiPlayerprint_chat"[ZP] You don't have a trip mine to plant" );
        
        return 
PLUGIN_CONTINUE;
    }
    
    if( 
g_iPlantedMinesiPlayer ] > )
    {
        
client_printiPlayerprint_chat"[ZP] You can plant only 2 mines" );
        
        return 
PLUGIN_CONTINUE;
    }
    
    if( 
zp_is_lnj_round( ) )
    {
        
client_printiPlayerprint_chat"[ZP] You can't buy a tripmine into an armageddon round" );
        
        return 
PLUGIN_CONTINUE;
    }
    
    if( 
g_iPlantingiPlayer ] || g_iRemovingiPlayer ] )
        return 
PLUGIN_CONTINUE;
    
    if( 
CanPlantiPlayer ) ) {
        
g_iPlantingiPlayer ] = true;
        
        
message_beginMSG_ONE_UNRELIABLE108_iPlayer );
        
write_byte);
        
write_byte);
        
message_end( );
        
        
set_task1.2"Func_Plant"iPlayer TASK_CREATE );
    }
    
    return 
PLUGIN_CONTINUE;
}

public 
Command_TakeiPlayer )
{
    if( !
is_user_aliveiPlayer ) )
    {
        
client_printiPlayerprint_chat"[ZP] You should be alive" );
        
        return 
PLUGIN_CONTINUE;
    }
    
    if( 
zp_get_user_zombieiPlayer ) )
    {
        
client_printiPlayerprint_chat"[ZP] You should be human" );
        
        return 
PLUGIN_CONTINUE;
    }
    
    if( !
g_iPlantedMinesiPlayer ] )
    {
        
client_printiPlayerprint_chat"[ZP] You don't have a planted mine" );
        
        return 
PLUGIN_CONTINUE;
    }
    
    if( 
g_iPlantingiPlayer ] || g_iRemovingiPlayer ] )
        return 
PLUGIN_CONTINUE;
    
    if( 
CanTakeiPlayer ) ) {
        
g_iRemovingiPlayer ] = true;
        
        
message_beginMSG_ONE_UNRELIABLE108_iPlayer );
        
write_byte);
        
write_byte);
        
message_end( );
        
        
set_task1.2"Func_Take"iPlayer TASK_REMOVE );
    }
    
    return 
PLUGIN_CONTINUE;
}

public 
Event_RoundStart( ) {
    static 
iEntityszClassName32 ], iPlayer;
    for( 
iEntity 0iEntity MAX_ENTITIES 1iEntity++ ) {
        if( !
is_valid_entiEntity ) )
            continue;
        
        
szClassName] = '^0';
        
entity_get_classnameiEntityszClassName );
        
        if( 
equalszClassNameMINE_CLASSNAME ) )
            
remove_entityiEntity );
    }
    
    for( 
iPlayer 1iPlayer 33iPlayer++ ) {
        
g_iTripMinesiPlayer ] = 0;
        
g_iPlantedMinesiPlayer ] = 0;
    }
}

public 
Func_TakeiPlayer ) {
    
iPlayer -= TASK_REMOVE;
    
    
g_iRemovingiPlayer ] = false;
    
    static 
iEntityszClassName32 ], FloatflOwnerOrigin], FloatflEntityOrigin];
    for( 
iEntity 0iEntity MAX_ENTITIES 1iEntity++ ) {
        if( !
is_valid_entiEntity ) )
            continue;
        
        
szClassName] = '^0';
        
entity_get_classnameiEntityszClassName );
        
        if( 
equalszClassNameMINE_CLASSNAME ) ) {
            if( 
entity_get_owneriEntity ) == iPlayer ) {
                
entity_get_vectoriPlayerEV_VEC_originflOwnerOrigin );
                
entity_get_vectoriEntityEV_VEC_originflEntityOrigin );
                
                if( 
get_distance_fflOwnerOriginflEntityOrigin ) < 55.0 ) {
                    
g_iPlantedMinesiPlayer ]--;
                    
g_iTripMinesiPlayer ]++;
                    
                    
remove_entityiEntity );
                    
                    break;
                }
            }
        }
    }
}

public 
boolCanTakeiPlayer ) {
    static 
iEntityszClassName32 ], FloatflOwnerOrigin], FloatflEntityOrigin];
    for( 
iEntity 0iEntity MAX_ENTITIES 1iEntity++ ) {
        if( !
is_valid_entiEntity ) )
            continue;
        
        
szClassName] = '^0';
        
entity_get_classnameiEntityszClassName );
        
        if( 
equalszClassNameMINE_CLASSNAME ) ) {
            if( 
entity_get_owneriEntity ) == iPlayer ) {
                
entity_get_vectoriPlayerEV_VEC_originflOwnerOrigin );
                
entity_get_vectoriEntityEV_VEC_originflEntityOrigin );
                
                if( 
get_distance_fflOwnerOriginflEntityOrigin ) < 55.0 )
                    return 
true;
            }
        }
    }
    
    return 
false;
}

public 
boolCanPlantiPlayer ) {
    static 
FloatflOrigin];
    
entity_get_vectoriPlayerEV_VEC_originflOrigin );
    
    static 
FloatflTraceDirection], FloatflTraceEnd], FloatflTraceResult], FloatflNormal];
    
velocity_by_aimiPlayer64flTraceDirection );
    
flTraceEnd] = flTraceDirection] + flOrigin];
    
flTraceEnd] = flTraceDirection] + flOrigin];
    
flTraceEnd] = flTraceDirection] + flOrigin];
    
    static 
FloatflFractioniTr;
    
iTr 0;
    
engfuncEngFunc_TraceLineflOriginflTraceEnd0iPlayeriTr );
    
get_tr2iTrTR_vecEndPosflTraceResult );
    
get_tr2iTrTR_vecPlaneNormalflNormal );
    
get_tr2iTrTR_flFractionflFraction );
    
    if( 
flFraction >= 1.0 ) {
        
client_printiPlayerprint_chat"[ZP] You must plant the tripmine on a wall" );
        
        return 
false;
    }
    
    return 
true;
}

public 
Func_PlantiPlayer ) {
    
iPlayer -= TASK_CREATE;
    
    
g_iPlantingiPlayer ] = false;
    
    static 
FloatflOrigin];
    
entity_get_vectoriPlayerEV_VEC_originflOrigin );
    
    static 
FloatflTraceDirection], FloatflTraceEnd], FloatflTraceResult], FloatflNormal];
    
velocity_by_aimiPlayer128flTraceDirection );
    
flTraceEnd] = flTraceDirection] + flOrigin];
    
flTraceEnd] = flTraceDirection] + flOrigin];
    
flTraceEnd] = flTraceDirection] + flOrigin];
    
    static 
FloatflFractioniTr;
    
iTr 0;
    
engfuncEngFunc_TraceLineflOriginflTraceEnd0iPlayeriTr );
    
get_tr2iTrTR_vecEndPosflTraceResult );
    
get_tr2iTrTR_vecPlaneNormalflNormal );
    
get_tr2iTrTR_flFractionflFraction );
    
    static 
iEntity;
    
iEntity create_entity"info_target" );
    
    if( !
iEntity )
        return;
    
    
entity_set_stringiEntityEV_SZ_classnameMINE_CLASSNAME );
    
entity_set_modeliEntityMINE_MODEL_VIEW );
    
entity_set_sizeiEntityFloat: { -4.0, -4.0, -4.0 }, Float: { 4.04.04.0 } );
    
    
entity_set_intiEntityEV_INT_iuser2iPlayer );
    
    
g_iPlantedMinesiPlayer ]++;
    
    
entity_set_floatiEntityEV_FL_frame0.0 );
    
entity_set_floatiEntityEV_FL_framerate0.0 );
    
entity_set_intiEntityEV_INT_movetypeMOVETYPE_FLY );
    
entity_set_intiEntityEV_INT_solidSOLID_NOT );
    
entity_set_intiEntityEV_INT_body);
    
entity_set_intiEntityEV_INT_sequence);
    
entity_set_floatiEntityEV_FL_takedamageDAMAGE_NO );
    
entity_set_intiEntityEV_INT_iuser1MINE_OFF );
    
    static 
FloatflNewOrigin], FloatflEntAngles];
    
flNewOrigin] = flTraceResult] + ( flNormal] * 8.0 );
    
flNewOrigin] = flTraceResult] + ( flNormal] * 8.0 );
    
flNewOrigin] = flTraceResult] + ( flNormal] * 8.0 );
    
    
entity_set_originiEntityflNewOrigin );
    
    
vector_to_angleflNormalflEntAngles );
    
entity_set_vectoriEntityEV_VEC_anglesflEntAngles );
    
flEntAngles] *= -1.0;
    
flEntAngles] *= -1.0;
    
flEntAngles] *= -1.0;
    
entity_set_vectoriEntityEV_VEC_v_angleflEntAngles );
    
    
g_iTripMinesiPlayer ]--;
    
    
emit_soundiEntityCHAN_WEAPONMINE_SOUND_DEPLOYVOL_NORMATTN_NORM0PITCH_NORM );
    
emit_soundiEntityCHAN_VOICEMINE_SOUND_CHARGEVOL_NORMATTN_NORM0PITCH_NORM );
    
    
entity_set_floatiEntityEV_FL_nextthinkget_gametime( ) + 0.6 );
}

public 
Func_RemoveMinesByOwneriPlayer ) {
    static 
iEntityszClassName32 ];
    for( 
iEntity 0iEntity MAX_ENTITIES 1iEntity++ ) {
        if( !
is_valid_entiEntity ) )
            continue;
        
        
szClassName] = '^0';
        
entity_get_classnameiEntityszClassName );
        
        if( 
equalszClassNameMINE_CLASSNAME ) )
            if( 
entity_get_intiEntityEV_INT_iuser2 ) == iPlayer )
                
remove_entityiEntity );
    }
}

Func_ExplodeiEntity ) {
    
g_iPlantedMinesentity_get_owneriEntity ) ]--;
    
    static 
FloatflOrigin], FloatflZombieOrigin], FloatflHealthFloatflVelocity];
    
entity_get_vectoriEntityEV_VEC_originflOrigin );
    
    
message_beginMSG_BROADCASTSVC_TEMPENTITY );
    
write_byteTE_EXPLOSION );
    
engfuncEngFunc_WriteCoordflOrigin] );
    
engfuncEngFunc_WriteCoordflOrigin] );
    
engfuncEngFunc_WriteCoordflOrigin] );
    
write_shortg_hExplode );
    
write_byte55 );
    
write_byte15 );
    
write_byte);
    
message_end( );
    
    
message_beginMSG_BROADCASTSVC_TEMPENTITY );
    
write_byteTE_EXPLOSION );
    
engfuncEngFunc_WriteCoordflOrigin] );
    
engfuncEngFunc_WriteCoordflOrigin] );
    
engfuncEngFunc_WriteCoordflOrigin] );
    
write_shortg_hExplode );
    
write_byte65 );
    
write_byte15 );
    
write_byte);
    
message_end( );
    
    
message_beginMSG_BROADCASTSVC_TEMPENTITY );
    
write_byteTE_EXPLOSION );
    
engfuncEngFunc_WriteCoordflOrigin] );
    
engfuncEngFunc_WriteCoordflOrigin] );
    
engfuncEngFunc_WriteCoordflOrigin] );
    
write_shortg_hExplode );
    
write_byte85 );
    
write_byte15 );
    
write_byte);
    
message_end( );
    
    static 
iZombie;
    for( 
iZombie 1iZombie MAX_PLAYERS 1iZombie++ ) {
        if( 
is_user_connectediZombie ) ) {
            if( 
is_user_aliveiZombie ) ) {
                
entity_get_vectoriZombieEV_VEC_originflZombieOrigin );
                
                if( 
get_distance_fflOriginflZombieOrigin ) < 360.0 ) {
                    
flHealth entity_get_floatiZombieEV_FL_health );
                    
entity_get_vectoriZombieEV_VEC_velocityflVelocity );
                    
                    
flVelocity] += 456.0;
                    
flVelocity] += 320.0;
                    
flVelocity] += 299.0;
                    
                    
entity_set_vectoriZombieEV_VEC_velocityflVelocity );
                    
                    if( 
zp_get_user_zombieiZombie ) )
                        
fm_set_user_healthiZombiefloatmaxflHealth random_float1600.02800.0 ), 0.0 ) );
                }
            }
        }
    }
    
    
remove_entityiEntity );
}

public 
Forward_ThinkiEntity ) {
    static 
FloatflGameTimeiStatus;
    
flGameTime get_gametime( );
    
iStatus entity_get_statusiEntity );
    
    switch( 
iStatus ) {
        case 
MINE_OFF: {
            
entity_set_intiEntityEV_INT_iuser1MINE_ON );
            
entity_set_floatiEntityEV_FL_takedamageDAMAGE_YES );
            
entity_set_intiEntityEV_INT_solidSOLID_BBOX );
            
entity_set_floatiEntityEV_FL_healthMINE_HEALTH 1000.0 );
            
            
emit_soundiEntityCHAN_VOICEMINE_SOUND_ACTIVATEVOL_NORMATTN_NORM0PITCH_NORM );
        }
        
        case 
MINE_ON: {
            static 
FloatflHealth;
            
flHealth entity_get_floatiEntityEV_FL_health );
            
            if( 
flHealth <= 1000.0 ) {
                
Func_ExplodeiEntity );
                
                return 
FMRES_IGNORED;
            }
        }
    }
    
    if( 
is_valid_entiEntity ) )
        
entity_set_floatiEntityEV_FL_nextthinkflGameTime 0.1 );
    
    return 
FMRES_IGNORED;
}

public 
fm_set_user_healthiPlayerFloatflHealth )
    
flHealth set_peviPlayerpev_healthflHealth ) : dllfuncDLLFunc_ClientKilliPlayer ); 
__________________

Last edited by ghost95v; 03-01-2015 at 07:26.
ghost95v is offline
Send a message via Skype™ to ghost95v
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 03-01-2015 , 08:28   Re: Save health of entity
Reply With Quote #2

Yes, before removing it:
PHP Code:
new FloatTripMineHealth
pev
(entpev_healthTripMineHealth
When you plant it again
PHP Code:
set_pev(entpev_healthTripMineHealth
You may need to make TripMineHealth variable an array like TripMineHealth[33], in case more than one player use tripmine at a time.
__________________
HamletEagle is offline
ghost95v
Senior Member
Join Date: Apr 2014
Location: somewhere in universe
Old 03-01-2015 , 08:46   Re: Save health of entity
Reply With Quote #3

I did these below but not working...

global var's added
PHP Code:
new FloatiMineHP
new iRemoved[33
and in the function take this...
PHP Code:
public Func_TakeiPlayer ) {
    
iPlayer -= TASK_REMOVE;
    
    
g_iRemovingiPlayer ] = false;
    
    static 
iEntityszClassName32 ], FloatflOwnerOrigin], FloatflEntityOrigin];
    for( 
iEntity 0iEntity MAX_ENTITIES 1iEntity++ ) {
        if( !
is_valid_entiEntity ) )
            continue;
        
        
szClassName] = '^0';
        
entity_get_classnameiEntityszClassName );
        
        if(
iRemovediPlayer ])
        {
            
pev(iEntitypev_healthiMineHP)
        }
        
        if( 
equalszClassNameMINE_CLASSNAME ) ) {
            if( 
entity_get_owneriEntity ) == iPlayer ) {
                
entity_get_vectoriPlayerEV_VEC_originflOwnerOrigin );
                
entity_get_vectoriEntityEV_VEC_originflEntityOrigin );
                
                if( 
get_distance_fflOwnerOriginflEntityOrigin ) < 55.0 ) {
                    
g_iPlantedMinesiPlayer ]--;
                    
g_iTripMinesiPlayer ]++;
                    
iRemovediPlayer ] = true
                    
                    remove_entity
iEntity );
                    
                    break;
                }
            }
        }
    }

and in Func plant this ....
PHP Code:
public Func_PlantiPlayer ) {
    
iPlayer -= TASK_CREATE;
    
    
g_iPlantingiPlayer ] = false;
    
    static 
FloatflOrigin];
    
entity_get_vectoriPlayerEV_VEC_originflOrigin );
    
    static 
FloatflTraceDirection], FloatflTraceEnd], FloatflTraceResult], FloatflNormal];
    
velocity_by_aimiPlayer128flTraceDirection );
    
flTraceEnd] = flTraceDirection] + flOrigin];
    
flTraceEnd] = flTraceDirection] + flOrigin];
    
flTraceEnd] = flTraceDirection] + flOrigin];
    
    static 
FloatflFractioniTr;
    
iTr 0;
    
engfuncEngFunc_TraceLineflOriginflTraceEnd0iPlayeriTr );
    
get_tr2iTrTR_vecEndPosflTraceResult );
    
get_tr2iTrTR_vecPlaneNormalflNormal );
    
get_tr2iTrTR_flFractionflFraction );
    
    static 
iEntity;
    
iEntity create_entity"info_target" );
    
    if( !
iEntity )
        return;
    
    
entity_set_stringiEntityEV_SZ_classnameMINE_CLASSNAME );
    
entity_set_modeliEntityMINE_MODEL_VIEW );
    
entity_set_sizeiEntityFloat: { -4.0, -4.0, -4.0 }, Float: { 4.04.04.0 } );
    
    
entity_set_intiEntityEV_INT_iuser2iPlayer );
    
    if (
iRemovediPlayer ])
    {
        
set_pev(iEntitypev_healthiMineHP)  
    }
    
    
g_iPlantedMinesiPlayer ]++;
    
    
entity_set_floatiEntityEV_FL_frame0.0 );
    
entity_set_floatiEntityEV_FL_framerate0.0 );
    
entity_set_intiEntityEV_INT_movetypeMOVETYPE_FLY );
    
entity_set_intiEntityEV_INT_solidSOLID_NOT );
    
entity_set_intiEntityEV_INT_body);
    
entity_set_intiEntityEV_INT_sequence);
    
entity_set_floatiEntityEV_FL_takedamageDAMAGE_NO );
    
entity_set_intiEntityEV_INT_iuser1MINE_OFF );
    
    static 
FloatflNewOrigin], FloatflEntAngles];
    
flNewOrigin] = flTraceResult] + ( flNormal] * 8.0 );
    
flNewOrigin] = flTraceResult] + ( flNormal] * 8.0 );
    
flNewOrigin] = flTraceResult] + ( flNormal] * 8.0 );
    
    
entity_set_originiEntityflNewOrigin );
    
    
vector_to_angleflNormalflEntAngles );
    
entity_set_vectoriEntityEV_VEC_anglesflEntAngles );
    
flEntAngles] *= -1.0;
    
flEntAngles] *= -1.0;
    
flEntAngles] *= -1.0;
    
entity_set_vectoriEntityEV_VEC_v_angleflEntAngles );
    
    
g_iTripMinesiPlayer ]--;
    
    
emit_soundiEntityCHAN_WEAPONMINE_SOUND_DEPLOYVOL_NORMATTN_NORM0PITCH_NORM );
    
emit_soundiEntityCHAN_VOICEMINE_SOUND_CHARGEVOL_NORMATTN_NORM0PITCH_NORM );
    
    
entity_set_floatiEntityEV_FL_nextthinkget_gametime( ) + 0.6 );

__________________

Last edited by ghost95v; 03-01-2015 at 09:05.
ghost95v is offline
Send a message via Skype™ to ghost95v
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 03-01-2015 , 11:07   Re: Save health of entity
Reply With Quote #4

i have the same question, someone know?
wicho is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 03-01-2015 , 11:21   Re: Save health of entity
Reply With Quote #5

Omg, use your logic. iRemoved[ iPlayer ] is set to true only inside the distance check, but you check it above it, so it will be always false. Also I told you to use Float:iMineHealth[33].
In the second block of code, when you set the health, turn iRemoved[ iPlayer ] to false.
__________________
HamletEagle is offline
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 03-02-2015 , 00:25   Re: Save health of entity
Reply With Quote #6

u mean this?

PHP Code:
new FloatiMineHP[33]
new 
iRemoved[33


public 
Func_TakeiPlayer ) { 
    
iPlayer -= TASK_REMOVE
     
    
g_iRemovingiPlayer ] = false
     
    static 
iEntityszClassName32 ], FloatflOwnerOrigin], FloatflEntityOrigin]; 
    for( 
iEntity 0iEntity MAX_ENTITIES 1iEntity++ ) { 
        if( !
is_valid_entiEntity ) ) 
            continue; 
         
        
szClassName] = '^0'
        
entity_get_classnameiEntityszClassName ); 
         
        if(
iRemovediPlayer ]) 
        { 
            
pev(iEntitypev_healthiMineHP[id]) 
            
iRemovediPlayer ] = true
        

         
        if( 
equalszClassNameMINE_CLASSNAME ) ) { 
            if( 
entity_get_owneriEntity ) == iPlayer ) { 
                
entity_get_vectoriPlayerEV_VEC_originflOwnerOrigin ); 
                
entity_get_vectoriEntityEV_VEC_originflEntityOrigin ); 
                 
                if( 
get_distance_fflOwnerOriginflEntityOrigin ) < 55.0 ) { 
                    
g_iPlantedMinesiPlayer ]--; 
                    
g_iTripMinesiPlayer ]++; 
                                        
                    
remove_entityiEntity ); 
                     
                    break; 
                } 
            } 
        } 
    } 


public 
Func_PlantiPlayer ) { 
    
iPlayer -= TASK_CREATE
     
    
g_iPlantingiPlayer ] = false
     
    static 
FloatflOrigin]; 
    
entity_get_vectoriPlayerEV_VEC_originflOrigin ); 
     
    static 
FloatflTraceDirection], FloatflTraceEnd], FloatflTraceResult], FloatflNormal]; 
    
velocity_by_aimiPlayer128flTraceDirection ); 
    
flTraceEnd] = flTraceDirection] + flOrigin]; 
    
flTraceEnd] = flTraceDirection] + flOrigin]; 
    
flTraceEnd] = flTraceDirection] + flOrigin]; 
     
    static 
FloatflFractioniTr
    
iTr 0
    
engfuncEngFunc_TraceLineflOriginflTraceEnd0iPlayeriTr ); 
    
get_tr2iTrTR_vecEndPosflTraceResult ); 
    
get_tr2iTrTR_vecPlaneNormalflNormal ); 
    
get_tr2iTrTR_flFractionflFraction ); 
     
    static 
iEntity
    
iEntity create_entity"info_target" ); 
     
    if( !
iEntity 
        return; 
     
    
entity_set_stringiEntityEV_SZ_classnameMINE_CLASSNAME ); 
    
entity_set_modeliEntityMINE_MODEL_VIEW ); 
    
entity_set_sizeiEntityFloat: { -4.0, -4.0, -4.0 }, Float: { 4.04.04.0 } ); 
     
    
entity_set_intiEntityEV_INT_iuser2iPlayer ); 
     
    if (
iRemovediPlayer ]) 
    { 
        
set_pev(iEntitypev_healthiMineHP[id])
        
iRemovediPlayer ] = false 
    

     
    
g_iPlantedMinesiPlayer ]++; 
     
    
entity_set_floatiEntityEV_FL_frame0.0 ); 
    
entity_set_floatiEntityEV_FL_framerate0.0 ); 
    
entity_set_intiEntityEV_INT_movetypeMOVETYPE_FLY ); 
    
entity_set_intiEntityEV_INT_solidSOLID_NOT ); 
    
entity_set_intiEntityEV_INT_body); 
    
entity_set_intiEntityEV_INT_sequence); 
    
entity_set_floatiEntityEV_FL_takedamageDAMAGE_NO ); 
    
entity_set_intiEntityEV_INT_iuser1MINE_OFF ); 
     
    static 
FloatflNewOrigin], FloatflEntAngles]; 
    
flNewOrigin] = flTraceResult] + ( flNormal] * 8.0 ); 
    
flNewOrigin] = flTraceResult] + ( flNormal] * 8.0 ); 
    
flNewOrigin] = flTraceResult] + ( flNormal] * 8.0 ); 
     
    
entity_set_originiEntityflNewOrigin ); 
     
    
vector_to_angleflNormalflEntAngles ); 
    
entity_set_vectoriEntityEV_VEC_anglesflEntAngles ); 
    
flEntAngles] *= -1.0
    
flEntAngles] *= -1.0
    
flEntAngles] *= -1.0
    
entity_set_vectoriEntityEV_VEC_v_angleflEntAngles ); 
     
    
g_iTripMinesiPlayer ]--; 
     
    
emit_soundiEntityCHAN_WEAPONMINE_SOUND_DEPLOYVOL_NORMATTN_NORM0PITCH_NORM ); 
    
emit_soundiEntityCHAN_VOICEMINE_SOUND_CHARGEVOL_NORMATTN_NORM0PITCH_NORM ); 
     
    
entity_set_floatiEntityEV_FL_nextthinkget_gametime( ) + 0.6 ); 

or this:

PHP Code:
new FloatiMineHP[33]
new 
iRemoved[33]

public 
Func_TakeiPlayer 
{    
     
iMineHP[iPlayer] = pev(iEntitypev_health)
     
iRemoved[iPlayer] = true   


public 
Func_PlantiPlayer 
{
   if(
iRemoved[iPlayer])
   {
     
set_pev(iEntitypev_health, (iMineHP[iPlayer])) = iMineHP[iPlayer]
     
iRemoved[iPlayer] = false
   
}


Last edited by wicho; 03-02-2015 at 00:52.
wicho is offline
ghost95v
Senior Member
Join Date: Apr 2014
Location: somewhere in universe
Old 03-02-2015 , 02:23   Re: Save health of entity
Reply With Quote #7

No, there its needed some other things to do.
cuz There we can Re-plant 2 Mines that they were damaged and with not the full HP.\
so for this we need a second array like Float: iTripMineHealth[33] [2], for 2 mines.
And to set the Last HP of mines, its needed to do only in Forward_Think( iEntity ).
__________________

Last edited by ghost95v; 03-02-2015 at 02:27.
ghost95v is offline
Send a message via Skype™ to ghost95v
wicho
Veteran Member
Join Date: Feb 2012
Location: GuateAmala
Old 03-02-2015 , 02:37   Re: Save health of entity
Reply With Quote #8

how? if you did can you post the code, I dont understand at all..
wicho is offline
RateX
Veteran Member
Join Date: Jun 2012
Location: 0o. SEA .o0
Old 03-02-2015 , 02:42   Re: Save health of entity
Reply With Quote #9

You should probably work out a way to properly store reclaimed mines, as it would become easier to store what ever values you want.

EDIT:You can start with define the max amount of mines you can reclaim. After that you can create an array Float: iTripMineHealth[33] [MAX_MINES] like ghost95v does.
__________________
Currently offline for study.

Last edited by RateX; 03-02-2015 at 02:48.
RateX is offline
ghost95v
Senior Member
Join Date: Apr 2014
Location: somewhere in universe
Old 03-02-2015 , 02:44   Re: Save health of entity
Reply With Quote #10

i didnt done anything big...
i just got the last Hp of a single mine, but when i Re-plant, it gives the saved HP to the second mine.
not to the mine that i removed.

PHP Code:
case MINE_ON: {
            static 
FloatflHealth
            
if (!iRemovedentity_get_owneriEntity ) ])
            
flHealth entity_get_floatiEntityEV_FL_health );
            else
            
flHealth == set_pev(iEntitypev_healthiMineHP[entity_get_owneriEntity )]) 
iMineHP has stored the last HP in Func_Take like this below....

PHP Code:
pev(iEntitypev_healthiMineHPiPlayer ]) 
__________________

Last edited by ghost95v; 03-02-2015 at 02:55.
ghost95v is offline
Send a message via Skype™ to ghost95v
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 17:38.


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