SHARE
TWEET

Untitled

FlacoBey Jun 16th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pragma semicolon 1
  2. #pragma newdecls required
  3.  
  4. #include <sdktools>
  5. #include <sdkhooks>
  6.  
  7. Handle sdkSetAttack;
  8.  
  9. float weapon_autoshotgun = 1650.0;
  10.  
  11. public void OnPluginStart()
  12. {
  13.     Handle hGameConf = LoadGameConfigFile("SetAttackSurvivorCommons");
  14.     StartPrepSDKCall(SDKCall_Entity);
  15.     if( PrepSDKCall_SetFromConf(hGameConf, SDKConf_Signature, "SetAttackToSurvivors") == false )
  16.         SetFailState("Could not load the \"SetAttackToSurvivors\" gamedata signature.");
  17.     sdkSetAttack = EndPrepSDKCall();
  18.    
  19.     HookEvent("weapon_fire", EventFire);
  20. }
  21.  
  22. public Action EventFire(Handle event, const char[] name, bool dontbroadcast)
  23. {
  24.     int client = GetClientOfUserId(GetEventInt(event, "userid"));
  25.     int weapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
  26.     if(!IsValidEntity(weapon)) return Plugin_Continue;
  27.    
  28.     char weaponname[36];
  29.     GetEntityClassname(weapon, weaponname, sizeof(weaponname));
  30.     if(bIsSurvivor(client))
  31.     {
  32.         float vPos[3], vTargetPos[3];
  33.         GetClientEyePosition(client, vPos);
  34.         if(strcmp(weaponname, "weapon_autoshotgun") == 0)
  35.         {
  36.             for(int i = 33; i <= 2048; i++)
  37.             {
  38.                 if(IsCommonInfected(i))
  39.                 {
  40.                     GetEntPropVector(i, Prop_Send, "m_vecOrigin", vTargetPos);
  41.                     float fTargetDistance = GetVectorDistance(vPos, vTargetPos);
  42.                     if(IsVisibleTo(vPos, vTargetPos))
  43.                     {
  44.                         if(fTargetDistance < weapon_autoshotgun)
  45.                         {
  46.                             SDKCall(sdkSetAttack, i);
  47.                         }
  48.                     }
  49.                 }
  50.             }
  51.         }
  52.     }
  53.     return Plugin_Continue;
  54. }
  55.  
  56. public bool _TraceFilter(int entity, int contentsMask)
  57. {
  58.     if (IsValidEntity(entity))
  59.     {
  60.         return false;
  61.     }
  62.     return true;
  63. }
  64.  
  65. stock bool bIsSurvivor(int client)
  66. {
  67.     return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
  68. }
  69.  
  70. stock bool IsCommonInfected(int entity)
  71. {
  72.     if (entity > 33 && IsValidEntity(entity) && IsValidEdict(entity))
  73.     {
  74.         char entType[64];
  75.         GetEdictClassname(entity, entType, sizeof(entType));
  76.         return StrEqual(entType, "infected");
  77.     }
  78.     return false;
  79. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top