#include <sdkhooks>
#pragma newdecls required
int g_iOffsetRender, g_iOffsetAlpha;
public void OnPluginStart()
{
if ((g_iOffsetRender = FindSendPropInfo("CBaseEntity", "m_nRenderMode")) < 1 || (g_iOffsetAlpha = FindSendPropInfo("CBaseEntity", "m_clrRender") + 3) < 4)
SetFailState("Not supported!");
}
public void OnClientPostAdminCheck(int client)
{
SDKHook(client, SDKHook_WeaponEquipPost, WeaponEquip);
}
public void WeaponEquip(int client, int weapon)
{
if (weapon != -1) SetTranslucencyWeapon(weapon, true);
}
public Action CS_OnCSWeaponDrop(int client, int weaponIndex)
{
if (GetClientHealth(client) < 1 && IsValidEntity(weaponIndex)) SetTranslucencyWeapon(weaponIndex);
return Plugin_Continue;
}
void SetTranslucencyWeapon(int weapon, bool normal = false)
{
SetEntData(weapon, g_iOffsetRender, 4, 1, true);
SetEntData(weapon, g_iOffsetAlpha, normal ? 255:128, 1, true);
}