#pragma semicolon 1
#pragma newdecls required
#include <sdktools_stringtables>
#include <cstrike>
Handle
hOverlay_t,
hOverlay_ct;
char
sOverlay_t[256],
sOverlay_ct[256];
public Plugin myinfo =
{
name = "Round end overlay",
author = "dataviruset (rewritten by Nek.'a 2x2 | ggwp.site )",
description = "Оверлей в конце раунда",
version = "1.2",
url = "http://www.sourcemod.net/"
};
public void OnPluginStart()
{
hOverlay_t = CreateConVar("sm_roundend_overlay_t", "overlays/game77seven/t_win", "Оверлей победы террористов");
GetConVarString(hOverlay_t, sOverlay_t, sizeof(sOverlay_t));
HookConVarChange(hOverlay_t, OnConVarChangeOverlayT);
hOverlay_ct = CreateConVar("sm_roundend_overlay_ct", "overlays/game77seven/ct_win", "Оверлей победы контр-террористов");
GetConVarString(hOverlay_ct, sOverlay_ct, sizeof(sOverlay_ct));
HookConVarChange(hOverlay_ct, OnConVarChangeOverlayCT);
AutoExecConfig(true, "overlay_end");
HookEvent("round_start", Event_RoundStart);
HookEvent("round_end", Event_RoundEnd);
}
public void OnConVarChangeOverlayT(ConVar CVar, const char[] oldValue, const char[] newValue)
{
if(hOverlay_t) strcopy(sOverlay_t, sizeof(sOverlay_t), newValue);
}
public void OnConVarChangeOverlayCT(ConVar CVar, const char[] oldValue, const char[] newValue)
{
if(hOverlay_ct) strcopy(sOverlay_ct, sizeof(sOverlay_ct), newValue);
}
public void OnMapStart()
{
char sBuffer_t[256], sBuffer_ct[256];
Format(sBuffer_t, sizeof(sBuffer_t), "materials/%s.vmt", sOverlay_t);
AddFileToDownloadsTable(sBuffer_t);
Format(sBuffer_t, sizeof(sBuffer_t), "materials/%s.vtf", sOverlay_t);
AddFileToDownloadsTable(sBuffer_t);
FormatEx(sBuffer_ct, sizeof(sBuffer_ct), "materials/%s.vmt", sOverlay_ct);
AddFileToDownloadsTable(sBuffer_ct);
FormatEx(sBuffer_ct, sizeof(sBuffer_ct), "materials/%s.vtf", sOverlay_ct);
AddFileToDownloadsTable(sBuffer_ct);
}
void ShowOverlayToAll(const char[] sOverlayPath)
{
for(int iClient = 1; iClient <= MaxClients; iClient++)
{
if (IsClientInGame(iClient) && !IsFakeClient(iClient))
{
ShowOverlayToClient(iClient, sOverlayPath);
}
}
}
public void Event_RoundEnd(Handle event, const char[] name, bool dontBroadcast)
{
int winner_team = GetEventInt(event, "winner");
char sOverlayPath[PLATFORM_MAX_PATH];
if (winner_team == CS_TEAM_T)
{
GetConVarString(hOverlay_t, sOverlayPath, sizeof(sOverlayPath));
ShowOverlayToAll(sOverlayPath);
}
else if (winner_team == CS_TEAM_CT)
{
GetConVarString(hOverlay_ct, sOverlayPath, sizeof(sOverlayPath));
ShowOverlayToAll(sOverlayPath);
}
}
void ShowOverlayToClient(int client, const char[] sOverlayPath)
{
ClientCommand(client, "r_screenoverlay \"%s\"", sOverlayPath);
}
public void Event_RoundStart(Handle event, const char[] name, bool dontBroadcast)
{
ShowOverlayToAll("");
}