FlacoBey

Untitled

May 21st, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.51 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3. #include <sdkhooks>
  4.  
  5. bool iAlready[MAXPLAYERS+1] = false;
  6.  
  7. public Action OnReload(int weapon)
  8. {
  9.     return Plugin_Handled;
  10. }
  11.  
  12. public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3], float angles[3], int& weapon)
  13. {
  14.     if(bIsSurvivor(client))
  15.     {
  16.         int iCurrentWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
  17.         new iClip = GetEntProp(iCurrentWeapon, Prop_Send, "m_iClip1");
  18.        
  19.         if(GetEntProp(iCurrentWeapon, Prop_Send, "m_bInReload") > 0) return;
  20.        
  21.         if(!(buttons & IN_RELOAD))
  22.         {
  23.             if(iClip == 0)
  24.             {
  25.                 if(!iAlready[client])
  26.                 {
  27.                     iAlready[client] = true;
  28.                     SetEntPropFloat(client, Prop_Send, "m_flNextAttack", 99999.0);
  29.                     SetEntPropFloat(iCurrentWeapon, Prop_Send, "m_flNextPrimaryAttack", 99999.0);
  30.                     SetEntProp(iCurrentWeapon, Prop_Send, "m_iClip1", 0);
  31.                     SDKHook(iCurrentWeapon, SDKHook_Reload, OnReload);
  32.                 }
  33.             }
  34.         }
  35.         if(iClip == 0 && buttons & IN_RELOAD)
  36.         {
  37.             if(iAlready[client])
  38.             {
  39.                 iAlready[client] = false;
  40.                 SetEntPropFloat(client, Prop_Send, "m_flNextAttack", 0.0);
  41.                 SetEntPropFloat(iCurrentWeapon, Prop_Send, "m_flNextPrimaryAttack", 0.0);
  42.                 SetEntProp(iCurrentWeapon, Prop_Send, "m_iClip1", 0);
  43.                 SDKUnhook(iCurrentWeapon, SDKHook_Reload, OnReload);
  44.             }
  45.         }
  46.     }
  47. }
  48.  
  49. stock bool bIsSurvivor(int client)
  50. {
  51.     return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
  52. }
Advertisement
Add Comment
Please, Sign In to add comment