PHP Code:
/* Formatright © 2010, ConnorMcLeod
This plugin is free software;
you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this plugin; if not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <amxmodx>
#include <hamsandwich>
#include <cstrike>
#include <screenfade_util.inc>
#define VERSION "0.0.2"
#define PLUGIN "FrrezeTime ScreenFade"
new g_bFreezePeriod = true
new g_pCvarFadeTeam, g_pCvarColorAlpha[2]
public plugin_init()
{
register_plugin(PLUGIN, VERSION, "ConnorMcLeod")
g_pCvarFadeTeam = register_cvar("amx_freezefade_team", "2") // 0:nobody 1:Ts 2:CTs 3:all
g_pCvarColorAlpha[0] = register_cvar("amx_fade_t", "250000000255") // RRRGGGBBB / R=Red G=Green B=Blue A=Alpha
g_pCvarColorAlpha[1] = register_cvar("amx_fade_ct", "000000250255") // RRRGGGBBB / R=Red G=Green B=Blue A=Alpha
register_event("HLTV", "Event_HLTV_New_Round", "a", "1=0", "2=0")
register_logevent("LogEvent_Round_Start", 2, "1=Round_Start")
RegisterHam(Ham_Spawn, "player", "CBasePlayer_Spawn_Post", true)
}
public Event_HLTV_New_Round()
{
g_bFreezePeriod = true
}
public CBasePlayer_Spawn_Post(id)
{
if( g_bFreezePeriod && is_user_alive(id) )
{
new iTeam = _:cs_get_user_team(id)
if( get_pcvar_num(g_pCvarFadeTeam) & iTeam )
{
new iColor[3], iAlpha
get_pcvar_color_alpha(g_pCvarColorAlpha[iTeam-1], iColor, iAlpha)
UTIL_ScreenFade(id,iColor,1.0,_,iAlpha,FFADE_OUT|FFADE_STAYOUT,true)
}
}
}
get_pcvar_color_alpha( g_pCvar , iColor[] , &iAlpha=0 )
{
new szColor[13]
if( get_pcvar_string(g_pCvar, szColor, charsmax(szColor)) != charsmax(szColor) )
{
abort(AMX_ERR_GENERAL, "Color cvar must be 12 chars, format ^"RRRGGGBBBAAA^"")
}
iColor[Red] = parse_color( szColor, 0 )
iColor[Green] = parse_color( szColor, 3 )
iColor[Blue] = parse_color( szColor, 6 )
iAlpha = parse_color( szColor, 9 )
}
parse_color(szColor[], iStart)
{
return 100 * szColor[iStart] + 10 * szColor[iStart+1] + szColor[iStart+2] - 5328
}
public LogEvent_Round_Start()
{
g_bFreezePeriod = false
new iPlayers[32], iNum, iColor[3], iAlpha
new iTeamCvar = get_pcvar_num(g_pCvarFadeTeam)
if( iTeamCvar & _:CS_TEAM_T )
{
get_players(iPlayers, iNum, "ae", "TERRORIST")
get_pcvar_color_alpha(g_pCvarColorAlpha[0], iColor, iAlpha)
for(--iNum; iNum>=0; iNum--)
{
UTIL_ScreenFade(iPlayers[iNum], iColor, 2.0, _, iAlpha)
}
}
if( iTeamCvar & _:CS_TEAM_CT )
{
get_players(iPlayers, iNum, "ae", "CT")
get_pcvar_color_alpha(g_pCvarColorAlpha[1], iColor, iAlpha)
for(--iNum; iNum>=0; iNum--)
{
UTIL_ScreenFade(iPlayers[iNum], iColor, 2.0, _, iAlpha)
}
}
}