Advertisement
FlacoBey

Untitled

Jun 16th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.25 KB | None | 0 0
  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(fTargetDistance < weapon_autoshotgun)
  43.                     {
  44.                         SDKCall(sdkSetAttack, i);
  45.                     }
  46.                 }
  47.             }
  48.         }
  49.     }
  50.     return Plugin_Continue;
  51. }
  52.  
  53. public bool _TraceFilter(int entity, int contentsMask)
  54. {
  55.     if (IsValidEntity(entity))
  56.     {
  57.         return false;
  58.     }
  59.     return true;
  60. }
  61.  
  62. stock bool bIsSurvivor(int client)
  63. {
  64.     return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
  65. }
  66.  
  67. stock bool IsCommonInfected(int entity)
  68. {
  69.     if (entity > 33 && IsValidEntity(entity) && IsValidEdict(entity))
  70.     {
  71.         char entType[64];
  72.         GetEdictClassname(entity, entType, sizeof(entType));
  73.         return StrEqual(entType, "infected");
  74.     }
  75.     return false;
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement