Advertisement
FlacoBey

Untitled

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