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(tgt, pev_classname, EntityName, 31); if(!equal(EntityName, ENT_CLASS_NAME)) return; if(pev(tgt,LASERMINE_OWNER) != id) return; RemoveEntity(tgt);
g_havemine[id] ++; g_deployed[id] --; emit_sound(id, CHAN_ITEM, ENT_SOUND5, VOL_NORM, ATTN_NORM, 0, PITCH_NORM) //ShowAmmo(id)
g_iHealthMine[id][g_deployed[id]] = pev(tgt, pev_health)//get health of tripmine
return; }
public Spawn( id ) { id -= TASK_PLANT // motor new i_Ent = engfunc(EngFunc_CreateNamedEntity,g_EntMine); if(!i_Ent) { ColorChat(id, TEAM_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]; pev( id, pev_origin, vOrigin ); velocity_by_aim( id, 128, vTraceDirection ); xs_vec_add( vTraceDirection, vOrigin, vTraceEnd ); engfunc( EngFunc_TraceLine, vOrigin, vTraceEnd, DONT_IGNORE_MONSTERS, id, 0 ); new Float:fFraction; get_tr2( 0, TR_flFraction, fFraction );
// -- We hit something! if ( fFraction < 1.0 ) { // -- Save results to be used later. get_tr2( 0, TR_vecEndPos, vTraceEnd ); get_tr2( 0, TR_vecPlaneNormal, vNormal ); }
xs_vec_mul_scalar( vNormal, 8.0, vNormal ); xs_vec_add( vTraceEnd, vNormal, vNewOrigin );
engfunc(EngFunc_SetSize, i_Ent, Float:{ -4.0, -4.0, -4.0 }, Float:{ 4.0, 4.0, 4.0 } ); engfunc(EngFunc_SetOrigin, i_Ent, vNewOrigin );
// -- 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(vNormal, 8192.0, vNormal ); xs_vec_add( vNewOrigin, vNormal, vBeamEnd );
engfunc( EngFunc_TraceLine, vNewOrigin, vBeamEnd, IGNORE_MONSTERS, -1, 0 );
get_tr2( 0, TR_vecPlaneNormal, vNormal ); get_tr2( 0, TR_vecEndPos, vTracedBeamEnd );
// -- Save results to be used later. set_pev(i_Ent, LASERMINE_OWNER, id ); set_pev(i_Ent,LASERMINE_BEAMENDPOINT,vTracedBeamEnd); set_pev(i_Ent,LASERMINE_TEAM,2); new Float:fCurrTime = get_gametime();
set_pev(i_Ent,LASERMINE_POWERUP, fCurrTime + 2.5 ); set_pev(i_Ent,LASERMINE_STEP,POWERUP_THINK); set_pev(i_Ent,pev_nextthink, fCurrTime + 0.2 );
PlaySound(i_Ent,POWERUP_SOUND ); g_deployed[id]++; g_havemine[id]--; DeleteTask(id); //ShowAmmo(id); set_pev(i_Ent, pev_health, (g_iHealthMine[id][g_deployed[id]]))//set the old health return 1; }
|