FlacoBey

Untitled

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