FlacoBey

Untitled

Feb 21st, 2019
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.00 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("vChancePistol", "25", "Шанс того что оружия заклинит от 0 до 100");
  16.     hCountOfShots = CreateConVar("vShotsPistol", "25", "Кол-во выстрелов для срабатывания шанса");
  17.     hTimerOfOutKlin = CreateConVar("vTimePistol", "20.0", "Время расклина(желательно ставить флоат(20.0)");
  18.    
  19.     AutoExecConfig(true, "KlinikaWeaponPistols");
  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, 1);
  56.     int iCurrentWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
  57.     char sWeaponEx[32]
  58.     GetEntityClassname(iCurrentWeapon, sWeaponEx, sizeof(sWeaponEx))
  59.    
  60.     if(iCurrentWeapon == vSlot)
  61.     {
  62.         if(bIsSurvivor(client) && !IsFakeClient(client))
  63.         {
  64.             if(!IsFucked[iCurrentWeapon])
  65.             {
  66.                 if(Shots[client] > GetConVarInt(hCountOfShots))
  67.                 {
  68.                     if(GetRandomInt(0, 100) < GetConVarInt(hChanceOfKlin))
  69.                     {
  70.                         IsFucked[iCurrentWeapon] = true;
  71.                         ref[iCurrentWeapon] = EntIndexToEntRef(iCurrentWeapon)
  72.                         if(StrEqual(sWeaponEx, "weapon_magnum"))
  73.                         {
  74.                             PrintToChat(client, "Ваш магнум заклинил, зажмите E")
  75.                         }
  76.                         else
  77.                         {
  78.                             PrintToChat(client, "Ваше оружие заклинило, зажмите E")
  79.                         }
  80.                     }
  81.                     Shots[client] = 0;
  82.                 }
  83.                 Shots[client]++
  84.             }
  85.         }
  86.     }
  87. }
  88.  
  89. public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3], float angles[3], int& weapon)
  90. {
  91.     new vSlot = GetPlayerWeaponSlot(client, 1);
  92.     if(!IsValidEntity(vSlot))
  93.     {
  94.         return Plugin_Continue;
  95.     }
  96.     int iCurrentWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
  97.     new FuckedWeapon = EntRefToEntIndex(ref[iCurrentWeapon])
  98.     if(FuckedWeapon == iCurrentWeapon)
  99.     {
  100.         if(IsFucked[FuckedWeapon])
  101.         {
  102.             if(buttons & IN_ATTACK)
  103.             {
  104.                 SetEntPropFloat(client, Prop_Send, "m_flNextAttack", 99999.0);
  105.                 SetEntPropFloat(iCurrentWeapon, Prop_Send, "m_flNextPrimaryAttack", 99999.0);
  106.             }
  107.             else if(buttons & IN_USE)
  108.             {
  109.                 if(EndLoadBar[client] == INVALID_HANDLE)
  110.                 {
  111.                     SetEntPropFloat(client, Prop_Send, "m_flProgressBarStartTime", GetGameTime());
  112.                     SetEntPropFloat(client, Prop_Send, "m_flProgressBarDuration", GetConVarFloat(hTimerOfOutKlin));
  113.                     new Handle:vPosition;
  114.                     EndLoadBar[client] = CreateDataTimer(GetConVarFloat(hTimerOfOutKlin), EndBar, vPosition, TIMER_REPEAT | TIMER_DATA_HNDL_CLOSE);
  115.                     WritePackCell(vPosition, FuckedWeapon);
  116.                     WritePackCell(vPosition, client);
  117.                 }
  118.             }
  119.             else if (!(buttons & IN_USE))
  120.             {
  121.                 if(EndLoadBar[client] != INVALID_HANDLE)
  122.                 {
  123.                     KillTimer(EndLoadBar[client])
  124.                     EndLoadBar[client] = INVALID_HANDLE
  125.                 }
  126.                 SetEntPropFloat(client, Prop_Send, "m_flProgressBarStartTime", 0.0);
  127.                 SetEntPropFloat(client, Prop_Send, "m_flProgressBarDuration", 0.0);
  128.             }
  129.         }
  130.         else
  131.         {
  132.             if(EndLoadBar[client] != INVALID_HANDLE)
  133.             {
  134.                 KillTimer(EndLoadBar[client])
  135.                 EndLoadBar[client] = INVALID_HANDLE
  136.                 SetEntPropFloat(client, Prop_Send, "m_flProgressBarStartTime", 0.0);
  137.                 SetEntPropFloat(client, Prop_Send, "m_flProgressBarDuration", 0.0);
  138.             }
  139.         }
  140.     }
  141.     return Plugin_Continue;
  142. }
  143.  
  144. public Action EndBar(Handle timer, Handle vPosition)
  145. {
  146.     ResetPack(vPosition);
  147.    
  148.     int IsFuck = ReadPackCell(vPosition);
  149.     int client = ReadPackCell(vPosition);
  150.    
  151.     SetEntPropFloat(client, Prop_Send, "m_flProgressBarStartTime", 0.0);
  152.     SetEntPropFloat(client, Prop_Send, "m_flProgressBarDuration", 0.0);
  153.     IsFucked[IsFuck] = false;
  154.     SetEntPropFloat(client, Prop_Send, "m_flNextAttack", 0.0);
  155.     SetEntPropFloat(IsFuck, Prop_Send, "m_flNextPrimaryAttack", 0.0);
  156.     KillTimer(EndLoadBar[client])
  157.     EndLoadBar[client] = INVALID_HANDLE
  158. }
  159.  
  160. stock bool bIsSurvivor(int client)
  161. {
  162.     return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
  163. }
Advertisement
Add Comment
Please, Sign In to add comment