#include <amxmodx>
#include <cstrike>
#include <fakemeta_util>
#include <hamsandwich>
//#include <reapi>
//
#define MAX_PLAYERS_ARR MAX_PLAYERS+1
#define TASKID 9655
new const SPRITE[] = "sprites/Flashed_csgo_anim11.spr";
new g_playerBar[MAX_PLAYERS_ARR]
new Float:int1[MAX_PLAYERS_ARR]
new Float:int2[MAX_PLAYERS_ARR]
new Float:int_3[MAX_PLAYERS_ARR]
new g_maxPlayers;
public plugin_precache( )
{
precache_model( SPRITE );
}
public plugin_init( )
{
register_plugin( "Flash Sprite", "null", "kek" );
state initializing;
register_forward( FM_AddToFullPack, "fwAddToFullPack", true );
RegisterHam( Ham_Spawn, "player", "fwHamSpawn", true );
register_message( get_user_msgid( "ScreenFade" ), "msg_ScreenFade" );
g_maxPlayers = get_maxplayers( );
new playerBar, allocString = engfunc( EngFunc_AllocString, "env_sprite" );
for( new id = 1; id <= g_maxPlayers; id ++ )
{
g_playerBar[ id ] = engfunc( EngFunc_CreateNamedEntity, allocString );
playerBar = g_playerBar[ id ];
if( pev_valid( playerBar ) )
{
set_pev( playerBar, pev_scale, 0.15 );
engfunc( EngFunc_SetModel, playerBar, SPRITE );
}
}
}
public fwAddToFullPack( es, e, ent, host, host_flags, player, p_set )
{
if( !player && is_user_alive(host))
{
new user;
for( user = g_maxPlayers; user > 0; -- user )
{
if( g_playerBar[ user ] == ent )
{
if( user != host && is_user_alive(user))
{
new Float: playerOrigin[ 3 ];
pev( user, pev_origin, playerOrigin );
playerOrigin[ 2 ] += 30.0;
set_es( es, ES_Origin, playerOrigin );
}
else
{
set_es( es, ES_Effects, EF_NODRAW );
}
break;
}
}
}
}
public fwHamSpawn( id )
{
set_pev(g_playerBar[ id ],pev_effects, EF_NODRAW)
if( is_user_alive( id ) && get_user_team(id) == 2)
{
new Float: playerOrigin[ 3 ];
pev( id, pev_origin, playerOrigin );
engfunc( EngFunc_SetOrigin, g_playerBar[ id ], playerOrigin );
}
}
public msg_ScreenFade( iMsgId, iMsgDest, id ) <initializing, initialized>
{
if(is_user_alive(id) /*&& get_user_team(id) == 2*/)
{
set_pev(g_playerBar[ id ],pev_effects, 0)
if(get_msg_arg_int( 7 ) > 0)
{
new Float:Value
if( get_msg_arg_int( 7 ) == 255 )
Value = 99.0
else
Value = ((get_msg_arg_int( 7 )/255.0)*100.0)
int1[id] = get_msg_arg_int(2)/4096.0
int2[id] = get_msg_arg_int(1)/4096.0
int_3[id] = int2[id]
set_pev( g_playerBar[ id ], pev_frame, Value );
if(task_exists(id + TASKID))
remove_task(id + TASKID);
StartThink(id + TASKID)
}
}
return PLUGIN_CONTINUE;
}
public StartThink(id)
{
id = id-TASKID
new Float:value
if(int1[id] > 0)
{
set_pev( g_playerBar[ id ], pev_frame, 99.0);
int1[id] = int1[id]-0.1
}
else
{
if(int2[id] > 0)
{
value = (int2[id]/int_3[id])*100.0
if(value >= 100.0)
value = 99.0
set_pev( g_playerBar[ id ], pev_frame, value)
int2[id] = int2[id]-0.1
}
}
if(int2[id] > 0)
set_task(0.1, "StartThink", id+TASKID)
else
set_pev(g_playerBar[ id ],pev_effects, EF_NODRAW)
}