FlacoBey

Untitled

May 30th, 2019
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.48 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.     RegConsoleCmd("sm_drop", iDrop);
  10. }
  11.  
  12. public Action iDrop(int client, int args)
  13. {
  14.     if(IsClientInGame(client) && GetClientTeam(client) == 2)
  15.     {
  16.         int iCurrentWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
  17.         if(IsValidEntity(iCurrentWeapon))
  18.         {
  19.             SDKCallWeaponDrop(client, iCurrentWeapon);
  20.         }
  21.     }
  22.     return Plugin_Handled;
  23. }
  24.  
  25. stock void SDKCallWeaponDrop(int client, int weapon)
  26. {
  27.     float vecAngles[3], vecTarget[3], vecVelocity[3];
  28.     if (GetPlayerEye(client, vecTarget))
  29.     {
  30.         GetClientEyeAngles(client, vecAngles);
  31.         GetAngleVectors(vecAngles, vecVelocity, NULL_VECTOR, NULL_VECTOR);
  32.         vecVelocity[0] *= 425.0;
  33.         vecVelocity[1] *= 375.0;
  34.         vecVelocity[2] *= 350.0;
  35.  
  36.         SDKHooks_DropWeapon(client, weapon, NULL_VECTOR, NULL_VECTOR);
  37.  
  38.         TeleportEntity(weapon, NULL_VECTOR, NULL_VECTOR, vecVelocity);
  39.     }
  40. }
  41.  
  42. stock bool GetPlayerEye(int client, float vecTarget[3])
  43. {
  44.     float Origin[3], Angles[3];
  45.     GetClientEyePosition(client, Origin);
  46.     GetClientEyeAngles(client, Angles);
  47.  
  48.     Handle trace = TR_TraceRayFilterEx(Origin, Angles, MASK_SHOT, RayType_Infinite, TraceEntityFilterPlayer);
  49.     if (TR_DidHit(trace))
  50.     {
  51.         TR_GetEndPosition(vecTarget, trace);
  52.         CloseHandle(trace);
  53.         return true;
  54.     }
  55.     CloseHandle(trace);
  56.     return false;
  57. }
  58.  
  59. public bool TraceEntityFilterPlayer(int entity, int contentsMask)
  60. {
  61.     return entity > GetMaxClients() || !entity;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment