FlacoBey

Untitled

Feb 16th, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.97 KB | None | 0 0
  1. #include sourcemod
  2. #include sdktools
  3. #include sdkhooks
  4.  
  5. public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3], float angles[3], int& weapon)
  6. {
  7.     if(buttons & IN_ZOOM)
  8.     {
  9.         if(bIsSurvivor(client))
  10.         {
  11.             //decl String:weaponn[32];
  12.             //GetEntityClassname(iCurrentWeapon, weaponn, sizeof(weaponn));
  13.             new item_slot = 0;
  14.             if (IsValidEntity(weapon))
  15.             {
  16.                 for (new slot = 0; slot <= 5; slot++)
  17.                 {
  18.                     item_slot = GetPlayerWeaponSlot(client, slot);
  19.                     if(IsValidEntity(item_slot))
  20.                     {
  21.                         SDKCallWeaponDrop(client, item_slot);
  22.                         break;
  23.                     }
  24.                 }
  25.             }
  26.         }
  27.     }
  28. }
  29.  
  30. stock SDKCallWeaponDrop(client, weapon)
  31. {
  32.     decl Float:vecAngles[3], Float:vecTarget[3], Float:vecVelocity[3];
  33.     if (GetPlayerEye(client, vecTarget))
  34.     {
  35.         GetClientEyeAngles(client, vecAngles);
  36.         GetAngleVectors(vecAngles, vecVelocity, NULL_VECTOR, NULL_VECTOR)
  37.         vecVelocity[0] *= 800.0;
  38.         vecVelocity[1] *= 800.0;
  39.         vecVelocity[2] *= 800.0;
  40.  
  41.         SDKHooks_DropWeapon(client, weapon, NULL_VECTOR, NULL_VECTOR);
  42.  
  43.         TeleportEntity(weapon, NULL_VECTOR, NULL_VECTOR, vecVelocity)
  44.     }
  45. }
  46.  
  47. stock bool:GetPlayerEye(client, Float:vecTarget[3])
  48. {
  49.     decl Float:Origin[3], Float:Angles[3];
  50.     GetClientEyePosition(client, Origin);
  51.     GetClientEyeAngles(client, Angles);
  52.  
  53.     new Handle:trace = TR_TraceRayFilterEx(Origin, Angles, MASK_SHOT, RayType_Infinite, TraceEntityFilterPlayer);
  54.     if (TR_DidHit(trace))
  55.     {
  56.         TR_GetEndPosition(vecTarget, trace);
  57.         CloseHandle(trace);
  58.         return true;
  59.     }
  60.     CloseHandle(trace);
  61.     return false;
  62. }
  63.  
  64. public bool:TraceEntityFilterPlayer(entity, contentsMask)
  65. {
  66.     return entity > GetMaxClients() || !entity;
  67. }
  68.  
  69. stock bool bIsSurvivor(int client)
  70. {
  71.     return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
  72. }
Advertisement
Add Comment
Please, Sign In to add comment