View Single Post
Author Message
Tetradox
Junior Member
Join Date: Aug 2016
Old 02-21-2017 , 20:54   Kill Streak Tracker With FireEvent? (Halp)
Reply With Quote #1

Hello, i saw SHADoW93's streaker plugin but i figured out it lacked the killtreak notification for every 5 kills at the top of the screen, so i tried to do something about it changing the code a bit, but there is a problem with it, here it is if you want to c it:

Code:
#pragma semicolon 1

#include <sourcemod>
#include <freak_fortress_2>

new LastKSCount[MAXPLAYERS+1];
new streak[MAXPLAYERS+1];
new Handle:DeathEvent;

new Handle:cvarKStreakDmg;

public void OnPluginStart()
{	
	cvarKStreakDmg=CreateConVar("streaker_kstreak_dmg", "200", "Damage required to increase the killstreak counter", FCVAR_PLUGIN);
}

stock bool IsValidClient(int client)
{
	if (client <= 0 || client > MaxClients) return false;
	if (!IsClientInGame(client) || !IsClientConnected(client)) return false;
	if (IsClientSourceTV(client) || IsClientReplay(client) || IsFakeClient(client)) return false;
	return true;
}

public OnGameFrame()
{
	for(new client = 1; client <= MaxClients; client++)
	{
		if (GetClientTeam(client)!=FF2_GetBossTeam() && IsValidClient(client) && IsClientInGame(client)) 
		{
			streak[client]=((FF2_GetClientDamage(client)/GetConVarInt(cvarKStreakDmg)) - ((FF2_GetClientDamage(client) % GetConVarInt(cvarKStreakDmg))/GetConVarInt(cvarKStreakDmg)));		
			if (streak[client]>0) 
			{
				DeathEvent = CreateEvent("player_death");
				SetEntProp(client, Prop_Send, "m_nStreaks", streak[client]);	
				SetEventInt(DeathEvent, "kill_streak_total", streak[client]);
				SetEventInt(DeathEvent, "kill_streak_wep", streak[client]);		
				SetEventInt(DeathEvent, "attacker", client);
			}
		
			if(streak[client] % 5 == 0 && LastKSCount[client]!=streak[client])
			{
				FireEvent(DeathEvent);
				LastKSCount[client]=streak[client];
			}		
		}
	}
	for(new boss; FF2_GetBossUserId(boss)!=-1; boss++)
	{
		new clboss=GetClientOfUserId(FF2_GetBossUserId(boss));
		SetEventInt(DeathEvent, "userid", clboss);
	}
}
The problem with this is that when the event is fired the boss instantly dies, is there a way to get the ks notification to work without this happening? It would be grateful if you could help me
Tetradox is offline