FlacoBey

Untitled

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