FlacoBey

Untitled

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