Skip to content

Instantly share code, notes, and snippets.

@hjhee
Last active June 21, 2017 14:53
Show Gist options
  • Save hjhee/6ea240e7fc480f9f9cc0af1da422a878 to your computer and use it in GitHub Desktop.
Save hjhee/6ea240e7fc480f9f9cc0af1da422a878 to your computer and use it in GitHub Desktop.
Dissolve Common Infected Ragdolls
// #pragma newdecls required
#include <sourcemod>
#include <sdktools>
#include <smlib>
#define PLUGIN_VERSION "0.1.3"
public Plugin myinfo={
name="[L4D] Dissolve Ragdolls",
author="hjhee",
description="Dissolve Common Infected Ragdolls.",
version=PLUGIN_VERSION,
url="https://gist.github.com/hjhee/6ea240e7fc480f9f9cc0af1da422a878"
}
float g_mins[3]={-5000000.0, -5000000.0, -5000000.0};
float g_maxs[3]={5000000.0, 5000000.0, 5000000.0};
float g_loc[3]={0.0, 0.0, 0.0};
public void OnPluginStart(){
HookEvent("round_start", OnRoundStart);
RegAdminCmd("sm_ragdoll_fade", CmdCreateFadeEntity, ADMFLAG_GENERIC, "Create func_ragdoll_fader");
// HookEvent("player_death", OnPlayerDeath);
// HookEvent("zombie_ignited", OnZombieIgnited, EventHookMode_Pre);
}
public Action CmdCreateFadeEntity(int client, int args) {
if(!client)
return Plugin_Handled;
float vec[3];
GetClientAbsOrigin(client, vec);
int func_ragdoll_fader=CreateEntityByName("func_ragdoll_fader");
if(func_ragdoll_fader==-1){
PrintToChat(client, "create func_ragdoll_fader failed!");
return Plugin_Handled;
}
DispatchSpawn(func_ragdoll_fader);
ActivateEntity(func_ragdoll_fader);
SetEntPropVector(func_ragdoll_fader, Prop_Send, "m_vecMins", g_mins);
SetEntPropVector(func_ragdoll_fader, Prop_Send, "m_vecMaxs", g_maxs);
SetEntProp(func_ragdoll_fader, Prop_Send, "m_nSolidType", 2);
TeleportEntity(func_ragdoll_fader, vec, NULL_VECTOR, NULL_VECTOR);
return Plugin_Handled;
}
public void OnMapStart(){
if(!IsModelPrecached("sprites/light_glow03.vmt"))
PrecacheModel("sprites/light_glow03.vmt");
if(!IsModelPrecached("sprites/glow_test02.vmt"))
PrecacheModel("sprites/glow_test02.vmt");
}
public Action OnRoundStart(Handle event, const char[] name, bool dontBroadcast){
CreateTimer(3.0, timer_SpawnFader, TIMER_FLAG_NO_MAPCHANGE); // TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
return Plugin_Continue;
}
public Action timer_SpawnFader(Handle timer){
int func_ragdoll_fader=CreateEntityByName("func_ragdoll_fader");
if(func_ragdoll_fader==-1){
// PrintToChat(client, "create func_ragdoll_fader failed!");
CreateTimer(3.0, timer_SpawnFader, TIMER_FLAG_NO_MAPCHANGE); // TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
return Plugin_Stop;
}
DispatchSpawn(func_ragdoll_fader);
ActivateEntity(func_ragdoll_fader);
SetEntPropVector(func_ragdoll_fader, Prop_Send, "m_vecMins", g_mins);
SetEntPropVector(func_ragdoll_fader, Prop_Send, "m_vecMaxs", g_maxs);
SetEntProp(func_ragdoll_fader, Prop_Send, "m_nSolidType", 2);
TeleportEntity(func_ragdoll_fader, g_loc, NULL_VECTOR, NULL_VECTOR);
return Plugin_Stop;
// int client=GetInGameClient();
// if(client){
// float vec[3];
// GetClientAbsOrigin(client, vec);
// vec[2]-=1000.0;
// int func_ragdoll_fader=CreateEntityByName("func_ragdoll_fader");
// if(func_ragdoll_fader==-1)
// return Plugin_Continue;
// SetEntPropVector(func_ragdoll_fader, Prop_Send, "m_vecMins", g_mins);
// SetEntPropVector(func_ragdoll_fader, Prop_Send, "m_vecMaxs", g_maxs);
// SetEntProp(func_ragdoll_fader, Prop_Send, "m_nSolidType", 2);
// TeleportEntity(func_ragdoll_fader, vec, NULL_VECTOR, NULL_VECTOR);
// return Plugin_Stop;
// }
// return Plugin_Continue;
}
stock int GetInGameClient(){
for(int i=1; i<=MaxClients; i++)
if(IsClientInGame(i)&&GetClientTeam(i)==2)
return i;
return 0;
}
stock void FadeEntity(int entid){
int func_ragdoll_fader=CreateEntityByName("func_ragdoll_fader");
if(func_ragdoll_fader==-1)
return;
DispatchSpawn(func_ragdoll_fader);
ActivateEntity(func_ragdoll_fader);
float vec[3];
GetEntPropVector(entid, Prop_Send, "m_vecOrigin", vec);
SetEntPropVector(func_ragdoll_fader, Prop_Send, "m_vecMins", g_mins);
SetEntPropVector(func_ragdoll_fader, Prop_Send, "m_vecMaxs", g_maxs);
SetEntProp(func_ragdoll_fader, Prop_Send, "m_nSolidType", 2);
TeleportEntity(func_ragdoll_fader, vec, NULL_VECTOR, NULL_VECTOR);
CreateTimer(0.2, DestoryFader, func_ragdoll_fader, TIMER_FLAG_NO_MAPCHANGE);
}
// public Action OnPlayerDeath(Handle event, const char[] name, bool dontBroadcast){
// if(GetEventInt(event, "userid")==0){
// int entid=GetEventInt(event, "entityid");
// if(IsCommonInfected(entid)){
// FadeEntity(entid);
// // Effect_DissolveEntity(entid, DISSOLVE_ELECTRICAL_LIGHT);
// }
// }
// return Plugin_Continue;
// }
// public Action OnZombieIgnited(Handle event, const char[] name, bool dontBroadcast){
// char zname[15];
// GetEventString(event, "victimname", zname, sizeof(zname));
// if(StrEqual(zname, "Infected"))
// Effect_FadeOut(GetEventInt(event, "entityid"), false);
// // Effect_DissolveEntity(GetEventInt(event, "entityid"), DISSOLVE_ELECTRICAL_LIGHT);
// // PrintToServer("Zombie Ignited: %d(%s)", GetEventInt(event, "entityid"), zname);
// return Plugin_Handled;
// }
// public Action DestoryFader(Handle timer, any entid){
// if(IsCommonInfected(entid))
// AcceptEntityInput(entid, "Kill");
// }
// stock bool IsCommonInfected(int entid){
// if(entid&&IsValidEntity(entid)&&IsValidEdict(entid)){
// char strClassName[64];
// GetEdictClassname(entid, strClassName, sizeof(strClassName));
// return StrEqual(strClassName, "infected");
// }
// return false;
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment