#include <amxmodx>
#include <reapi>
#define MAX_ENTS 10 //?
enum ents_e {
Entity_Id,
Entity_Solid,
Entity_RenderFx,
Float: Entity_RenderColor[3],
Entity_RenderMode,
Float: Entity_RenderAmt
};
new g_eEntity[MAX_ENTS][ents_e];
public plugin_precache() {
new iEntity = NULLENT, i = 0;
while ((iEntity = rg_find_ent_by_model(iEntity, "trigger_teleport", "*2")) > 0) {
if (is_nullent(iEntity)) {
continue;
}
g_eEntity[i][Entity_Id] = iEntity;
g_eEntity[i][Entity_Solid] = get_entvar(iEntity, var_solid);
g_eEntity[i][Entity_RenderFx] = get_entvar(iEntity, var_renderfx);
get_entvar(iEntity, var_rendercolor, g_eEntity[i][Entity_RenderColor]);
g_eEntity[i][Entity_RenderMode] = get_entvar(iEntity, var_rendermode);
g_eEntity[i][Entity_RenderAmt] = get_entvar(iEntity, var_renderamt);
i++;
}
}
stock bool: switch_entity(const iEntity) {
if (is_nullent(iEntity)) {
return false;
}
new id = 0;
for (new i = 0; i < MAX_ENTS; i++) {
if (g_eEntity[i][Entity_Id] == iEntity) {
id = i;
break;
}
}
if (get_entvar(iEntity, var_solid) == g_eEntity[id][Entity_Solid]) {
set_entvar(iEntity, var_solid, SOLID_NOT);
rg_set_rendering(iEntity, kRenderFxGlowShell, { 0.0, 0.0, 0.0 }, kRenderTransAlpha, 0.0);
}
else {
set_entvar(iEntity, var_solid, g_eEntity[id][Entity_Solid]);
rg_set_rendering(iEntity,
g_eEntity[id][Entity_RenderFx],
g_eEntity[id][Entity_RenderColor],
g_eEntity[id][Entity_RenderMode],
g_eEntity[id][Entity_RenderAmt]
);
}
return true;
}
stock rg_set_rendering(const iEntity, fx = kRenderFxNone, Float: rgb[3] = { 255.0, 255.0, 255.0 }, render = kRenderNormal, Float: amount = 16.0) {
set_entvar(iEntity, var_renderfx, fx);
set_entvar(iEntity, var_rendercolor, rgb);
set_entvar(iEntity, var_rendermode, render);
set_entvar(iEntity, var_renderamt, amount);
}
//fm_utils
stock rg_find_ent_by_model(index, const classname[], const model[]) {
new ent = index, mdl[72];
while ((ent = rg_find_ent_by_class(ent, classname))) {
get_entvar(ent, var_model, mdl, sizeof mdl - 1);
if (equal(mdl, model))
return ent;
}
return 0;
}