I'm just learning about this myself. This is the code (which I modified from flyingmongoose), to handle lightning to a player. I run it on a timer repeatedly for a set amount of time.
Code:
g_lightning = PrecacheModel("materials/sprites/tp_beam001.vmt");
Lightning()
{
if (IsClientInGame(winner) && IsPlayerAlive(winner))
{
// get player position
new Float:playerpos[3];
GetClientAbsOrigin(winner,playerpos);
// set lightning settings
// set the top coordinates of the lightning effect
new Float:toppos[3];
toppos[0] = playerpos[0];
toppos[1] = playerpos[1];
toppos[2] = playerpos[2]+1000;
// set the color of the lightning
new lightningcolor[4];
lightningcolor[0] = 255;
lightningcolor[1] = 255;
lightningcolor[2] = 255;
lightningcolor[3] = 255;
// how long lightning lasts
new Float:lightninglife = 0.1;
// width of lightning at top
new Float:lightningwidth = 5.0;
// width of lightning at bottom
new Float:lightningendwidth = 5.0;
// lightning start frame
new lightningstartframe = 0;
// lightning frame rate
new lightningframerate = 1;
// how long it takes for lightning to fade
new lightningfadelength = 1;
// how bright lightning is
new Float:lightningamplitude = 1.0;
// how fast the effect is drawn
new lightningspeed = 250;
TE_SetupBeamPoints(toppos, playerpos, g_lightning, g_lightning, lightningstartframe, lightningframerate, lightninglife, lightningwidth, lightningendwidth, lightningfadelength, lightningamplitude, lightningcolor, lightningspeed);
TE_SendToAll(0.0);
}
}
This one is a neat ragdoll dissolve effect which LDuke ported or created.
Code:
public Action:DissolveRagdoll(Handle:timer, any:client)
{
if (!IsValidEntity(client) || IsPlayerAlive(client))
{
return;
}
new ragdoll = GetEntPropEnt(client, Prop_Send, "m_hRagdoll");
if (ragdoll < 0)
{
return;
}
new String:dname[32];
Format(dname, sizeof(dname), "dis_%d", client);
new entid = CreateEntityByName("env_entity_dissolver");
if (entid > 0)
{
DispatchKeyValue(ragdoll, "targetname", dname);
DispatchKeyValue(entid, "dissolvetype", "0");
DispatchKeyValue(entid, "target", dname);
AcceptEntityInput(entid, "Dissolve");
AcceptEntityInput(entid, "kill");
}
}
I'm still trying to learn about more advanced affects. Putting the lightning on a short timer (0.1) still looks jagged and weird when they walk around. Not as smooth as I was hoping for.
Hope some of this points you in the right direction.