Here's a bit of code you can stick in any plugin to make players ragdolls dissolve on death.
Tested and working in
● Team Fortress 2
(though I'm sure this will work in other games such as DoD:S, L4D, L4D2, CS:S)
Known bugs with this code
● [TF2] When playing as a Spy using the Dead Ringer, when you feign death, your fake corpse doesn't dissolve.
(I'm not exactly sure how to fix this, so if someone could help me out, that'd be swell)
Here's what the effect looks like ingame (TF2). The dissolving uses the effect from Half Life 2 for when you dissolve someone using those energy ball things.
[IMG]http://img824.**************/img824/2194/dissolvescout.th.png[/IMG]
(Click thumbnail to view fullsize image)
PHP Code:
public OnPluginStart()
{
HookEvent("player_death", Event_PlayerDeathPost, EventHookMode_Post);
}
public Action:Event_PlayerDeathPost(Handle:event, const String:name[], bool:dontBroadcast)
{
new victim = GetClientOfUserId(GetEventInt(event, "userid"));
if (IsValidEntity(victim))
{
CreateTimer(0.1, Timer_DissolveRagdoll, any:victim);
}
return Plugin_Continue;
}
public Action:Timer_DissolveRagdoll(Handle:timer, any:victim)
{
new ragdoll = GetEntPropEnt(victim, Prop_Send, "m_hRagdoll");
if (ragdoll != -1)
{
DissolveRagdoll(ragdoll);
}
}
DissolveRagdoll(ragdoll)
{
new dissolver = CreateEntityByName("env_entity_dissolver");
if (dissolver == -1)
{
return;
}
DispatchKeyValue(dissolver, "dissolvetype", "0");
DispatchKeyValue(dissolver, "magnitude", "1");
DispatchKeyValue(dissolver, "target", "!activator");
AcceptEntityInput(dissolver, "Dissolve", ragdoll);
AcceptEntityInput(dissolver, "Kill");
return;
}