Can someone test this plugin if its working correctly?
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <cstrike>
#define NO_FLASH_DURATION 0.0
float g_FlashDuration[MAXPLAYERS + 1];
public void OnPluginStart()
{
HookEvent("flashbang_detonate", Event_FlashbangDetonate);
}
public void Event_FlashbangDetonate(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(event.GetInt("userid"));
if (!client || !IsClientInGame(client))
{
return;
}
GetFlashDurations(client);
RequestFrame(SetFlashDurations);
}
void GetFlashDurations(int thrower)
{
int teamThrower = GetClientTeam(thrower);
// Anti flash alive teammates
for (int i = 1; i <= MaxClients; i++)
{
g_FlashDuration[i] = NO_FLASH_DURATION;
if (i == thrower || !IsClientInGame(i) || !IsPlayerAlive(i) || GetClientTeam(i) != teamThrower)
{
continue;
}
g_FlashDuration[i] = GetEntPropFloat(i, Prop_Send, "m_flFlashDuration");
}
// The spectators will see exactly what the player that they are spectating sees
for (int i = 1; i <= MaxClients; i++)
{
if (!IsClientInGame(i) || !IsClientObserver(i))
{
continue;
}
int specTarget = GetEntPropEnt(i, Prop_Send, "m_hObserverTarget");
if (specTarget == -1)
{
continue;
}
g_FlashDuration[i] = g_FlashDuration[specTarget];
}
}
void SetFlashDurations(any data)
{
for (int i = 1; i <= MaxClients; i++)
{
if (!IsClientInGame(i) || g_FlashDuration[i] == NO_FLASH_DURATION)
{
continue;
}
SetEntPropFloat(i, Prop_Send, "m_flFlashDuration", g_FlashDuration[i]);
}
}
I don't have a server (with players) to test it. It should anti flash alive teammates. The spectators will see exactly what the player that they are spectating sees (if the player is flashed they will be flashed etc).
If the my teammate was flashed by the enemy and then i flash him, my teammate will be still flashed by the enemy flash. I've seen that currently anti flash plugins doesn't have this feature, thats why i wrote it ...
__________________