public Plugin myinfo =
{
name = "Panorama timeLeft",
description = "Отображение времени до конца карты",
author = "Phoenix (˙·٠●Феникс●٠·˙)",
version = "1.0.0",
url = "zizt.ru hlmod.ru"
};
bool g_bPanorama[MAXPLAYERS + 1];
public void ClientConVar(QueryCookie hCookie, int iClient, ConVarQueryResult hResult, const char[] sCvarName, const char[] sCvarValue)
{
if(hResult == ConVarQuery_Okay) g_bPanorama[iClient] = true; // Использует
}
public void OnClientDisconnect(int iClient)
{
g_bPanorama[iClient] = false;
}
public void OnClientPutInServer(int iClient)
{
QueryClientConVar(iClient, "@panorama_debug_overlay_opacity", ClientConVar);
}
public void OnMapStart()
{
CreateTimer(1.0, Timer_UPDATE, _, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
}
public Action Timer_UPDATE(Handle timer)
{
int timeleft;
char sBuf[255];
GetMapTimeLeft(timeleft);
if(timeleft > 0) FormatEx(sBuf, sizeof sBuf, "До конца карты - %d:%02d", timeleft / 60, timeleft % 60);
else sBuf = "Последний раунд";
SetHudTextParams(-1.0, 0.99, 1.5, 0, 255, 255, 0);
for(int iClient = 1; iClient <= MaxClients; iClient++)
{
if(g_bPanorama[iClient] && ( GetClientButtons(iClient) & IN_SCORE) )
{
Format(sBuf,sizeof sBuf, "%s\n%d Spectators",sBuf,SpecTimer(iClient));
ShowHudText(iClient, 4, sBuf);
}
}
return Plugin_Continue;
}
stock int SpecTimer(int client)
{
int target = 0;
if ( !IsPlayerAlive( client ) )
{
int newtarget = GetClientObserverTarget( client );
if ( 0 < newtarget && newtarget <= MaxClients
&& IsClientInGame( newtarget )
&& IsPlayerAlive( newtarget )
&& GetClientObserverMode( client ) != 6)
{
target = newtarget;
}
}
else
{
target = client;
}
if ( !target ) return 0;
int num;
for ( int i = 1; i <= MaxClients; i++ )
{
if ( i == target ) continue;
if ( !IsClientInGame( i ) ) continue;
if ( IsFakeClient( i ) ) continue;
if ( IsPlayerAlive( i ) ) continue;
if ( GetClientObserverTarget( i ) == target && GetClientObserverMode( client ) != 6 )
++num;
}
return num;
}
stock int GetClientObserverMode( int client )
{
return GetEntProp( client, Prop_Send, "m_iObserverMode" );
}
stock int GetClientObserverTarget( int client )
{
return GetEntPropEnt( client, Prop_Send, "m_hObserverTarget" );
}