if(pev_valid(ent) && pev_valid(pev(ent, pev_ent_health)))
remove_entity(pev(ent, pev_ent_health))
A najlepiej sprawdzanie enta wywalić gdzieś na początek funkcji.
Witamy w Nieoficjalnym polskim support'cie AMX Mod X, jak w większości społeczności internetowych musisz się zarejestrować aby móc odpowiadać lub zakładać nowe tematy, ale nie bój się to jest prosty proces w którym wymagamy minimalnych informacji.
|
Najlepsza odpowiedź GT Team , 08.05.2013 19:15
A JEDNAK Działa! Rozłożyłem TakeDamage, bo sądziłem, że wykonuje się za dużo w 1 i oto co zrobiłem:
public TakeDamage(ent, idinflictor, attacker, Float:damage, damagebits) { static classname[32]; entity_get_string(ent, EV_SZ_classname, classname, 31); if(equal(classname, "monster")) { new hp = floatround(entity_get_float(ent, EV_FL_health)) /* Pokazuje zadane obrazenia */ new id = 0 if(is_turret(attacker)) { id = SentryOwner(attacker) if(gPlayerDamage[id]) damage+=float(gPlayerNewDamage[id]) } if(is_turret(attacker)) { new sentryid = SentryId(ent) if(damagebits & DMG_SLASH && sentryid == 0) { set_hudmessage(100, 255, 0, 0.81, 0.27, 0, 6.0, 1.0) ShowSyncHudMsg(id, gSync9, "W 1: %d", floatround(damage)) } if(damagebits & DMG_BLAST && sentryid == 1) { set_hudmessage(100, 255, 0, 0.81, 0.32, 0, 6.0, 1.0) ShowSyncHudMsg(id, gSync10, "W 2: %d", floatround(damage)) } if(damagebits & DMG_BURN && sentryid == 2) { set_hudmessage(100, 255, 0, 0.81, 0.37, 0, 6.0, 1.0) ShowSyncHudMsg(id, gSync11, "W 3: %d", floatround(damage)) } if(damagebits & DMG_DROWN && sentryid == 3) { set_hudmessage(100, 255, 0, 0.81, 0.42, 0, 6.0, 1.0) ShowSyncHudMsg(id, gSync12, "W 4: %d", floatround(damage)) } if(MAX_SENTRY > 4 && sentryid >= 4) { set_hudmessage(100, 0, 255, 0.81, 0.47, 0, 6.0, 1.0) ShowSyncHudMsg(id, gSync13, "O: %d", floatround(damage)) } } else { ghave[attacker]++ if(ghave[attacker] == 1) { set_hudmessage(0, 255, 0, 0.55, 0.465, 0, 0.0, 1.0, 0.0, 0.2, 1) ShowSyncHudMsg(attacker, gSync5, "%d", floatround(damage)) } if(ghave[attacker] == 2) { set_hudmessage(0, 255, 0, 0.55, 0.5, 0, 0.0, 1.0, 0.0, 0.2, 2) ShowSyncHudMsg(attacker, gSync5, "%d", floatround(damage)) } if(ghave[attacker] == 3) { set_hudmessage(0, 255, 0, 0.55, 0.535, 0, 0.0, 1.0, 0.0, 0.2, 3) ShowSyncHudMsg(attacker, gSync5, "%d", floatround(damage)) } if(ghave[attacker] == 4) { set_hudmessage(0, 255, 0, 0.55, 0.57, 0, 0.0, 1.0, 0.0, 0.2, 4) ShowSyncHudMsg(attacker, gSync5, "%d", floatround(damage)) } if(ghave[attacker] == 5) { set_hudmessage(0, 255, 0, 0.55, 0.605, 0, 0.0, 1.0, 0.0, 0.2, 1) ShowSyncHudMsg(attacker, gSync5, "%d", floatround(damage)) ghave[attacker] = 0 } } /* -- */ static Float:fOrigin[3] static Origin[3] pev(ent, pev_origin, fOrigin) FVecIVec(Origin, fOrigin) static Color[33][3] ; Color[id?id:attacker][0] = gPlayerAttackColorValue[id?id:attacker][0] Color[id?id:attacker][1] = gPlayerAttackColorValue[id?id:attacker][1] Color[id?id:attacker][2] = gPlayerAttackColorValue[id?id:attacker][2] msg_dlight(Origin, 10, Color[id?id:attacker], 3, 1) if(hp <= floatround(damage)) { new data[1] data[0] = id?id:attacker set_task(0.1, "TakeDamage2", ent, data, 1) if(is_valid_ent(pev(ent, pev_ent_health))) remove_entity(pev(ent, pev_ent_health)) } } if(!is_valid_ent(ent)) { client_print(0, 3, "take damage !pev vaild") gMonsterAlive--; if(gMonsterAlive < 0) gMonsterAlive=0 if(gMonsterAlive <= 0 && gWave && gStart && gGame) EndRound() return HAM_IGNORED } SetHamParamFloat(4, damage) return HAM_IGNORED } public TakeDamage2(Params[], ent) { new id = Params[0] gMonsterAlive--; if(gMonsterAlive < 0) gMonsterAlive=0 if(gMonsterAlive <= 0 && gWave && gStart && gGame) EndRound() if(is_user_connected(id)) { set_hudmessage(255, 255, 255, -1.0, 0.6, 0, 0.0, 1.0, 0.0, 0.3) ShowSyncHudMsg(id, gSync3, "KILL!") gPlayerPoints[id]+=get_pcvar_num(cvar_points_kill) cs_set_user_money(id, cs_get_user_money(id)+450) if(is_user_alive(id)) GiveAmmo(id, 20) set_user_frags(id, get_user_frags(id)+1) refreshFrags(id) } }Do zamknięcia! Przejdź do postu
Napisano 07.05.2013 14:52
if(pev_valid(ent) && pev_valid(pev(ent, pev_ent_health)))
remove_entity(pev(ent, pev_ent_health))
Posiadam TBM (inaczej PTB), które działa dużo lepiej niż zwykłe PTB, nawet na modach z lvlami. Zainteresowany? Proszę bardzo
Napisano 08.05.2013 16:21
#define pev_ent_health pev_iuser3 // HP potwora ......... new bar = create_entity("env_sprite") entity_set_string(bar, EV_SZ_classname, "monster_healthbar"); entity_set_vector(bar, EV_VEC_origin, Origin) entity_set_model(bar, gEntityBar[0]); entity_set_int(bar, EV_INT_solid, SOLID_NOT); entity_set_int(bar, EV_INT_movetype, MOVETYPE_FLY) set_pev(ent, pev_ent_health, bar) set_pev(ent, pev_max_health, health) set_pev(bar, pev_scale, 0.30); entity_set_float(ent, EV_FL_nextthink, get_gametime()+0.03); client_print(0, 3, "send monsters| ent %d bar %d", ent, bar)
Nowa wersja Tower Defense 0.2 Alpha | Inne Mody -> Nowości
Napisano 08.05.2013 19:15 Najlepsza odpowiedź
public TakeDamage(ent, idinflictor, attacker, Float:damage, damagebits) { static classname[32]; entity_get_string(ent, EV_SZ_classname, classname, 31); if(equal(classname, "monster")) { new hp = floatround(entity_get_float(ent, EV_FL_health)) /* Pokazuje zadane obrazenia */ new id = 0 if(is_turret(attacker)) { id = SentryOwner(attacker) if(gPlayerDamage[id]) damage+=float(gPlayerNewDamage[id]) } if(is_turret(attacker)) { new sentryid = SentryId(ent) if(damagebits & DMG_SLASH && sentryid == 0) { set_hudmessage(100, 255, 0, 0.81, 0.27, 0, 6.0, 1.0) ShowSyncHudMsg(id, gSync9, "W 1: %d", floatround(damage)) } if(damagebits & DMG_BLAST && sentryid == 1) { set_hudmessage(100, 255, 0, 0.81, 0.32, 0, 6.0, 1.0) ShowSyncHudMsg(id, gSync10, "W 2: %d", floatround(damage)) } if(damagebits & DMG_BURN && sentryid == 2) { set_hudmessage(100, 255, 0, 0.81, 0.37, 0, 6.0, 1.0) ShowSyncHudMsg(id, gSync11, "W 3: %d", floatround(damage)) } if(damagebits & DMG_DROWN && sentryid == 3) { set_hudmessage(100, 255, 0, 0.81, 0.42, 0, 6.0, 1.0) ShowSyncHudMsg(id, gSync12, "W 4: %d", floatround(damage)) } if(MAX_SENTRY > 4 && sentryid >= 4) { set_hudmessage(100, 0, 255, 0.81, 0.47, 0, 6.0, 1.0) ShowSyncHudMsg(id, gSync13, "O: %d", floatround(damage)) } } else { ghave[attacker]++ if(ghave[attacker] == 1) { set_hudmessage(0, 255, 0, 0.55, 0.465, 0, 0.0, 1.0, 0.0, 0.2, 1) ShowSyncHudMsg(attacker, gSync5, "%d", floatround(damage)) } if(ghave[attacker] == 2) { set_hudmessage(0, 255, 0, 0.55, 0.5, 0, 0.0, 1.0, 0.0, 0.2, 2) ShowSyncHudMsg(attacker, gSync5, "%d", floatround(damage)) } if(ghave[attacker] == 3) { set_hudmessage(0, 255, 0, 0.55, 0.535, 0, 0.0, 1.0, 0.0, 0.2, 3) ShowSyncHudMsg(attacker, gSync5, "%d", floatround(damage)) } if(ghave[attacker] == 4) { set_hudmessage(0, 255, 0, 0.55, 0.57, 0, 0.0, 1.0, 0.0, 0.2, 4) ShowSyncHudMsg(attacker, gSync5, "%d", floatround(damage)) } if(ghave[attacker] == 5) { set_hudmessage(0, 255, 0, 0.55, 0.605, 0, 0.0, 1.0, 0.0, 0.2, 1) ShowSyncHudMsg(attacker, gSync5, "%d", floatround(damage)) ghave[attacker] = 0 } } /* -- */ static Float:fOrigin[3] static Origin[3] pev(ent, pev_origin, fOrigin) FVecIVec(Origin, fOrigin) static Color[33][3] ; Color[id?id:attacker][0] = gPlayerAttackColorValue[id?id:attacker][0] Color[id?id:attacker][1] = gPlayerAttackColorValue[id?id:attacker][1] Color[id?id:attacker][2] = gPlayerAttackColorValue[id?id:attacker][2] msg_dlight(Origin, 10, Color[id?id:attacker], 3, 1) if(hp <= floatround(damage)) { new data[1] data[0] = id?id:attacker set_task(0.1, "TakeDamage2", ent, data, 1) if(is_valid_ent(pev(ent, pev_ent_health))) remove_entity(pev(ent, pev_ent_health)) } } if(!is_valid_ent(ent)) { client_print(0, 3, "take damage !pev vaild") gMonsterAlive--; if(gMonsterAlive < 0) gMonsterAlive=0 if(gMonsterAlive <= 0 && gWave && gStart && gGame) EndRound() return HAM_IGNORED } SetHamParamFloat(4, damage) return HAM_IGNORED } public TakeDamage2(Params[], ent) { new id = Params[0] gMonsterAlive--; if(gMonsterAlive < 0) gMonsterAlive=0 if(gMonsterAlive <= 0 && gWave && gStart && gGame) EndRound() if(is_user_connected(id)) { set_hudmessage(255, 255, 255, -1.0, 0.6, 0, 0.0, 1.0, 0.0, 0.3) ShowSyncHudMsg(id, gSync3, "KILL!") gPlayerPoints[id]+=get_pcvar_num(cvar_points_kill) cs_set_user_money(id, cs_get_user_money(id)+450) if(is_user_alive(id)) GiveAmmo(id, 20) set_user_frags(id, get_user_frags(id)+1) refreshFrags(id) } }Do zamknięcia!
Nowa wersja Tower Defense 0.2 Alpha | Inne Mody -> Nowości
Napisano 08.05.2013 19:57
Posiadam TBM (inaczej PTB), które działa dużo lepiej niż zwykłe PTB, nawet na modach z lvlami. Zainteresowany? Proszę bardzo
0 użytkowników, 0 gości, 0 anonimowych