/* idea from Бешенный Апельсин IP: 77.220.180.48:27015 */
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
new const PLUGIN_NAME[] = "[AMXX] Ghost after death";
new const PLUGIN_VERSION[] = "0.0.1";
new const ENTITY_NAME[] = "ghost";
new const ENTITY_MODEL_CT[] = "models/player/leet/leet.mdl";
new const ENTITY_MODEL_TR[] = "models/player/gign/gign.mdl"
const Float: ENTITY_RADIUS = 16.0;
const Float: ENTITY_TIME = 1.05;
public plugin_init()
{
register_plugin(PLUGIN_NAME, PLUGIN_VERSION, "steelzorrr (for dev-cs.ru)");
RegisterHam(Ham_Killed, "player", "CPlayer_Killed_Post", .Post = true);
RegisterHam(Ham_Think, "info_target", "CEntity_Think_Pre", .Post = false);
}
public plugin_precache()
{
engfunc(EngFunc_PrecacheModel, ENTITY_MODEL_CT);
engfunc(EngFunc_PrecacheModel, ENTITY_MODEL_TR);
}
public CPlayer_Killed_Post(iVictim, iAttacker, iGib)
{
if(!is_user_connected(iAttacker) || iVictim == iAttacker)
{
return;
}
static iszAllocString_Entity;
if(iszAllocString_Entity || (iszAllocString_Entity = engfunc(EngFunc_AllocString, "info_target")))
{
new iEntity = engfunc(EngFunc_CreateNamedEntity, iszAllocString_Entity);
if(!pev_valid(iEntity))
{
return;
}
static Float: fVecOrigin[3];
pev(iVictim, pev_origin, fVecOrigin);
fVecOrigin[2] += 28.0;
set_pev(iEntity, pev_classname, ENTITY_NAME);
set_pev(iEntity, pev_origin, fVecOrigin);
set_pev(iEntity, pev_solid, SOLID_NOT);
engfunc(EngFunc_SetModel, iEntity, get_user_team(iVictim) == 1 ? ENTITY_MODEL_CT : ENTITY_MODEL_TR);
set_pev(iEntity, pev_sequence, get_user_team(iVictim) == 1 ? 54 : 55); // 54 - ct ; 55 - t
engfunc(EngFunc_SetSize, iEntity, Float:{-ENTITY_RADIUS, -ENTITY_RADIUS, -ENTITY_RADIUS}, Float:{ENTITY_RADIUS, ENTITY_RADIUS, ENTITY_RADIUS});
set_pev(iEntity, pev_framerate, 1.0);
set_pev(iEntity, pev_renderfx, kRenderFxNone);
set_pev(iEntity, pev_rendermode, kRenderTransAdd);
set_pev(iEntity, pev_renderamt, 200.0);
set_pev(iEntity, pev_movetype, MOVETYPE_FLY);
set_pev(iEntity, pev_velocity, Float: {0.0, 0.0, 90.0});
set_pev(iEntity, pev_nextthink, get_gametime() + ENTITY_TIME);
}
return;
}
public CEntity_Think_Pre(iEntity)
{
if(!pev_valid(iEntity))
{
return HAM_IGNORED;
}
new szClassName[32];
pev(iEntity, pev_classname, szClassName, charsmax(szClassName));
if(equal(szClassName, ENTITY_NAME))
{
set_pev(iEntity, pev_flags, pev(iEntity, pev_flags) | FL_KILLME);
}
return HAM_IGNORED;
}