FlacoBey

Untitled

Feb 17th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.71 KB | None | 0 0
  1. #include sdktools
  2. #include sdkhooks
  3.  
  4. new bool:IsFucked[MAXPLAYERS+1] = false;
  5. float LastMessage[MAXPLAYERS+1];
  6. Handle EndLoadBar[MAXPLAYERS+1];
  7. int Shots[MAXPLAYERS+1];
  8.  
  9. public OnPluginStart()
  10. {
  11.     HookEvent("weapon_fire", FireBulletsPost)
  12. }
  13.  
  14. public OnMapStart()
  15. {
  16.     for (new i = 1; i <= MaxClients; i++)
  17.     {
  18.         IsFucked[i] = false;
  19.         LastMessage[i] = 0.0;
  20.         Shots[i] = 0;
  21.         EndLoadBar[i] = null;
  22.     }
  23. }
  24.  
  25. public OnClientPutInServer(client)
  26. {
  27.     SDKHook(client, SDKHook_WeaponCanUse, WeaponCanUse);
  28. }
  29.  
  30. public OnClientDisconnect(client)
  31. {
  32.     SDKUnhook(client, SDKHook_WeaponCanUse, WeaponCanUse);
  33.     if (EndLoadBar[client] != null)
  34.     {
  35.         KillTimer(EndLoadBar[client]);
  36.         EndLoadBar[client] = null;
  37.     }
  38. }
  39.  
  40. public Action:WeaponCanUse(client, weapon)
  41. {
  42.     if(bIsSurvivor(client) && !IsFakeClient(client))
  43.     {
  44.         if(IsFucked[client])
  45.         {
  46.             new String:sClassName[64];
  47.             GetEntityClassname(weapon, sClassName, sizeof(sClassName));
  48.             if(StrEqual(sClassName, "weapon_autoshotgun") || StrEqual(sClassName, "weapon_grenade_launcher") || StrEqual(sClassName, "weapon_hunting_rifle ") || StrEqual(sClassName, "weapon_pumpshotgun") || StrEqual(sClassName, "weapon_rifle") || StrEqual(sClassName, "weapon_rifle_ak47") || StrEqual(sClassName, "weapon_rifle_desert") || StrEqual(sClassName, "weapon_rifle_m60") || StrEqual(sClassName, "weapon_rifle_sg552") || StrEqual(sClassName, "weapon_shotgun_chrome") || StrEqual(sClassName, "weapon_shotgun_spas ") || StrEqual(sClassName, "weapon_rifle_sg552") || StrEqual(sClassName, "weapon_smg") || StrEqual(sClassName, "weapon_smg_mp5") || StrEqual(sClassName, "weapon_smg_silenced") || StrEqual(sClassName, "weapon_sniper_awp") || StrEqual(sClassName, "weapon_sniper_military") || StrEqual(sClassName, "weapon_sniper_scout"))
  49.             {
  50.                 return Plugin_Handled;
  51.             }
  52.         }
  53.     }
  54.     return Plugin_Continue;
  55. }
  56.  
  57. public Action FireBulletsPost(Event event, const char[] name, bool dontBroadcast)
  58. {
  59.     int client = GetClientOfUserId(event.GetInt("userid"));
  60.    
  61.     new vSlot = GetPlayerWeaponSlot(client, 0);
  62.     int iCurrentWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
  63.     if(iCurrentWeapon == vSlot)
  64.     {
  65.         if(bIsSurvivor(client) && !IsFakeClient(client))
  66.         {
  67.             if(!IsFucked[client])
  68.             {
  69.                 if(Shots[client] > 125)
  70.                 {
  71.                     if(GetRandomInt(0, 100) < 100)
  72.                     {
  73.                         IsFucked[client] = true;
  74.                         PrintToChat(client, "Ваше оружие заклинило")
  75.                     }
  76.                     Shots[client] = 0;
  77.                 }
  78.                 Shots[client]++
  79.             }
  80.         }
  81.     }
  82. }
  83.  
  84. public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3], float angles[3], int& weapon)
  85. {
  86.     if(IsFucked[client])
  87.     {
  88.         new vSlot = GetPlayerWeaponSlot(client, 0);
  89.         int iCurrentWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
  90.         if(iCurrentWeapon == vSlot)
  91.         {
  92.             if(buttons & IN_ATTACK)
  93.             {
  94.                 if((GetEngineTime() - LastMessage[client]) > 30)
  95.                 {
  96.                     PrintHintText(client, "Дурак? Заклинила пушка, нажми Е!");
  97.                     LastMessage[client] = GetEngineTime();
  98.                 }
  99.                 SetEntPropFloat(client, Prop_Send, "m_flNextAttack", 9999.0);
  100.                 SetEntPropFloat(iCurrentWeapon, Prop_Send, "m_flNextPrimaryAttack", 9999.0);
  101.             }
  102.             else if(buttons & IN_USE)
  103.             {
  104.                 if(EndLoadBar[client] == null)
  105.                 {
  106.                     SetEntPropFloat(client, Prop_Send, "m_flProgressBarStartTime", GetGameTime());
  107.                     SetEntPropFloat(client, Prop_Send, "m_flProgressBarDuration", 3.0);
  108.                     new Handle:vPosition;
  109.                     EndLoadBar[client] = CreateDataTimer(3.0, EndBar, vPosition, TIMER_DATA_HNDL_CLOSE);
  110.                     WritePackCell(vPosition, iCurrentWeapon);
  111.                     WritePackCell(vPosition, client);
  112.                 }
  113.             }
  114.             else if (!(buttons & IN_USE))
  115.             {
  116.                 if(IsFucked[client])
  117.                 {
  118.                     if(EndLoadBar[client] != null)
  119.                     {
  120.                         KillTimer(EndLoadBar[client])
  121.                         EndLoadBar[client] = null
  122.                     }
  123.                 }
  124.                 SetEntPropFloat(client, Prop_Send, "m_flProgressBarStartTime", 0.0);
  125.                 SetEntPropFloat(client, Prop_Send, "m_flProgressBarDuration", 0.0);
  126.             }
  127.         }
  128.     }
  129.     return Plugin_Continue;
  130. }
  131.  
  132. public Action EndBar(Handle timer, Handle vPosition)
  133. {
  134.     ResetPack(vPosition);
  135.    
  136.     int iCurrentWeapon = ReadPackCell(vPosition);
  137.     int client = ReadPackCell(vPosition);
  138.    
  139.     SetEntPropFloat(client, Prop_Send, "m_flProgressBarStartTime", 0.0);
  140.     SetEntPropFloat(client, Prop_Send, "m_flProgressBarDuration", 0.0);
  141.     IsFucked[client] = false;
  142.     PrintHintText(client, "Отклинило)))");
  143.     SetEntPropFloat(client, Prop_Send, "m_flNextAttack", 0.0);
  144.     SetEntPropFloat(iCurrentWeapon, Prop_Send, "m_flNextPrimaryAttack", 0.0);
  145. }
  146.  
  147. stock bool bIsSurvivor(int client)
  148. {
  149.     return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
  150. }
Advertisement
Add Comment
Please, Sign In to add comment