Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include sdktools
- #include sdkhooks
- ConVar dark, iKills;
- new bool:IsKilled[2048+1] = false;
- int ref[2048+1];
- int iKill[MAXPLAYERS+1];
- public OnPluginStart()
- {
- dark = CreateConVar("melee_chance", "25", "Chance", FCVAR_NONE);
- iKills = CreateConVar("melee_kills", "50", "Number of kills to trigger the chance.", FCVAR_NONE);
- HookEvent("infected_death", InKill);
- HookEvent("infected_hurt", Mind, EventHookMode_Pre);
- HookEvent("player_death", InDeath);
- }
- public OnClientPutInServer(client)
- {
- SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
- }
- public OnClientDisconnect(client)
- {
- SDKUnhook(client, SDKHook_OnTakeDamage, OnTakeDamage);
- }
- public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype)
- {
- if (IsValidInfected(victim))
- {
- if(bIsSurvivor(attacker) && !IsFakeClient(attacker))
- {
- int iCurrentWeapon = GetEntPropEnt(attacker, Prop_Send, "m_hActiveWeapon");
- new NotWeapon = EntRefToEntIndex(ref[iCurrentWeapon])
- if(IsKilled[NotWeapon])
- {
- damage = 0.0;
- return Plugin_Changed;
- }
- }
- }
- return Plugin_Continue;
- }
- public Action InKill(Event event, const char[] name, bool dontBroadcast)
- {
- //int XD = GetClientOfUserId(event.GetInt("infected_id"));
- int client = GetClientOfUserId(event.GetInt("attacker"));
- if(bIsSurvivor(client) && !IsFakeClient(client))
- {
- new vSlot = GetPlayerWeaponSlot(client, 1);
- int iCurrentWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
- char sWeaponEx[32]
- GetEntityClassname(iCurrentWeapon, sWeaponEx, sizeof(sWeaponEx))
- if(iCurrentWeapon == vSlot)
- {
- if(StrEqual(sWeaponEx, "weapon_melee"))
- {
- if(!IsKilled[iCurrentWeapon])
- {
- if(iKill[client] >= GetConVarInt(iKills))
- {
- if(GetRandomInt(0, 100) < GetConVarInt(dark))
- {
- IsKilled[iCurrentWeapon] = true;
- ref[iCurrentWeapon] = EntIndexToEntRef(iCurrentWeapon)
- PrintToChat(client, "Ваша рукпоашка откинулась.")
- }
- iKill[client] = 0;
- }
- iKill[client]++
- }
- }
- }
- }
- }
- public Action Mind(Handle:event, const String:name[], bool:dontBroadcast)
- {
- new client = GetClientOfUserId(GetEventInt(event, "attacker"));
- new Idiot = GetEventInt(event, "entityid");
- if(bIsSurvivor(client) && !IsFakeClient(client))
- {
- int iCurrentWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
- new NotWeapon = EntRefToEntIndex(ref[iCurrentWeapon])
- if(IsKilled[NotWeapon])
- {
- new Hada = GetEventInt(event,"amount");
- new blood = GetEntProp(Idiot, Prop_Data, "m_iHealth");
- new twillight = Hada + blood;
- SetEntProp(Idiot, Prop_Data, "m_iHealth", twillight++);
- SetEventInt(event, "amount", 0);
- }
- }
- }
- public Action InDeath(Event event, const char[] name, bool dontBroadcast)
- {
- int client = GetClientOfUserId(event.GetInt("attacker"));
- if(bIsSurvivor(client) && !IsFakeClient(client))
- {
- new vSlot = GetPlayerWeaponSlot(client, 1);
- int iCurrentWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
- char sWeaponEx[32]
- GetEntityClassname(iCurrentWeapon, sWeaponEx, sizeof(sWeaponEx))
- if(iCurrentWeapon == vSlot)
- {
- if(StrEqual(sWeaponEx, "weapon_melee"))
- {
- if(!IsKilled[iCurrentWeapon])
- {
- if(iKill[client] >= GetConVarInt(iKills))
- {
- if(GetRandomInt(0, 100) < GetConVarInt(dark))
- {
- IsKilled[iCurrentWeapon] = true;
- ref[iCurrentWeapon] = EntIndexToEntRef(iCurrentWeapon)
- PrintToChat(client, "Ваша рукпоашка откинулась.")
- }
- iKill[client] = 0;
- }
- iKill[client]++
- }
- }
- }
- }
- }
- stock bool:IsValidInfected( client )
- {
- if ( client < 1 || client > MaxClients ) return false;
- if ( !IsClientConnected( client )) return false;
- if ( !IsClientInGame( client )) return false;
- if ( GetClientTeam( client ) != 3 ) return false;
- return true;
- }
- 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
Advertisement