AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Save health of tripmine (https://forums.alliedmods.net/showthread.php?t=237757)

wicho 03-29-2014 03:52

Save health of tripmine
 
Hi everybody, well i use the tripmine/lasermine of ARUKARI on zombie mod but have a little problem when a player take the lasermine and plant again this set again the hp for default i mean give the health of the cvar, my question is how i can save the health when the player take the lasermine then when he plant again give the last health no the health by default, of course if the lasermine receive damage of zombie, how i can make this?..thx in advance

another example:

for example the tripmine have a health of 500 hp (assigned by cvar) then when a zombie attack and make it a damage of 200 the tripmine has now 300 hp, now the player want to take own tripmine and plant again but when the player plant now has a life of 300.

i make this but dont work:

PHP Code:

//global
new g_iHealthMine[33][1]

public 
ReturnMine(id)
{
    
id -= TASK_RELEASE;
    new 
tgt,body,Float:vo[3],Float:to[3];
    
get_user_aiming(id,tgt,body);
    if(!
pev_valid(tgt)) return;
    
pev(id,pev_origin,vo);
    
pev(tgt,pev_origin,to);
    if(
get_distance_f(vo,to) > 70.0) return;
    
    new 
EntityName[32];
    
pev(tgtpev_classnameEntityName31);
    if(!
equal(EntityNameENT_CLASS_NAME)) return;
    if(
pev(tgt,LASERMINE_OWNER) != id) return;
    
RemoveEntity(tgt);

    
g_havemine[id] ++;
    
g_deployed[id] --;
    
emit_sound(idCHAN_ITEMENT_SOUND5VOL_NORMATTN_NORM0PITCH_NORM)
    
//ShowAmmo(id)

    
g_iHealthMine[id][g_deployed[id]] = pev(tgtpev_health)//get health of tripmine

    
return;
}

public 
Spawnid )
{
    
id -= TASK_PLANT
    
// motor
    
new i_Ent engfunc(EngFunc_CreateNamedEntity,g_EntMine);
    if(!
i_Ent)
    {
        
ColorChat(idTEAM_COLOR"^x04 ZP |^x01 Can't Create Entity!")
        return 
PLUGIN_HANDLED_MAIN;
    }
    
set_pev(i_Ent,pev_classname,ENT_CLASS_NAME);

    
engfunc(EngFunc_SetModel,i_Ent,ENT_MODELS);

    
set_pev(i_Ent,pev_solid,SOLID_NOT);
    
set_pev(i_Ent,pev_movetype,MOVETYPE_FLY);

    
set_pev(i_Ent,pev_frame,0);
    
set_pev(i_Ent,pev_body,3);
    
set_pev(i_Ent,pev_sequence,TRIPMINE_WORLD);
    
set_pev(i_Ent,pev_framerate,0);
    
    
set_pev(i_Ent,pev_takedamage,DAMAGE_YES);
    
    
set_pev(i_Ent,pev_dmg,100.0);
    
    
set_user_health(i_Ent,get_pcvar_num(g_LHEALTH));
    
    new 
Float:vOrigin[3];
    new 
Float:vNewOrigin[3],Float:vNormal[3],Float:vTraceDirection[3],Float:vTraceEnd[3],Float:vEntAngles[3];
    
    
pevidpev_originvOrigin );
    
velocity_by_aimid128vTraceDirection );
    
xs_vec_addvTraceDirectionvOriginvTraceEnd );
    
    
engfuncEngFunc_TraceLinevOriginvTraceEndDONT_IGNORE_MONSTERSid);
    
    new 
Float:fFraction;
    
get_tr20TR_flFractionfFraction );
    

    
// -- We hit something!
    
if ( fFraction 1.0 )
    {
        
// -- Save results to be used later.
        
get_tr20TR_vecEndPosvTraceEnd );
        
get_tr20TR_vecPlaneNormalvNormal );
    }


    
xs_vec_mul_scalarvNormal8.0vNormal );
    
xs_vec_addvTraceEndvNormalvNewOrigin );

    
engfunc(EngFunc_SetSizei_EntFloat:{ -4.0, -4.0, -4.0 }, Float:{ 4.04.04.0 } );
    
engfunc(EngFunc_SetOrigini_EntvNewOrigin );

    
// -- Rotate tripmine.
    
vector_to_angle(vNormal,vEntAngles );
    
set_pev(i_Ent,pev_angles,vEntAngles );

    
// -- Calculate laser end origin.
    
new Float:vBeamEnd[3], Float:vTracedBeamEnd[3];
        
    
xs_vec_mul_scalar(vNormal8192.0vNormal );
    
xs_vec_addvNewOriginvNormalvBeamEnd );

    
engfuncEngFunc_TraceLinevNewOriginvBeamEndIGNORE_MONSTERS, -1);

    
get_tr20TR_vecPlaneNormalvNormal );
    
get_tr20TR_vecEndPosvTracedBeamEnd );

    
// -- Save results to be used later.
    
set_pev(i_EntLASERMINE_OWNERid );
    
set_pev(i_Ent,LASERMINE_BEAMENDPOINT,vTracedBeamEnd);
    
set_pev(i_Ent,LASERMINE_TEAM,2);
    new 
Float:fCurrTime get_gametime();

    
set_pev(i_Ent,LASERMINE_POWERUPfCurrTime 2.5 );
   
    
set_pev(i_Ent,LASERMINE_STEP,POWERUP_THINK);
    
set_pev(i_Ent,pev_nextthinkfCurrTime 0.2 );

    
PlaySound(i_Ent,POWERUP_SOUND );
    
g_deployed[id]++;
    
g_havemine[id]--;
    
DeleteTask(id);
    
//ShowAmmo(id);
    
set_pev(i_Entpev_health, (g_iHealthMine[id][g_deployed[id]]))//set the old health
    
    
return 1;



wicho 10-15-2014 21:23

Re: Save health of tripmine
 
Bump, someone know?

HamletEagle 10-16-2014 09:46

Re: Save health of tripmine
 
Not looked at the code, but it may be simple. When a player remove the lasermine, just save into a global var the mine health, then when the player wants to plant it again, set the healt stored into the var :D

Code:
public somefunc_removetripmine( ) {     some_global_var_here = get_somehow_the_hp     some_bool_here[ id ] = true } public somefunc_planttripmine( ) {     if( some_bool_here[ id ] )     {           set_somehow_tripminehp  = some_global_var_here         some_bool_here[ id ] = false     } }

wicho 10-16-2014 13:03

Re: Save health of tripmine
 
i make something like this but dont work..

PHP Code:

//global
new g_iHealthMine[33][1]

public 
ReturnMine(id)
{
    
g_iHealthMine[id][g_deployed[id]] = pev(tgtpev_health)//get health of tripmine
}

public 
Spawn(id)
{
    
set_pev(i_Entpev_health, (g_iHealthMine[id][g_deployed[id]]))//set the old health




All times are GMT -4. The time now is 06:00.

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