FlacoBey

Untitled

Feb 21st, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.97 KB | None | 0 0
  1. #include sdktools
  2. #include sdkhooks
  3.  
  4. new bool:IsFucked[2048+1] = false;
  5. //float LastMessage[MAXPLAYERS+1];
  6. new ref[2048+1];
  7. Handle EndLoadBar[MAXPLAYERS+1];
  8. int Shots[MAXPLAYERS+1];
  9.  
  10. ConVar hChanceOfKlin, hCountOfShots, hTimerOfOutKlin;
  11.  
  12. public OnPluginStart()
  13. {
  14.     HookEvent("weapon_fire", FireBulletsPost)
  15.     hChanceOfKlin = CreateConVar("vChance", "25", "Шанс того что оружия заклинит от 0 до 100");
  16.     hCountOfShots = CreateConVar("vShots", "25", "Кол-во выстрелов для срабатывания шанса");
  17.     hTimerOfOutKlin = CreateConVar("vTime", "20.0", "Время расклина(желательно ставить флоат(20.0)");
  18.    
  19.     AutoExecConfig(true, "KlinikaWeapon");
  20. }
  21.  
  22. public OnClientPutInServer(client)
  23. {
  24.     SDKHook(client, SDKHook_WeaponCanUse, WeaponCanUse);
  25. }
  26.  
  27. public OnClientDisconnect(client)
  28. {
  29.     SDKUnhook(client, SDKHook_WeaponCanUse, WeaponCanUse);
  30.     if (EndLoadBar[client] != null)
  31.     {
  32.         KillTimer(EndLoadBar[client]);
  33.         EndLoadBar[client] = null;
  34.     }
  35. }
  36.  
  37. public Action:WeaponCanUse(client, weapon)
  38. {
  39.     if(bIsSurvivor(client))
  40.     {
  41.         if(EndLoadBar[client] != INVALID_HANDLE)
  42.         {
  43.             KillTimer(EndLoadBar[client])
  44.             EndLoadBar[client] = INVALID_HANDLE
  45.         }
  46.         SetEntPropFloat(client, Prop_Send, "m_flProgressBarStartTime", 0.0);
  47.         SetEntPropFloat(client, Prop_Send, "m_flProgressBarDuration", 0.0);
  48.     }
  49.     return Plugin_Continue;
  50. }
  51. public Action FireBulletsPost(Event event, const char[] name, bool dontBroadcast)
  52. {
  53.     int client = GetClientOfUserId(event.GetInt("userid"));
  54.    
  55.     new vSlot = GetPlayerWeaponSlot(client, 0);
  56.     int iCurrentWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
  57.     char sWeaponEx[32]
  58.     GetEntityClassname(iCurrentWeapon, sWeaponEx, sizeof(sWeaponEx))
  59.    
  60.     if(!(StrEqual(sWeaponEx, "weapon_sniper_awp") || StrEqual(sWeaponEx, "weapon_sniper_scout")))
  61.     {
  62.         if(iCurrentWeapon == vSlot)
  63.         {
  64.             if(bIsSurvivor(client) && !IsFakeClient(client))
  65.             {
  66.                 if(!IsFucked[iCurrentWeapon])
  67.                 {
  68.                     if(Shots[client] > GetConVarInt(hCountOfShots))
  69.                     {
  70.                         if(GetRandomInt(0, 100) < GetConVarInt(hChanceOfKlin))
  71.                         {
  72.                             IsFucked[iCurrentWeapon] = true;
  73.                             ref[iCurrentWeapon] = EntIndexToEntRef(iCurrentWeapon)
  74.                             PrintToChat(client, "Ваше оружие заклинило, нажмите Shift + E, чтобы пофиксить это дерьмо.")
  75.                         }
  76.                         Shots[client] = 0;
  77.                     }
  78.                     Shots[client]++
  79.                 }
  80.             }
  81.         }
  82.     }
  83. }
  84.  
  85. public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3], float angles[3], int& weapon)
  86. {
  87.     new vSlot = GetPlayerWeaponSlot(client, 0);
  88.     if(!IsValidEntity(vSlot))
  89.     {
  90.         return Plugin_Continue;
  91.     }
  92.     int iCurrentWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
  93.     new FuckedWeapon = EntRefToEntIndex(ref[iCurrentWeapon])
  94.     if(FuckedWeapon == iCurrentWeapon)
  95.     {
  96.         if(IsFucked[FuckedWeapon])
  97.         {
  98.             if(buttons & IN_ATTACK)
  99.             {
  100.                 SetEntPropFloat(client, Prop_Send, "m_flNextAttack", 99999.0);
  101.                 SetEntPropFloat(iCurrentWeapon, Prop_Send, "m_flNextPrimaryAttack", 99999.0);
  102.             }
  103.             else if(buttons & IN_USE)
  104.             {
  105.                 if(EndLoadBar[client] == INVALID_HANDLE)
  106.                 {
  107.                     SetEntPropFloat(client, Prop_Send, "m_flProgressBarStartTime", GetGameTime());
  108.                     SetEntPropFloat(client, Prop_Send, "m_flProgressBarDuration", GetConVarFloat(hTimerOfOutKlin));
  109.                     new Handle:vPosition;
  110.                     EndLoadBar[client] = CreateDataTimer(GetConVarFloat(hTimerOfOutKlin), EndBar, vPosition, TIMER_REPEAT | TIMER_DATA_HNDL_CLOSE);
  111.                     WritePackCell(vPosition, FuckedWeapon);
  112.                     WritePackCell(vPosition, client);
  113.                 }
  114.             }
  115.             else if (!(buttons & IN_USE))
  116.             {
  117.                 if(EndLoadBar[client] != INVALID_HANDLE)
  118.                 {
  119.                     KillTimer(EndLoadBar[client])
  120.                     EndLoadBar[client] = INVALID_HANDLE
  121.                 }
  122.                 SetEntPropFloat(client, Prop_Send, "m_flProgressBarStartTime", 0.0);
  123.                 SetEntPropFloat(client, Prop_Send, "m_flProgressBarDuration", 0.0);
  124.             }
  125.         }
  126.         else
  127.         {
  128.             if(EndLoadBar[client] != INVALID_HANDLE)
  129.             {
  130.                 KillTimer(EndLoadBar[client])
  131.                 EndLoadBar[client] = INVALID_HANDLE
  132.                 SetEntPropFloat(client, Prop_Send, "m_flProgressBarStartTime", 0.0);
  133.                 SetEntPropFloat(client, Prop_Send, "m_flProgressBarDuration", 0.0);
  134.             }
  135.         }
  136.     }
  137.     return Plugin_Continue;
  138. }
  139.  
  140. public Action EndBar(Handle timer, Handle vPosition)
  141. {
  142.     ResetPack(vPosition);
  143.    
  144.     int IsFuck = ReadPackCell(vPosition);
  145.     int client = ReadPackCell(vPosition);
  146.    
  147.     SetEntPropFloat(client, Prop_Send, "m_flProgressBarStartTime", 0.0);
  148.     SetEntPropFloat(client, Prop_Send, "m_flProgressBarDuration", 0.0);
  149.     IsFucked[IsFuck] = false;
  150.     SetEntPropFloat(client, Prop_Send, "m_flNextAttack", 0.0);
  151.     SetEntPropFloat(IsFuck, Prop_Send, "m_flNextPrimaryAttack", 0.0);
  152.     KillTimer(EndLoadBar[client])
  153.     EndLoadBar[client] = INVALID_HANDLE
  154. }
  155.  
  156. stock bool bIsSurvivor(int client)
  157. {
  158.     return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
  159. }
Advertisement
Add Comment
Please, Sign In to add comment