Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include sdktools
- #include sdkhooks
- new bool:IsFucked[MAXPLAYERS+1] = false;
- float LastMessage[MAXPLAYERS+1];
- Handle EndLoadBar[MAXPLAYERS+1];
- int Shots[MAXPLAYERS+1];
- public OnPluginStart()
- {
- HookEvent("weapon_fire", FireBulletsPost)
- }
- public OnMapStart()
- {
- for (new i = 1; i <= MaxClients; i++)
- {
- IsFucked[i] = false;
- LastMessage[i] = 0.0;
- Shots[i] = 0;
- EndLoadBar[i] = null;
- }
- }
- public OnClientPutInServer(client)
- {
- SDKHook(client, SDKHook_WeaponCanUse, WeaponCanUse);
- }
- public OnClientDisconnect(client)
- {
- SDKUnhook(client, SDKHook_WeaponCanUse, WeaponCanUse);
- if (EndLoadBar[client] != null)
- {
- KillTimer(EndLoadBar[client]);
- EndLoadBar[client] = null;
- }
- }
- public Action:WeaponCanUse(client, weapon)
- {
- if(bIsSurvivor(client) && !IsFakeClient(client))
- {
- if(IsFucked[client])
- {
- new String:sClassName[64];
- GetEntityClassname(weapon, sClassName, sizeof(sClassName));
- 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"))
- {
- return Plugin_Handled;
- }
- }
- }
- return Plugin_Continue;
- }
- public Action FireBulletsPost(Event event, const char[] name, bool dontBroadcast)
- {
- int client = GetClientOfUserId(event.GetInt("userid"));
- new vSlot = GetPlayerWeaponSlot(client, 0);
- int iCurrentWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
- if(iCurrentWeapon == vSlot)
- {
- if(bIsSurvivor(client) && !IsFakeClient(client))
- {
- if(!IsFucked[client])
- {
- if(Shots[client] > 125)
- {
- if(GetRandomInt(0, 100) < 100)
- {
- IsFucked[client] = true;
- PrintToChat(client, "Ваше оружие заклинило")
- }
- Shots[client] = 0;
- }
- Shots[client]++
- }
- }
- }
- }
- public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3], float angles[3], int& weapon)
- {
- if(IsFucked[client])
- {
- new vSlot = GetPlayerWeaponSlot(client, 0);
- int iCurrentWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
- if(iCurrentWeapon == vSlot)
- {
- if(buttons & IN_ATTACK)
- {
- if((GetEngineTime() - LastMessage[client]) > 30)
- {
- PrintHintText(client, "Дурак? Заклинила пушка, нажми Е!");
- LastMessage[client] = GetEngineTime();
- }
- SetEntPropFloat(client, Prop_Send, "m_flNextAttack", 9999.0);
- SetEntPropFloat(iCurrentWeapon, Prop_Send, "m_flNextPrimaryAttack", 9999.0);
- }
- else if(buttons & IN_USE)
- {
- if(EndLoadBar[client] == null)
- {
- SetEntPropFloat(client, Prop_Send, "m_flProgressBarStartTime", GetGameTime());
- SetEntPropFloat(client, Prop_Send, "m_flProgressBarDuration", 3.0);
- new Handle:vPosition;
- EndLoadBar[client] = CreateDataTimer(3.0, EndBar, vPosition, TIMER_DATA_HNDL_CLOSE);
- WritePackCell(vPosition, iCurrentWeapon);
- WritePackCell(vPosition, client);
- }
- }
- else if (!(buttons & IN_USE))
- {
- if(IsFucked[client])
- {
- if(EndLoadBar[client] != null)
- {
- KillTimer(EndLoadBar[client])
- EndLoadBar[client] = null
- }
- }
- SetEntPropFloat(client, Prop_Send, "m_flProgressBarStartTime", 0.0);
- SetEntPropFloat(client, Prop_Send, "m_flProgressBarDuration", 0.0);
- }
- }
- }
- return Plugin_Continue;
- }
- public Action EndBar(Handle timer, Handle vPosition)
- {
- ResetPack(vPosition);
- int iCurrentWeapon = ReadPackCell(vPosition);
- int client = ReadPackCell(vPosition);
- SetEntPropFloat(client, Prop_Send, "m_flProgressBarStartTime", 0.0);
- SetEntPropFloat(client, Prop_Send, "m_flProgressBarDuration", 0.0);
- IsFucked[client] = false;
- PrintHintText(client, "Отклинило)))");
- SetEntPropFloat(client, Prop_Send, "m_flNextAttack", 0.0);
- SetEntPropFloat(iCurrentWeapon, Prop_Send, "m_flNextPrimaryAttack", 0.0);
- }
- stock bool bIsSurvivor(int client)
- {
- return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
- }
Advertisement
Add Comment
Please, Sign In to add comment