Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sourcemod>
- #include <sdktools>
- #include <sdkhooks>
- static bool g_DeathModelSpawned=false;
- static bool:bSpawnedGlowModels = false;
- static bool:bShowGlow[MAXPLAYERS+1];
- static iDeathModelRef[2048+1];
- static iGlowModelRef[2048+1];
- //int g_Falling[MAXPLAYERS+1] = -1;
- public OnPluginStart()
- {
- HookEvent("player_death", Player_Death, EventHookMode_Post);
- CreateTimer(0.1, GlowThink, _, TIMER_REPEAT);
- }
- public OnEntityCreated(entity, const char[] classname)
- {
- if(classname[0] != 's' )
- return;
- if(StrEqual(classname, "survivor_death_model", false))
- {
- SDKHook(entity, SDKHook_SpawnPost, SpawnPostDeathModel);
- }
- }
- public void SpawnPostDeathModel(entity)
- {
- //SDKUnhook(entity, SDKHook_SpawnPost, SpawnPostDeathModel);
- if(!IsValidEntity(entity)) return;
- int index = EntIndexToEntRef(entity);
- g_DeathModelSpawned = true;
- //SetEntProp(index, Prop_Send, "m_iGlowType", 3);
- //SetEntProp(index, Prop_Send, "m_glowColorOverride", 180);
- //SetEntProp(index, Prop_Send, "m_nGlowRange", 2147483646);
- //SetEntityRenderMode(index, RENDER_NONE);
- //iDeathModelRef[death_model] = EntIndexToEntRef(death_model);
- if(bSpawnedGlowModels)
- {
- SetUpGlowModel(death_model);
- }
- }
- public CreateRagdoll(client)
- {
- if (!IsValidClient(client) || (GetClientTeam(client) != 2 && GetClientTeam(client) != 3 && GetClientTeam(client) != 4))
- return;
- int Ragdoll = CreateEntityByName("cs_ragdoll");
- float fPos[3];
- float fAng[3];
- GetClientAbsOrigin(client, fPos);
- GetClientAbsAngles(client, fAng);
- TeleportEntity(Ragdoll, fPos, fAng, NULL_VECTOR);
- SetEntPropVector(Ragdoll, Prop_Send, "m_vecRagdollOrigin", fPos);
- SetEntProp(Ragdoll, Prop_Send, "m_nModelIndex", GetEntProp(client, Prop_Send, "m_nModelIndex"));
- SetEntProp(Ragdoll, Prop_Send, "m_iTeamNum", GetClientTeam(client));
- SetEntPropEnt(Ragdoll, Prop_Send, "m_hPlayer", client);
- SetEntProp(Ragdoll, Prop_Send, "m_nForceBone", 0);
- if (GetClientTeam(client) == 2 || GetClientTeam(client) == 4)
- {
- SetEntProp(Ragdoll, Prop_Send, "m_ragdollType", 4);
- SetEntProp(Ragdoll, Prop_Send, "m_survivorCharacter", GetEntProp(client, Prop_Send, "m_survivorCharacter", 1), 1);
- }
- else if ( GetClientTeam(client) == 3 )
- {
- int infclass = GetEntProp(client, Prop_Send, "m_zombieClass", 1);
- if (infclass == 8)
- {
- SetEntProp(Ragdoll, Prop_Send, "m_ragdollType", 3);
- }
- else
- {
- SetEntProp(Ragdoll, Prop_Send, "m_ragdollType", 2);
- }
- SetEntProp(Ragdoll, Prop_Send, "m_zombieClass", infclass, 1);
- int effect = GetEntPropEnt(client, Prop_Send, "m_hEffectEntity");
- if (IsValidEntity(effect))
- {
- char effectclass[64];
- GetEntityClassname(effect, effectclass, sizeof(effectclass));
- if (StrEqual(effectclass, "entityflame"))
- {
- SetEntProp(Ragdoll, Prop_Send, "m_bOnFire", 1, 1);
- }
- }
- }
- else
- {
- SetEntProp(Ragdoll, Prop_Send, "m_ragdollType", 1);
- }
- int prev_ragdoll = GetEntPropEnt(client, Prop_Send, "m_hRagdoll");
- if (!IsPlayerAlive(client) && !IsValidEntity(prev_ragdoll))
- {
- SetEntPropEnt(client, Prop_Send, "m_hRagdoll", Ragdoll);
- }
- else
- {
- SetVariantString("OnUser1 !self:Kill::1.0:1");
- AcceptEntityInput(Ragdoll, "AddOutput");
- AcceptEntityInput(Ragdoll, "FireUser1");
- }
- }
- public Action Player_Death(Handle event, const char[] name, bool dontbroadcast)
- {
- int client = GetClientOfUserId(GetEventInt(event, "userid"));
- if ((client <= 0 || GetClientTeam(client) != 2 && GetClientTeam(client) != 4))
- return;
- if (g_DeathModelSpawned)
- {
- CreateRagdoll(client);
- }
- g_DeathModelSpawned = false;
- }
- public Action GlowThink(Handle hTimer, any Cake)
- {
- static int i;
- static bool bHasDefib;
- bHasDefib = false;
- for(i = 1; i <= MaxClients; i++)
- {
- if(!IsClientInGame(i) || IsFakeClient(i) || GetClientTeam(i) != 2)
- continue;
- static char sWeapon[32];
- GetClientWeapon(i, sWeapon, sizeof(sWeapon));
- if(sWeapon[7] == 'd' && StrEqual(sWeapon, "weapon_defibrillator", false))
- {
- bHasDefib = true;
- bShowGlow[i] = true;
- continue;
- }
- }
- if(bSpawnedGlowModels && !bHasDefib)
- {
- for(i = MaxClients; i <= 2048; i++)
- if(IsValidEntRef(iGlowModelRef[i]))
- AcceptEntityInput(iGlowModelRef[i], "Kill");
- bSpawnedGlowModels = false;
- for(i = 1; i <= MaxClients; i++)
- bShowGlow[i] = false;
- }
- else if(!bSpawnedGlowModels && bHasDefib)
- {
- for(i = MaxClients; i <= 2048; i++)
- if(IsValidEntRef(iDeathModelRef[i]))
- if(!SetUpGlowModel(EntRefToEntIndex(iDeathModelRef[i])))
- break;
- bSpawnedGlowModels = true;
- }
- }
- stock TeamsTransitions()
- {
- for( new client = 1; client <= MaxClients; client++ )
- {
- g_aClientsRespectated[client] = false;
- g_aClientsRespectatedAttempts[client] = 0;
- }
- }
- public Action ShouldTransmitGlow(int iEntity, int iClient)
- {
- if(bShowGlow[iClient])
- return Plugin_Continue;
- return Plugin_Handled;
- }
- bool SetUpGlowModel(int iEntity)
- {
- static int iEnt;
- iEnt = CreateEntityByName("prop_dynamic_ornament");
- if(iEnt < 0)
- return false;
- static char sModel[PLATFORM_MAX_PATH];
- GetEntPropString(iEntity, Prop_Data, "m_ModelName", sModel, sizeof(sModel));
- DispatchKeyValue(iEnt, "model", sModel);
- DispatchSpawn(iEnt);
- ActivateEntity(iEnt);
- SetVariantString("!activator");
- AcceptEntityInput(iEnt, "SetParent", iEntity);
- SetVariantString("!activator");
- AcceptEntityInput(iEnt, "SetAttached", iEntity);
- AcceptEntityInput(iEnt, "TurnOn");
- iGlowModelRef[iEnt] = EntIndexToEntRef(iEnt);
- SetEntProp(iEnt, Prop_Send, "m_iGlowType", 3);
- SetEntProp(iEnt, Prop_Send, "m_glowColorOverride", 180);
- SetEntProp(iEnt, Prop_Send, "m_nGlowRange", 2147483646);
- SetEntityRenderMode(iEnt, RENDER_NONE);
- SDKHook(iEnt, SDKHook_SetTransmit, ShouldTransmitGlow);
- return true;
- }
- static bool IsValidEntRef(int iEntRef)
- {
- return (iEntRef != 0 && EntRefToEntIndex(iEntRef) != INVALID_ENT_REFERENCE);
- }
- bool IsValidClient(client)
- {
- if (!IsValidEntity(client))
- {
- return false;
- }
- if (client <= 0 || client > MaxClients)
- {
- return false;
- }
- if (!IsClientInGame(client))
- {
- return false;
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement