Advertisement
FlacoBey

Untitled

Jan 16th, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.22 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.     new iCurrentWeapon = GetEntPropEnt(iClient, Prop_Send, "m_hActiveWeapon");
  18.    
  19.     if(!IsValidEntity(iCurrentWeapon))
  20.     return Plugin_Continue;
  21.  
  22.     new 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.         SetEntProp(iViewModel, Prop_Send, "m_nLayerSequence", 3);
  33.         SetEntPropFloat(iViewModel, Prop_Send, "m_flLayerStartTime", GetGameTime());
  34.         ChangeEdictState(iViewModel, FindDataMapInfo(iViewModel, "m_nLayerSequence"));
  35.     }
  36.     return Plugin_Continue;
  37. }
  38.  
  39.  
  40. stock bool:IsValidClient(iClient)
  41. {
  42.     if(iClient < 1 || iClient > MaxClients)
  43.     return false;
  44.  
  45.     return IsClientInGame(iClient);
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement