FlacoBey

Untitled

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