FlacoBey

Untitled

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