PHP Code:
// EITHER
#define is_user_spectator( %0 ) ( get_user_team( %0 ) == 3 )
// OR
bool: is_user_spectator( iPlayer )
return get_user_team( iPlayer ) == 3;
Edit:
Or, if you want to know whether user is spectating someone:
PHP Code:
#define INVALID_PLAYER -1
get_user_spectating_target( iPlayer )
{
static i;
if( !is_user_alive( iPlayer ) && is_user_connected( ( i = pev( iPlayer, pev_iuser1 ) ) ) )
return i;
return INVALID_PLAYER;
}
Then, you can check:
PHP Code:
if( is_user_spectator( iClient ) && get_user_spectating_target( iClient ) != INVALID_PLAYER )
{
// His team is spectator and he is spectating a valid target
}
if( is_user_spectator( iClient ) )
{
// His team is spectator
}
if( get_user_spectating_target( iClient ) != INVALID_PLAYER )
{
// His team may be Red, Blue or Spectator and he is spectating a valid target
}
__________________