FlacoBey

Untitled

May 31st, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.11 KB | None | 0 0
  1. #include sdktools
  2. #include sdkhooks
  3.  
  4. #pragma semicolon 1
  5. #pragma newdecls required
  6.  
  7. public void OnPluginStart()
  8. {
  9.     HookEvent("jockey_ride", Event_JockeyRide, EventHookMode_Post);
  10.     HookEvent("charger_carry_start", Event_CarrySstart, EventHookMode_Post);
  11.     HookEvent("lunge_pounce", Event_LungePounce, EventHookMode_Post);
  12.     HookEvent("player_hurt", EventPlayerHurt, EventHookMode_Post);
  13. }
  14.  
  15. public Action EventPlayerHurt(Handle event, const char[] name, bool dontBroadcast)
  16. {
  17.     int client = GetClientOfUserId(GetEventInt(event, "victim"));
  18.     char iTankClass[32];
  19.     GetEventString(event, "weapon", iTankClass, sizeof(iTankClass));
  20.     if(StrContains(iTankClass, "tank"))
  21.     {
  22.         int iCurrentWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
  23.         SDKCallWeaponDrop(client, iCurrentWeapon);
  24.     }
  25. }
  26.  
  27. public Action Event_JockeyRide(Handle event, const char[] name, bool dontBroadcast)
  28. {
  29.     int iJockey = GetClientOfUserId(GetEventInt(event, "userid"));
  30.     int client = GetClientOfUserId(GetEventInt(event, "victim"));
  31.     int iCurrentWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
  32.     if(!IsTargetInSightRange(client, iJockey, 107.0, 107.0, true))
  33.     {
  34.         iDropWeapon(client, iCurrentWeapon);
  35.     }
  36. }
  37.  
  38. public Action Event_CarrySstart(Handle event, const char[] name, bool dontBroadcast)
  39. {
  40.     int client = GetClientOfUserId(GetEventInt(event, "victim"));
  41.     int iCurrentWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
  42.     iDropWeapon(client, iCurrentWeapon);
  43. }
  44.  
  45. public Action Event_LungePounce(Handle event, const char[] name, bool dontBroadcast)
  46. {
  47.     int client = GetClientOfUserId(GetEventInt(event, "victim"));
  48.     int iCurrentWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
  49.     iDropWeapon(client, iCurrentWeapon);
  50. }
  51.  
  52. void iDropWeapon(int client, int iWeapon)
  53. {
  54.     if(IsValidEntity(iWeapon))
  55.     {
  56.         SDKCallWeaponDrop(client, iWeapon);
  57.     }
  58. }
  59.  
  60. stock void SDKCallWeaponDrop(int client, int weapon)
  61. {
  62.     float vecAngles[3], vecVelocity[3];
  63.     GetClientEyeAngles(client, vecAngles);
  64.     GetAngleVectors(vecAngles, vecVelocity, NULL_VECTOR, NULL_VECTOR);
  65.     vecVelocity[0] = vecAngles[0] * GetRandomInt(2, 4);
  66.     vecVelocity[1] = vecAngles[1] * GetRandomInt(2, 4);
  67.     vecVelocity[2] = vecAngles[2] * GetRandomInt(2, 4);
  68.     SDKHooks_DropWeapon(client, weapon, NULL_VECTOR, NULL_VECTOR);
  69.     TeleportEntity(weapon, NULL_VECTOR, NULL_VECTOR, vecVelocity);
  70. }
  71.  
  72. stock bool IsTargetInSightRange(int client, int target, float angle = 90.0, float distance = 0.0, bool heightcheck = true, bool negativeangle = false)
  73. {
  74.     if(angle > 360.0 || angle < 0.0)
  75.         ThrowError("Angle Max : 360 & Min : 0. %d isn't proper angle.", angle);
  76.     if(!IsClientInGame(client) && !IsPlayerAlive(client))
  77.         ThrowError("Client is not Alive.");
  78.     if(!IsClientInGame(target) && !IsPlayerAlive(target))
  79.         ThrowError("Target is not Alive.");
  80.        
  81.     float clientpos[3], targetpos[3], anglevector[3], targetvector[3], resultangle, resultdistance;
  82.    
  83.     GetClientEyeAngles(client, anglevector);
  84.     anglevector[0] = anglevector[2] = 0.0;
  85.     GetAngleVectors(anglevector, anglevector, NULL_VECTOR, NULL_VECTOR);
  86.     NormalizeVector(anglevector, anglevector);
  87.     if(negativeangle)
  88.         NegateVector(anglevector);
  89.  
  90.     GetClientAbsOrigin(client, clientpos);
  91.     GetClientAbsOrigin(target, targetpos);
  92.     if(heightcheck && distance > 0)
  93.         resultdistance = GetVectorDistance(clientpos, targetpos);
  94.     clientpos[2] = targetpos[2] = 0.0;
  95.     MakeVectorFromPoints(clientpos, targetpos, targetvector);
  96.     NormalizeVector(targetvector, targetvector);
  97.    
  98.     resultangle = RadToDeg(ArcCosine(GetVectorDotProduct(targetvector, anglevector)));
  99.    
  100.     if(resultangle <= angle/2)  
  101.     {
  102.         if(distance > 0)
  103.         {
  104.             if(!heightcheck)
  105.                 resultdistance = GetVectorDistance(clientpos, targetpos);
  106.             if(distance >= resultdistance)
  107.                 return true;
  108.             else
  109.                 return false;
  110.         }
  111.         else
  112.             return true;
  113.     }
  114.     else
  115.         return false;
  116. }
Advertisement
Add Comment
Please, Sign In to add comment