FlacoBey

Untitled

Jan 16th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.69 KB | None | 0 0
  1. #include sdktools
  2. #include sdkhooks
  3.  
  4. Handle sdkOnStaggered;
  5. Handle distance;
  6. public OnPluginStart()
  7. {
  8.     distance    = CreateConVar("sv_rang_rock_stun", "400.0", "", FCVAR_NONE);
  9.     Handle hGameConf = LoadGameConfigFile("tank_stun_rock");
  10.    
  11.     StartPrepSDKCall(SDKCall_Player);
  12.     PrepSDKCall_SetFromConf(hGameConf, SDKConf_Signature, "CTerrorPlayer_OnStaggered");
  13.     PrepSDKCall_AddParameter(SDKType_CBaseEntity, SDKPass_Pointer);
  14.     PrepSDKCall_AddParameter(SDKType_Vector, SDKPass_ByRef);
  15.     sdkOnStaggered = EndPrepSDKCall();
  16. }
  17.  
  18. public OnEntityDestroyed(entity)
  19. {
  20.     if(IsValidEntity(entity) && IsValidEdict(entity))
  21.     {
  22.         decl String:g_classname[20];
  23.         GetEdictClassname(entity, g_classname, 20);
  24.         if(StrEqual(g_classname, "tank_rock", true) && GetEntProp(entity, Prop_Send, "m_iTeamNum")>=0)
  25.         {
  26.             for(int i = 1; i <= MaxClients; ++i)
  27.             {
  28.                 if(bIsSurvivor(i))
  29.                 {
  30.                     float fDamagerPos[3], fDangerPos[3];
  31.                     GetEntPropVector(entity, Prop_Send, "m_vecOrigin", fDamagerPos);
  32.                     GetEntPropVector(i, Prop_Send, "m_vecOrigin", fDangerPos);
  33.                     float fTargetDistance = GetVectorDistance(fDamagerPos, fDangerPos);
  34.                     if (fTargetDistance > GetConVarFloat(distance)) continue;
  35.                    
  36.                     SDKCall(sdkOnStaggered, i, entity, fDamagerPos);
  37.                 }
  38.             }
  39.         }
  40.     }
  41. }
  42.  
  43. stock bool bIsSurvivor(int client)
  44. {
  45.     return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
  46. }
Advertisement
Add Comment
Please, Sign In to add comment