FlacoBey

Untitled

May 22nd, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.07 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. public OnMapStart()
  14. {
  15.     IsAllow = false;
  16.     CreateTimer(3.0, allow)
  17. }
  18.  
  19. public Action allow(Handle timer)
  20. {
  21.     IsAllow = true;
  22. }
  23.  
  24. public void OnEntityDestroyed(int entity)
  25. {
  26.     if(!IsAllow) return;
  27.    
  28.     if (IsValidEntity(entity) && IsValidEdict(entity))
  29.     {
  30.         char classname[128];
  31.         GetEdictClassname(entity, classname, 128);
  32.         if (StrEqual(classname, "grenade_launcher_projectile", false))
  33.         {
  34.             GrenadeTouch(entity);
  35.         }
  36.         if (StrEqual(classname, "pipe_bomb_projectile", false))
  37.         {
  38.             BombTouch(entity);
  39.         }
  40.         if (StrEqual(classname, "prop_fuel_barrel", false))
  41.         {
  42.             BarrelTouch(entity);
  43.         }
  44.     }
  45. }
  46.  
  47. public int GrenadeTouch(int entity)
  48. {
  49.     float pos[3];
  50.     GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);
  51.     GranadeExplode(pos);
  52. }
  53.  
  54. public int BombTouch(int entity)
  55. {
  56.     float pos[3];
  57.     GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);
  58.     BombExplode(pos)
  59. }
  60.  
  61. public int BarrelTouch(int entity)
  62. {
  63.     float pos[3];
  64.     GetEntPropVector(entity, PropType:0, "m_vecOrigin", pos, 0);
  65.     BarrelExplode(pos);
  66. }
  67.  
  68. int GranadeExplode(float pos[3])
  69. {
  70.     float fDistance = 0.0;
  71.     float pos2[3];
  72.     for( int i = 0; i < 32; i++ )
  73.     {
  74.         if(IsValidClient(i) && GetClientTeam(i) == 3)
  75.         {
  76.             int vClass = GetEntProp(i, Prop_Send, "m_zombieClass")
  77.             if(vClass == 6)
  78.             {
  79.                 GetClientAbsOrigin(i, pos2);
  80.                 fDistance = GetVectorDistance(pos, pos2);
  81.                 if(fDistance < GrenadeRadius)
  82.                 {
  83.                     StaggerClient(i, pos)
  84.                 }
  85.             }
  86.         }
  87.     }
  88. }
  89.  
  90. int BombExplode(float pos[3])
  91. {
  92.     float fDistance = 0.0;
  93.     float pos2[3];
  94.     for( int i = 0; i < 32; i++ )
  95.     {
  96.         if(IsValidClient(i) && GetClientTeam(i) == 3)
  97.         {
  98.             int vClass = GetEntProp(i, Prop_Send, "m_zombieClass")
  99.             if(vClass == 6)
  100.             {
  101.                 GetClientAbsOrigin(i, pos2);
  102.                 fDistance = GetVectorDistance(pos, pos2);
  103.                 if(fDistance < PipeBombRadius)
  104.                 {
  105.                     StaggerClient(i, pos)
  106.                 }
  107.                
  108.             }
  109.         }
  110.     }
  111. }
  112.  
  113. int BarrelExplode(float pos[3])
  114. {
  115.     float fDistance = 0.0;
  116.     float pos2[3];
  117.     for( int i = 0; i < 32; i++ )
  118.     {
  119.         if(IsValidClient(i) && GetClientTeam(i) == 3)
  120.         {
  121.             int vClass = GetEntProp(i, Prop_Send, "m_zombieClass")
  122.             if(vClass == 6)
  123.             {
  124.                 GetClientAbsOrigin(i, pos2);
  125.                 fDistance = GetVectorDistance(pos, pos2);
  126.                 if(fDistance < BarrelRadius)
  127.                 {
  128.                     StaggerClient(i, pos)
  129.                 }
  130.             }
  131.         }
  132.     }
  133. }
  134.  
  135. void StaggerClient(int iUserID, const float fPos[3])
  136. {
  137.     static int iScriptLogic = INVALID_ENT_REFERENCE;
  138.     if(iScriptLogic == INVALID_ENT_REFERENCE || !IsValidEntity(iScriptLogic))
  139.     {
  140.         iScriptLogic = EntIndexToEntRef(CreateEntityByName("logic_script"));
  141.         if(iScriptLogic == INVALID_ENT_REFERENCE || !IsValidEntity(iScriptLogic))
  142.             LogError("Could not create 'logic_script");
  143.  
  144.         DispatchSpawn(iScriptLogic);
  145.     }
  146.  
  147.     char sBuffer[96];
  148.     Format(sBuffer, sizeof(sBuffer), "GetPlayerFromUserID(%d).Stagger(Vector(%d,%d,%d))", iUserID, RoundFloat(fPos[0]), RoundFloat(fPos[1]), RoundFloat(fPos[2]));
  149.     SetVariantString(sBuffer);
  150.     AcceptEntityInput(iScriptLogic, "RunScriptCode");
  151.     AcceptEntityInput(iScriptLogic, "Kill");
  152. }
  153.  
  154. stock bool:IsValidClient(client)
  155. {
  156.     if ( client < 1 || client > MaxClients ) return false;
  157.     if ( !IsClientConnected( client )) return false;
  158.     if ( !IsClientInGame( client )) return false;
  159.     if ( GetClientTeam( client ) != 3 ) return false;
  160.     return true;
  161. }
Advertisement
Add Comment
Please, Sign In to add comment