Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.14 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3. #include <sdkhooks>
  4.  
  5. static bool g_DeathModelSpawned=false;
  6.  
  7. static bool:bSpawnedGlowModels = false;
  8. static bool:bShowGlow[MAXPLAYERS+1];
  9. static iDeathModelRef[2048+1];
  10. static iGlowModelRef[2048+1];
  11.  
  12. //int g_Falling[MAXPLAYERS+1] = -1;
  13.  
  14. public OnPluginStart()
  15. {
  16. HookEvent("player_death", Player_Death, EventHookMode_Post);
  17.  
  18. CreateTimer(0.1, GlowThink, _, TIMER_REPEAT);
  19. }
  20.  
  21. public OnEntityCreated(entity, const char[] classname)
  22. {
  23. if(classname[0] != 's' )
  24. return;
  25.  
  26. if(StrEqual(classname, "survivor_death_model", false))
  27. {
  28. SDKHook(entity, SDKHook_SpawnPost, SpawnPostDeathModel);
  29. }
  30. }
  31.  
  32. public void SpawnPostDeathModel(entity)
  33. {
  34. //SDKUnhook(entity, SDKHook_SpawnPost, SpawnPostDeathModel);
  35. if(!IsValidEntity(entity)) return;
  36.  
  37. int index = EntIndexToEntRef(entity);
  38.  
  39. g_DeathModelSpawned = true;
  40.  
  41. //SetEntProp(index, Prop_Send, "m_iGlowType", 3);
  42. //SetEntProp(index, Prop_Send, "m_glowColorOverride", 180);
  43. //SetEntProp(index, Prop_Send, "m_nGlowRange", 2147483646);
  44. //SetEntityRenderMode(index, RENDER_NONE);
  45.  
  46. //iDeathModelRef[death_model] = EntIndexToEntRef(death_model);
  47.  
  48. if(bSpawnedGlowModels)
  49. {
  50. SetUpGlowModel(death_model);
  51. }
  52. }
  53.  
  54. public CreateRagdoll(client)
  55. {
  56. if (!IsValidClient(client) || (GetClientTeam(client) != 2 && GetClientTeam(client) != 3 && GetClientTeam(client) != 4))
  57. return;
  58.  
  59. int Ragdoll = CreateEntityByName("cs_ragdoll");
  60. float fPos[3];
  61. float fAng[3];
  62. GetClientAbsOrigin(client, fPos);
  63. GetClientAbsAngles(client, fAng);
  64.  
  65. TeleportEntity(Ragdoll, fPos, fAng, NULL_VECTOR);
  66.  
  67. SetEntPropVector(Ragdoll, Prop_Send, "m_vecRagdollOrigin", fPos);
  68. SetEntProp(Ragdoll, Prop_Send, "m_nModelIndex", GetEntProp(client, Prop_Send, "m_nModelIndex"));
  69. SetEntProp(Ragdoll, Prop_Send, "m_iTeamNum", GetClientTeam(client));
  70. SetEntPropEnt(Ragdoll, Prop_Send, "m_hPlayer", client);
  71. SetEntProp(Ragdoll, Prop_Send, "m_nForceBone", 0);
  72.  
  73. if (GetClientTeam(client) == 2 || GetClientTeam(client) == 4)
  74. {
  75. SetEntProp(Ragdoll, Prop_Send, "m_ragdollType", 4);
  76. SetEntProp(Ragdoll, Prop_Send, "m_survivorCharacter", GetEntProp(client, Prop_Send, "m_survivorCharacter", 1), 1);
  77. }
  78. else if ( GetClientTeam(client) == 3 )
  79. {
  80. int infclass = GetEntProp(client, Prop_Send, "m_zombieClass", 1);
  81. if (infclass == 8)
  82. {
  83. SetEntProp(Ragdoll, Prop_Send, "m_ragdollType", 3);
  84. }
  85. else
  86. {
  87. SetEntProp(Ragdoll, Prop_Send, "m_ragdollType", 2);
  88. }
  89.  
  90. SetEntProp(Ragdoll, Prop_Send, "m_zombieClass", infclass, 1);
  91.  
  92. int effect = GetEntPropEnt(client, Prop_Send, "m_hEffectEntity");
  93. if (IsValidEntity(effect))
  94. {
  95. char effectclass[64];
  96. GetEntityClassname(effect, effectclass, sizeof(effectclass));
  97. if (StrEqual(effectclass, "entityflame"))
  98. {
  99. SetEntProp(Ragdoll, Prop_Send, "m_bOnFire", 1, 1);
  100. }
  101. }
  102. }
  103. else
  104. {
  105. SetEntProp(Ragdoll, Prop_Send, "m_ragdollType", 1);
  106. }
  107.  
  108. int prev_ragdoll = GetEntPropEnt(client, Prop_Send, "m_hRagdoll");
  109. if (!IsPlayerAlive(client) && !IsValidEntity(prev_ragdoll))
  110. {
  111. SetEntPropEnt(client, Prop_Send, "m_hRagdoll", Ragdoll);
  112. }
  113. else
  114. {
  115. SetVariantString("OnUser1 !self:Kill::1.0:1");
  116. AcceptEntityInput(Ragdoll, "AddOutput");
  117. AcceptEntityInput(Ragdoll, "FireUser1");
  118. }
  119. }
  120.  
  121. public Action Player_Death(Handle event, const char[] name, bool dontbroadcast)
  122. {
  123. int client = GetClientOfUserId(GetEventInt(event, "userid"));
  124.  
  125. if ((client <= 0 || GetClientTeam(client) != 2 && GetClientTeam(client) != 4))
  126. return;
  127.  
  128. if (g_DeathModelSpawned)
  129. {
  130. CreateRagdoll(client);
  131. }
  132.  
  133. g_DeathModelSpawned = false;
  134. }
  135.  
  136. public Action GlowThink(Handle hTimer, any Cake)
  137. {
  138. static int i;
  139. static bool bHasDefib;
  140. bHasDefib = false;
  141. for(i = 1; i <= MaxClients; i++)
  142. {
  143. if(!IsClientInGame(i) || IsFakeClient(i) || GetClientTeam(i) != 2)
  144. continue;
  145.  
  146. static char sWeapon[32];
  147. GetClientWeapon(i, sWeapon, sizeof(sWeapon));
  148. if(sWeapon[7] == 'd' && StrEqual(sWeapon, "weapon_defibrillator", false))
  149. {
  150. bHasDefib = true;
  151. bShowGlow[i] = true;
  152. continue;
  153. }
  154. }
  155.  
  156. if(bSpawnedGlowModels && !bHasDefib)
  157. {
  158. for(i = MaxClients; i <= 2048; i++)
  159. if(IsValidEntRef(iGlowModelRef[i]))
  160. AcceptEntityInput(iGlowModelRef[i], "Kill");
  161. bSpawnedGlowModels = false;
  162.  
  163. for(i = 1; i <= MaxClients; i++)
  164. bShowGlow[i] = false;
  165. }
  166. else if(!bSpawnedGlowModels && bHasDefib)
  167. {
  168. for(i = MaxClients; i <= 2048; i++)
  169. if(IsValidEntRef(iDeathModelRef[i]))
  170. if(!SetUpGlowModel(EntRefToEntIndex(iDeathModelRef[i])))
  171. break;
  172.  
  173. bSpawnedGlowModels = true;
  174. }
  175. }
  176.  
  177. stock TeamsTransitions()
  178. {
  179. for( new client = 1; client <= MaxClients; client++ )
  180. {
  181. g_aClientsRespectated[client] = false;
  182. g_aClientsRespectatedAttempts[client] = 0;
  183. }
  184. }
  185.  
  186. public Action ShouldTransmitGlow(int iEntity, int iClient)
  187. {
  188. if(bShowGlow[iClient])
  189. return Plugin_Continue;
  190. return Plugin_Handled;
  191. }
  192.  
  193. bool SetUpGlowModel(int iEntity)
  194. {
  195. static int iEnt;
  196. iEnt = CreateEntityByName("prop_dynamic_ornament");
  197. if(iEnt < 0)
  198. return false;
  199.  
  200. static char sModel[PLATFORM_MAX_PATH];
  201.  
  202. GetEntPropString(iEntity, Prop_Data, "m_ModelName", sModel, sizeof(sModel));
  203.  
  204. DispatchKeyValue(iEnt, "model", sModel);
  205.  
  206. DispatchSpawn(iEnt);
  207. ActivateEntity(iEnt);
  208.  
  209. SetVariantString("!activator");
  210. AcceptEntityInput(iEnt, "SetParent", iEntity);
  211.  
  212. SetVariantString("!activator");
  213. AcceptEntityInput(iEnt, "SetAttached", iEntity);
  214. AcceptEntityInput(iEnt, "TurnOn");
  215.  
  216. iGlowModelRef[iEnt] = EntIndexToEntRef(iEnt);
  217.  
  218. SetEntProp(iEnt, Prop_Send, "m_iGlowType", 3);
  219. SetEntProp(iEnt, Prop_Send, "m_glowColorOverride", 180);
  220. SetEntProp(iEnt, Prop_Send, "m_nGlowRange", 2147483646);
  221. SetEntityRenderMode(iEnt, RENDER_NONE);
  222. SDKHook(iEnt, SDKHook_SetTransmit, ShouldTransmitGlow);
  223. return true;
  224. }
  225.  
  226. static bool IsValidEntRef(int iEntRef)
  227. {
  228. return (iEntRef != 0 && EntRefToEntIndex(iEntRef) != INVALID_ENT_REFERENCE);
  229. }
  230.  
  231. bool IsValidClient(client)
  232. {
  233. if (!IsValidEntity(client))
  234. {
  235. return false;
  236. }
  237.  
  238. if (client <= 0 || client > MaxClients)
  239. {
  240. return false;
  241. }
  242.  
  243. if (!IsClientInGame(client))
  244. {
  245. return false;
  246. }
  247.  
  248. return true;
  249. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement