Advertisement
FlacoBey

Untitled

Jan 17th, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.71 KB | None | 0 0
  1. #include sdktools
  2.  
  3. int Clip;
  4.  
  5. public void OnPluginStart()
  6. {
  7.     Clip = FindSendPropInfo("CBaseCombatWeapon", "m_iClip1");
  8.     HookEvent("weapon_reload", eReloadWeapon);
  9. }
  10.  
  11. public Action:eReloadWeapon(Handle:event, const String:name[], bool:dontBroadcast)
  12. {
  13.     new iClient = GetClientOfUserId(GetEventInt(event, "userid"));
  14.     if(!IsValidClient(iClient)  
  15.             || !IsPlayerAlive(iClient)
  16.             || IsFakeClient(iClient)
  17.             || GetClientTeam(iClient) != 2)
  18.     return Plugin_Continue;
  19.  
  20.     int iCurrentWeapon = GetEntPropEnt(iClient, Prop_Send, "m_hActiveWeapon");
  21.    
  22.     if(!IsValidEntity(iCurrentWeapon))
  23.     return Plugin_Continue;
  24.  
  25.     int iViewModel = GetEntPropEnt(iClient, Prop_Send, "m_hViewModel");
  26.    
  27.     if(!IsValidEntity(iViewModel))
  28.     return Plugin_Continue;
  29.    
  30.     decl String:sWeaponName[32];
  31.     GetClientWeapon(iClient, sWeaponName, sizeof(sWeaponName));
  32.  
  33.     if (StrContains(sWeaponName, "hunting_rifle", false) != -1)
  34.     {
  35.         if(Clip == 0)
  36.         {
  37.             SetEntProp(iViewModel, Prop_Send, "m_nLayerSequence", 3);
  38.             SetEntPropFloat(iViewModel, Prop_Send, "m_flLayerStartTime", GetGameTime());
  39.             ChangeEdictState(iViewModel, FindDataMapInfo(iViewModel, "m_nLayerSequence"));
  40.         }
  41.         else if(Clip > 0)
  42.         {
  43.             SetEntProp(iViewModel, Prop_Send, "m_nLayerSequence", 13);
  44.             SetEntPropFloat(iViewModel, Prop_Send, "m_flLayerStartTime", GetGameTime());
  45.             ChangeEdictState(iViewModel, FindDataMapInfo(iViewModel, "m_nLayerSequence"));
  46.         }
  47.     }
  48.     return Plugin_Continue;
  49. }
  50.  
  51.  
  52. stock bool:IsValidClient(iClient)
  53. {
  54.     if(iClient < 1 || iClient > MaxClients)
  55.     return false;
  56.  
  57.     return IsClientInGame(iClient);
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement