Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sourcemod>
- #include <sdktools>
- #include sdkhooks
- static killcount[MAXPLAYERS+1], IsAllowToEquip[MAXPLAYERS+1] = false;
- static IndexWp[MAXPLAYERS+1][2];
- static Handle:hCount = INVALID_HANDLE;
- static bool:NoDoubleEventFire;
- public OnPluginStart()
- {
- HookEvent("infected_death", hGiveAwp);
- HookEvent("round_start", RoundStartEvent);
- hCount = CreateConVar("l4d2_specialammo_killcountsetting", "5", "How much Infected a Player has to shoot to win special ammo. (default 120) ", FCVAR_NONE);
- AutoExecConfig(true, "l4d2_specialammo"); // an autoexec! ooooh shiny
- }
- public Action:RoundStartEvent(Handle:event, const String:name[], bool:dontBroadcast)
- {
- for (new i = 1; i <= MaxClients; i++)
- {
- killcount[i] = 0;
- }
- }
- public OnClientPutInServer(client)
- {
- SDKHook(client, SDKHook_WeaponCanUse, WeaponCanUse);
- }
- public Action:WeaponCanUse(client, weapon)
- {
- if(bIsSurvivor(client))
- {
- new wepn = GetPlayerWeaponSlot(client, 1)
- if (!IsValidEntity(wepn))
- {
- return Plugin_Continue;
- }
- decl String:sWeaponExM[32];
- GetEntityClassname(wepn, sWeaponExM, sizeof(sWeaponExM));
- if(StrEqual(sWeaponExM, "weapon_sniper_awp"))
- {
- IndexWp[client][1] = wepn
- }
- new String:sWeaponEx[64];
- GetEntityClassname(weapon, sWeaponEx, sizeof(sWeaponEx));
- if(StrEqual(sWeaponEx, "weapon_sniper_awp") && IndexWp[client][1] != weapon)
- {
- if(!IsAllowToEquip[client])
- {
- return Plugin_Handled;
- }
- }
- }
- return Plugin_Continue;
- }
- public OnClientDisconnect(client)
- {
- killcount[client] = 0;
- }
- public OnClientPostAdminCheck(client)
- {
- killcount[client] = 0;
- }
- public Action:hGiveAwp(Handle:event, String:ename[], bool:dontBroadcast)
- {
- if (NoDoubleEventFire) return Plugin_Continue;
- new client = GetClientOfUserId(GetEventInt(event, "attacker"));
- new bool:minigun = GetEventBool(event, "minigun");
- new bool:blast = GetEventBool(event, "blast");
- if (client)
- {
- if (!minigun && !blast)
- killcount[client] += 1;
- else
- {
- NoDoubleEventFire = false;
- return Plugin_Continue;
- }
- if ((killcount[client] > GetConVarInt(hCount)))
- {
- if(IsClientInGame(client) && GetClientTeam(client) == 2)
- {
- IsAllowToEquip[client] = true;
- killcount[client] = 0;
- GiveFunction(client, "sniper_awp");
- IsAllowToEquip[client] = false;
- }
- }
- }
- NoDoubleEventFire = false;
- return Plugin_Continue;
- }
- stock bool bIsSurvivor(int client)
- {
- return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && !IsFakeClient(client) && IsPlayerAlive(client);
- }
- void GiveFunction(int client, char[] name)
- {
- char sBuf[32];
- int flags = GetCommandFlags("give");
- SetCommandFlags("give", flags & ~FCVAR_CHEAT);
- FormatEx(sBuf, sizeof sBuf, "give %s", name);
- FakeClientCommand(client, sBuf);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement