#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
new Handle:sm_invisibility_time = INVALID_HANDLE;
public OnPluginStart()
{
HookEvent("player_spawn", Event_PlayerSpawn);
sm_invisibility_time = CreateConVar("sm_invisibility_time", "5", "Invisibility time");
}
public Action:Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event,"userid"));
CreateInvis(client, 0);
CreateTimer(GetConVarFloat(sm_invisibility_time), removeinvis, client);
}
public Action:removeinvis(Handle:timer, any:client)
{
CreateInvis(client, 255);
}
CreateInvis(target, alpha)
{
SetAlpha(target,alpha);
}
SetAlpha(target, alpha)
{
SetWeaponsAlpha(target,alpha);
SetEntityRenderMode(target, RENDER_TRANSCOLOR);
SetEntityRenderColor(target, 255, 255, 255, alpha);
}
SetWeaponsAlpha(target, alpha)
{
if(IsPlayerAlive(target))
{
new m_hMyWeapons = FindSendPropOffs("CBasePlayer", "m_hMyWeapons");
for(new i = 0, weapon; i < 47; i += 4)
{
weapon = GetEntDataEnt2(target, m_hMyWeapons + i);
if(weapon > -1 )
{
SetEntityRenderMode(weapon, RENDER_TRANSCOLOR);
SetEntityRenderColor(weapon, 255, 255, 255, alpha);
}
}
}
}