Advertisement
FlacoBey

Untitled

May 22nd, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.05 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3. #include sdkhooks
  4.  
  5. #pragma tabsize 0
  6.  
  7. float GrenadeRadius = 1000.0
  8. float PipeBombRadius = 1000.0
  9. float BarrelRadius = 1000.0
  10.  
  11. bool IsAllow = false;
  12.  
  13. Handle g_hConfStagger;
  14.  
  15. public OnPluginStart()
  16. {
  17.     Handle hConf = LoadGameConfigFile("StaggerInfected");
  18.     if( hConf == null )
  19.         SetFailState("Missing required 'gamedata/l4d2_airstrike.txt', please re-download.");
  20.     StartPrepSDKCall(SDKCall_Player);
  21.     if( PrepSDKCall_SetFromConf(hConf, SDKConf_Signature, "CTerrorPlayer::OnStaggered") == false )
  22.         SetFailState("Could not load the 'CTerrorPlayer::OnStaggered' gamedata signature.");
  23.     PrepSDKCall_AddParameter(SDKType_CBaseEntity, SDKPass_Pointer);
  24.     PrepSDKCall_AddParameter(SDKType_Vector, SDKPass_ByRef);
  25.     g_hConfStagger = EndPrepSDKCall();
  26.     if( g_hConfStagger == null )
  27.         SetFailState("Could not prep the 'CTerrorPlayer::OnStaggered' function.");
  28. }
  29.  
  30. public OnMapStart()
  31. {
  32.     IsAllow = false;
  33.     CreateTimer(3.0, allow)
  34. }
  35.  
  36. public Action allow(Handle timer)
  37. {
  38.     IsAllow = true;
  39. }
  40.  
  41. public void OnEntityDestroyed(int entity)
  42. {
  43.     if(!IsAllow) return;
  44.    
  45.     if (IsValidEntity(entity) && IsValidEdict(entity))
  46.     {
  47.         char classname[128];
  48.         GetEntityClassname(entity, classname, sizeof(classname));
  49.         if (StrEqual(classname, "grenade_launcher_projectile", false))
  50.         {
  51.             GrenadeTouch(entity);
  52.         }
  53.         if (StrEqual(classname, "pipe_bomb_projectile", false))
  54.         {
  55.             BombTouch(entity);
  56.         }
  57.         if (StrEqual(classname, "prop_fuel_barrel", false))
  58.         {
  59.             BarrelTouch(entity);
  60.         }
  61.     }
  62. }
  63.  
  64. public int GrenadeTouch(int entity)
  65. {
  66.     float pos[3];
  67.     GetEntPropVector(entity, Prop_Send, "m_vecOrigin", pos);
  68.     GranadeExplode(pos);
  69. }
  70.  
  71. public int BombTouch(int entity)
  72. {
  73.     float pos[3];
  74.     GetEntPropVector(entity, Prop_Send, "m_vecOrigin", pos);
  75.     BombExplode(pos)
  76. }
  77.  
  78. public int BarrelTouch(int entity)
  79. {
  80.     float pos[3];
  81.     GetEntPropVector(entity, Prop_Send, "m_vecOrigin", pos);
  82.     BarrelExplode(pos);
  83. }
  84.  
  85. int GranadeExplode(float pos[3])
  86. {
  87.     float fDistance = 0.0;
  88.     float pos2[3];
  89.     for( int i = 0; i < 32; i++ )
  90.     {
  91.         if(IsValidClient(i) && GetClientTeam(i) == 3)
  92.         {
  93.             int vClass = GetEntProp(i, Prop_Send, "m_zombieClass")
  94.             if(vClass == 6)
  95.             {
  96.                 GetClientAbsOrigin(i, pos2);
  97.                 fDistance = GetVectorDistance(pos, pos2);
  98.                 if(fDistance < GrenadeRadius)
  99.                 {
  100.                     SDKCall(g_hConfStagger, i, 0.0, pos2);
  101.                 }
  102.             }
  103.         }
  104.     }
  105. }
  106.  
  107. int BombExplode(float pos[3])
  108. {
  109.     float fDistance = 0.0;
  110.     float pos2[3];
  111.     for( int i = 0; i < 32; i++ )
  112.     {
  113.         if(IsValidClient(i) && GetClientTeam(i) == 3)
  114.         {
  115.             int vClass = GetEntProp(i, Prop_Send, "m_zombieClass")
  116.             if(vClass == 6)
  117.             {
  118.                 GetClientAbsOrigin(i, pos2);
  119.                 fDistance = GetVectorDistance(pos, pos2);
  120.                 if(fDistance < PipeBombRadius)
  121.                 {
  122.                     SDKCall(g_hConfStagger, i, 0.0, pos2);
  123.                 }
  124.                
  125.             }
  126.         }
  127.     }
  128. }
  129.  
  130. int BarrelExplode(float pos[3])
  131. {
  132.     float fDistance = 0.0;
  133.     float pos2[3];
  134.     for( int i = 0; i < 32; i++ )
  135.     {
  136.         if(IsValidClient(i) && GetClientTeam(i) == 3)
  137.         {
  138.             int vClass = GetEntProp(i, Prop_Send, "m_zombieClass")
  139.             if(vClass == 6)
  140.             {
  141.                 GetClientAbsOrigin(i, pos2);
  142.                 fDistance = GetVectorDistance(pos, pos2);
  143.                 if(fDistance < BarrelRadius)
  144.                 {
  145.                     SDKCall(g_hConfStagger, i, 0.0, pos2);
  146.                 }
  147.             }
  148.         }
  149.     }
  150. }
  151.  
  152. stock bool:IsValidClient(client)
  153. {
  154.     if ( client < 1 || client > MaxClients ) return false;
  155.     if ( !IsClientConnected( client )) return false;
  156.     if ( !IsClientInGame( client )) return false;
  157.     if ( GetClientTeam( client ) != 3 ) return false;
  158.     return true;
  159. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement