#include <amxmodx>
#include <fakemeta>
#include <reapi>
enum RGB { r, g, b };
new Float: as_vip_health, Float: as_vip_armor, as_vip_colors[3], as_vip_color_alpha;
new g_hAddToFullPack = 1;
#define IsHasColors() (as_vip_colors[0] || as_vip_colors[1] || as_vip_colors[2])
#define get__bIsVIP(%1) get_member(%1, m_bIsVIP)
#define set__bIsVIP(%1,%2) set_member(%1, m_bIsVIP, %2)
new Array: g_aSpawnItems, g_iArraySize_SpawnItems;
enum any: Item_s
{
item_name[32],
item_count
}
public plugin_init()
{
register_plugin("[AS_] Assassination Enhancement", "0.0.1b", "wopox1337 @ Dev-CS.ru");
new pCvar;
pCvar = create_cvar("as_vip_health", "100",
.description = "VIP Health value",
.has_min = true, .min_val = 1.0,
.has_max = true, .max_val = 300.0
);
bind_pcvar_float(pCvar, as_vip_health);
pCvar = create_cvar("as_vip_armor", "100",
.description = "VIP Armor value",
.has_min = true, .min_val = 0.0,
.has_max = true, .max_val = 999.0
);
bind_pcvar_float(pCvar, as_vip_armor);
pCvar = create_cvar("as_vip_colors", "0 0 200 20",
.description = "VIP player color (glow[R G B A]). Ony teammates see that glow.",
.has_min = true, .min_val = 0.0
);
hook_cvar_change(pCvar, "as_vip_colors_changed");
register_srvcmd("as_vip_add_spawnitem", "SrvCmd_AddSpawnItem");
AutoExecConfig();
}
public as_vip_colors_changed(pcvar, const old_value[], const new_value[])
{
ParseColors(new_value);
if(IsHasColors() || g_hAddToFullPack == 1)
g_hAddToFullPack = register_forward(FM_AddToFullPack, "pfnAddToFullPack", ._post = true);
else unregister_forward(FM_AddToFullPack, g_hAddToFullPack, .post = true);
}
public OnConfigsExecuted()
{
if(!get_member_game(m_bMapHasVIPSafetyZone))
pause("a");
RegisterHookChain(RG_CBasePlayer_Spawn, "CBasePlayer_Spawn", .post = true);
g_hAddToFullPack = register_forward(FM_AddToFullPack, "pfnAddToFullPack", ._post = true);
new colors[20];
get_cvar_string("as_vip_colors", colors, charsmax(colors));
ParseColors(colors);
if(IsHasColors())
return;
unregister_forward(FM_AddToFullPack, g_hAddToFullPack, .post = true);
}
public CBasePlayer_Spawn(const this)
{
if(!get__bIsVIP(this) || !is_user_alive(this))
return;
// cuz: https://github.com/s1lentq/ReGameDLL_CS/blob/26db32e8845647cf024e38f11cb3da3071ac0dd1/regamedll/dlls/weapons.cpp#L566
rg_remove_all_items(this);
set__bIsVIP(this, false);
__GiveItems(this);
set__bIsVIP(this, true); // F'kin dirty hax:)
set_entvar(this, var_health, as_vip_health);
set_entvar(this, var_armorvalue, as_vip_armor);
}
public __GiveItems(id)
{
new aItem[Item_s];
for(new i; i < g_iArraySize_SpawnItems; i++)
{
ArrayGetArray(g_aSpawnItems, i, aItem, sizeof aItem);
rg_give_item_ex(id, aItem[item_name], GT_APPEND, .amount = aItem[item_count]);
}
}
public pfnAddToFullPack(entity_state, e, ent, host, hostflags, player, pSet )
{
if(!player || !get__bIsVIP(e))
return;
if(get_member(e, m_iTeam) != get_member(host, m_iTeam))
return;
set_es_rendering(
.es = entity_state,
.fx = kRenderFxGlowShell,
.color = as_vip_colors,
.render = kRenderNormal,
.amount = as_vip_color_alpha
);
}
stock set_es_rendering(es = 0, fx = kRenderFxNone, color[3] = {255, 255, 255}, render = kRenderNormal, amount = 16) {
set_es(es, ES_RenderFx, fx);
set_es(es, ES_RenderColor, color);
set_es(es, ES_RenderMode, render);
set_es(es, ES_RenderAmt, amount);
}
stock rg_give_item_ex(id, weapon[], GiveType:type = GT_APPEND, amount = 0)
{
rg_give_item(id, weapon, type);
if(amount) rg_set_user_bpammo(id, rg_get_weapon_info(weapon, WI_ID), amount);
}
stock ParseColors(const colors_buff[])
{
new color[4][4];
parse(colors_buff,
color[0], charsmax(color[]),
color[1], charsmax(color[]),
color[2], charsmax(color[]),
color[3], charsmax(color[])
);
for(new any:i; i < RGB; i++)
as_vip_colors[i] = strtol(color[i]);
as_vip_color_alpha = strtol(color[3]);
}
public SrvCmd_AddSpawnItem()
{
if(!g_aSpawnItems) g_aSpawnItems = ArrayCreate(Item_s);
enum any: args_s { arg0, arg1, arg2 };
new szArgs[args_s][32];
for(new iArg = arg0; iArg < sizeof szArgs; iArg++)
read_argv(iArg, szArgs[iArg], charsmax(szArgs[]));
new iArgsCount = read_argc();
if(iArgsCount < 2){
log_amx("\tUsage: as_vip_add_SpawnItem <item_name> [count]");
return;
}
new aSpawnItem[Item_s];
copy(aSpawnItem[item_name], charsmax(aSpawnItem[item_name]), szArgs[arg1]);
aSpawnItem[item_count] = strtol(szArgs[arg2]);
ArrayPushArray(g_aSpawnItems, aSpawnItem);
g_iArraySize_SpawnItems = ArraySize(g_aSpawnItems);
// log_amx("ADD: Item[#%i]: '%s' Count: %i. ", g_iArraySize_SpawnItems, aSpawnItem[item_name], aSpawnItem[item_count]);
}
public plugin_end()
{
ArrayDestroy(g_aSpawnItems);
}