Hey,
I tried to find / code a plugin that would replace the CT Win or T Win banner that shows on the screen to something like this (I've seen this already in some servers):
https://i.imgur.com/ToKtKFo.png
I tried a lot of plugins. Even tried and changed the one provided by kento but didn't work.
The current source code is:
PHP Code:
#include <sourcemod>
#include <sdktools>
#pragma newdecls required
ConVar Cvar_Time, CT_Overlay, T_Overlay;
char ct_overlay[PLATFORM_MAX_PATH], t_overlay[PLATFORM_MAX_PATH];
float overlay_time;
public Plugin myinfo =
{
name = "[SpirT] Round Draw Overlay",
author = "SpirT",
description = "Display overlay when round draw.",
version = "1.0",
url = "http://steamcommunity.com/id/spirtbbx/"
};
public void OnPluginStart()
{
HookEvent("round_end", Event_RoundEnd);
Cvar_Time = CreateConVar("sm_overlay_time", "7.0", "How long should overlay display?");
CT_Overlay = CreateConVar("sm_overlay_t", "path/to/file", "Overlay when Terrorists win! Path to file without materials/ and without .vtf or .vmt extension");
T_Overlay = CreateConVar("sm_overlay_ct", "path/to/file", "Overlay when Counter-Terrorists win! Path to file without materials/ and without .vtf or .vmt extension");
AutoExecConfig(true, "spirt_round_end_overlay");
}
public void OnConfigsExecuted()
{
CT_Overlay.GetString(ct_overlay, sizeof(ct_overlay));
T_Overlay.GetString(t_overlay, sizeof(t_overlay));
overlay_time = Cvar_Time.FloatValue;
}
public void OnMapStart()
{
if(!StrEqual(ct_overlay, "") && StrEqual(t_overlay, ""))
{
char dlpath1[1024], dlpath2[1024], dlpath3[1024], dlpath4[1024];
Format(dlpath1, sizeof(dlpath1), "materials/%s.vtf", ct_overlay);
Format(dlpath2, sizeof(dlpath2), "materials/%s.vmt", ct_overlay);
Format(dlpath3, sizeof(dlpath1), "materials/%s.vtf", t_overlay);
Format(dlpath4, sizeof(dlpath2), "materials/%s.vmt", t_overlay);
AddFileToDownloadsTable(dlpath1);
AddFileToDownloadsTable(dlpath2);
AddFileToDownloadsTable(dlpath3);
AddFileToDownloadsTable(dlpath4);
PrecacheDecal(dlpath1, true);
PrecacheDecal(dlpath2, true);
PrecacheDecal(dlpath3, true);
PrecacheDecal(dlpath4, true);
}
}
public Action Event_RoundEnd(Handle event, const char[] name, bool dontBroadcast)
{
char message[256];
int winnerTeam = GetEventInt(event, "winner");
GetEventString(event, "message", message, sizeof(message));
if(StrEqual(message, "#SFUI_Notice_Round_Draw", false))
{
for (int i = 1; i <= MaxClients; i++)
{
if (IsValidClient(i) && !IsFakeClient(i))
{
if(winnerTeam == 2)
{
SetClientOverlay(i, t_overlay);
PrintToChatAll("os T ganharam crl");
CreateTimer(overlay_time, DeleteOverlay, i);
}
else if(winnerTeam == 3)
{
SetClientOverlay(i, ct_overlay);
PrintToChatAll("os CTs deram uma tareia nos Ts");
CreateTimer(overlay_time, DeleteOverlay, i);
}
}
}
}
}
stock bool IsValidClient(int client)
{
if (client <= 0) return false;
if (client > MaxClients) return false;
if (!IsClientConnected(client)) return false;
return IsClientInGame(client);
}
// Code taken from csgoware
// https://forums.alliedmods.net/showthread.php?p=2500764
bool SetClientOverlay(int client, char[] strOverlay)
{
if (IsValidClient(client) && !IsFakeClient(client))
{
int iFlags = GetCommandFlags("r_screenoverlay") & (~FCVAR_CHEAT);
SetCommandFlags("r_screenoverlay", iFlags);
ClientCommand(client, "r_screenoverlay \"%s.vtf\"", strOverlay);
return true;
}
return false;
}
public Action DeleteOverlay(Handle tmr, any client)
{
if (IsValidClient(client) && !IsFakeClient(client))
{
SetClientOverlay(client, "");
}
return Plugin_Handled;
}
How may I fix this
__________________