Raised This Month: $255 Target: $400
 63% 

Notices

Invisible Spectator


Post New Thread Reply   
 
Thread Tools Display Modes
_J_o_e_
Junior Member
Join Date: Mar 2010
Old 02-12-2015 , 10:52   Re: Invisible Spectator
Reply With Quote #111

this code fixes a bug with the crash server
before selecting the team and typing the command /spectate
Code:
#include < amxmodx >
#include < fakemeta >

#if AMXX_VERSION_NUM < 180
	#define charsmax(%1)	sizeof(%1) - 1
#endif

#if AMXX_VERSION_NUM < 183
	#define MAX_PLAYERS	32
#else 
	// Temp fix until offical 183 is released
	#undef MAX_PLAYERS
	#define MAX_PLAYERS	32
#endif

#define DEAD_FLAG	( 1 << 0 )
#define OFFSET_TEAM	114

enum 
{
 	CS_TEAM_UNASSIGNED,
 	CS_TEAM_T,
 	CS_TEAM_CT,
 	CS_TEAM_SPECTATOR
}

enum InvisibleData
{
	bool:bInvisibleStatus,
	nInvisibleTeam,
	bool:bInvisibleNotAllowed
}

new g_aInvisible[ MAX_PLAYERS + 1 ][ InvisibleData ];

new g_msgScoreAttrib, g_msgTeamInfo
new g_pCvarPercent;

new bool:g_bRoundEnd;

public plugin_init( ) 
{
	register_plugin( "Invisible Spectator", "0.2", "ConnorMcLeod" )

	g_pCvarPercent 		= register_cvar( "amx_inv_dead_percent", "40" )
	g_msgScoreAttrib	= get_user_msgid( "ScoreAttrib" )
	g_msgTeamInfo		= get_user_msgid( "TeamInfo" )
	
	register_message( g_msgScoreAttrib, "msg_ScoreAttrib" );
	register_message( g_msgTeamInfo, "msg_TeamInfo" );
	
	register_menucmd( register_menuid( "Team_Select", 1 ), (1<<0)|(1<<1)|(1<<4)|(1<<5), "handle_TeamMenu" );
	register_menucmd( register_menuid( "Terrorist_Select", 1 ), 31, "handle_ClassMenu" );
	register_menucmd( register_menuid( "CT_Select", 1 ), 31, "handle_ClassMenu" );

	register_clcmd( "amx_spectate", "make_invis", ADMIN_RCON );
	register_clcmd( "jointeam", "command_joinTeam" );
	register_clcmd( "joinclass", "command_joinClass" );
	
	register_logevent( "eRoundEnd", 2, "1=Round_End" )

	register_event( "HLTV", "eNewRound", "a", "1=0", "2=0" )
	register_event( "ResetHUD", "eResetHUD", "be" )
	register_event( "DeathMsg", "eDeathMsg", "a" )
}

public handle_TeamMenu( id, iKey ) 
{ 
	g_aInvisible[ id ][ bInvisibleNotAllowed ] = true;
} 

public handle_ClassMenu( id, iKey )
{
	g_aInvisible[ id ][ bInvisibleNotAllowed ] = false;
}

public command_joinClass( id )
{
	g_aInvisible[ id ][ bInvisibleNotAllowed ] = false;
}

public command_joinTeam( id ) 
{	   
	g_aInvisible[ id ][ bInvisibleNotAllowed ] = true;
}

public make_invis( id, level ) 
{
	if( ~get_user_flags( id ) & level )
	{
		return PLUGIN_CONTINUE;
	}

	if( g_aInvisible[ id ][ bInvisibleStatus ] )
	{
		client_print( id, print_console, "You're not invisible anymore" );
		g_aInvisible[ id ][ bInvisibleStatus ] = false;

		return PLUGIN_HANDLED;
	}
		
	if( is_user_alive( id ) )
	{
		client_print( id, print_console, "You have to be dead first to be an invisible spectator !" )
		return PLUGIN_HANDLED;
	}

	if( g_aInvisible[ id ][ bInvisibleNotAllowed ] )
	{
		client_print( id, print_console, "You have to finish team choosing first !" )
		return PLUGIN_HANDLED;
	}

	g_aInvisible[ id ][ bInvisibleStatus ] = true;
	client_print( id, print_console, "You're now an invisible spectator" );

	new nTeam = get_pdata_int( id, OFFSET_TEAM );

	if( CS_TEAM_T <= nTeam <= CS_TEAM_CT )
	{
		g_aInvisible[ id ][ nInvisibleTeam ] = nTeam
		set_pdata_int( id, OFFSET_TEAM, CS_TEAM_SPECTATOR );
	}
	else
	{
		new aPlayers[ MAX_PLAYERS ], nTerroristNum, nCTNum;
		get_players( aPlayers, nTerroristNum, "e", "TERRORIST" );
		get_players( aPlayers, nCTNum, "e", "CT" );

		g_aInvisible[ id ][ nInvisibleTeam ] = nCTNum > nTerroristNum ? 1 : 2;
	}

	UTIL_ScoreAttrib( id, 0 );

	new szTeamName[ 12 ];
	switch( g_aInvisible[ id ][ nInvisibleTeam ] )
	{
		case 1: formatex( szTeamName, charsmax( szTeamName ), "TERRORIST" );
		case 2: formatex( szTeamName, charsmax( szTeamName ), "CT" );
	}

	UTIL_TeamInfo( id, szTeamName );

	return PLUGIN_HANDLED;
}

public eDeathMsg( ) 
{
	if( g_bRoundEnd )
	{
		return;
	}

	new aPlayers[ MAX_PLAYERS ], nDead, nNum, nPlayer, Float:flPercent = get_pcvar_float( g_pCvarPercent ) / 100.0;
	
	get_players( aPlayers, nDead, "bh" );
	get_players( aPlayers, nNum, "h" );

	if( float( nDead ) / float( nNum ) < flPercent ) 
	{
		return;
	}

	for( new i; i < nNum; i++ )
	{
		nPlayer = aPlayers[ i ]
		if( g_aInvisible[ nPlayer ][ bInvisibleStatus ] )
		{
			UTIL_ScoreAttrib( nPlayer, DEAD_FLAG );
		}
	}
}

public eNewRound( ) 
{
	g_bRoundEnd = false;
	
	new aPlayers[ MAX_PLAYERS ], nNum, nPlayer;
	get_players( aPlayers, nNum );

	for( new i; i < nNum; i++ )
	{
		nPlayer = aPlayers[ i ];
		if( g_aInvisible[ nPlayer ][ bInvisibleStatus ] )
		{
			UTIL_ScoreAttrib( nPlayer, 0 );
		}
	}
}

public eRoundEnd() 
{
	g_bRoundEnd = true;

	new aPlayers[ MAX_PLAYERS ], nNum, nPlayer;
	get_players( aPlayers, nNum );

	for( new i; i < nNum; i++ )
	{
		nPlayer = aPlayers[ i ];
		if( g_aInvisible[ nPlayer ][ bInvisibleStatus ] )
		{
			UTIL_ScoreAttrib( nPlayer, DEAD_FLAG );
		}
	}
}

public eResetHUD( id ) 
{
	if( g_aInvisible[ id ][ bInvisibleStatus ] )
	{
		g_aInvisible[ id ][ bInvisibleStatus ] = false;
	}
}

// Doesn't seem to work so set flag to 0 at NewRound event.
public msg_ScoreAttrib( msg_type, msg_dest, target ) 
{
	if( !g_aInvisible[ get_msg_arg_int( 1 ) ][ bInvisibleStatus ] )
	{
		return PLUGIN_CONTINUE;
	}

	new nFlags = get_msg_arg_int( 2 );
	if( nFlags & DEAD_FLAG )
	{
		set_msg_arg_int( 2, 0, nFlags & ~DEAD_FLAG );
	}

	return PLUGIN_CONTINUE;
}

public msg_TeamInfo(msg_type, msg_dest, target) 
{
	new id = get_msg_arg_int( 1 );
	if( !g_aInvisible[ id ][ bInvisibleStatus ] )
	{
		return PLUGIN_CONTINUE;
	}

	new szTeamName[ 12 ];
	get_msg_arg_string( 2, szTeamName, charsmax( szTeamName ) );

	if( g_aInvisible[ id ][ nInvisibleTeam ] == CS_TEAM_T && strcmp( szTeamName, "TERRORIST" ) != 0 )
	{
		set_msg_arg_string( 2, "TERRORIST" );
	}
	else if( g_aInvisible[ id ][ nInvisibleTeam ] == CS_TEAM_CT && strcmp( szTeamName, "CT" ) != 0 )
	{
		set_msg_arg_string( 2, "CT" );
	}

	return PLUGIN_CONTINUE;
}

UTIL_ScoreAttrib( id, nFlags )
{
	message_begin( MSG_ALL, g_msgScoreAttrib, _, 0 );
	write_byte( id );
	write_byte( nFlags );
	message_end( );
}

UTIL_TeamInfo( id, szTeamName[ ] )
{
	message_begin( MSG_ALL, g_msgTeamInfo, _, 0 );
	write_byte( id );
	write_string( szTeamName );
	message_end( );
}
BUT!
now I have the problem will not go in sometimes invisible spectate
You're now an invisible spectator (stay in the game)
or
not to leave from spec.
You're not invisible anymore (stay in the game)
some fix?
_J_o_e_ is offline
Ejziponken
AlliedModders Donor
Join Date: Apr 2008
Old 03-19-2015 , 20:26   Re: Invisible Spectator
Reply With Quote #112

Quote:
Originally Posted by ConnorMcLeod View Post
This would be better as a module since it gonna catch every MessageBegin of the creation, but here it is, should catch admin transfers (any kind), added ADMIN_BAN access.
Please try it.
Not working. Clients gets disconnected (dropped" from server everytime they join. No errors. Using linux.
__________________

Last edited by Ejziponken; 03-19-2015 at 20:48.
Ejziponken is offline
Prime247cs
Junior Member
Join Date: Aug 2013
Old 03-20-2015 , 18:54   Re: Invisible Spectator
Reply With Quote #113

Quote:
Originally Posted by m4m3ts View Post
Connor can you support this plugin for csdm ?
i need this.

after i deactivate invis_spec it wont respawn again...
please help..

How do you go to spec mode in csdm? Are you in a team playing already or are you in spectators?
Prime247cs is offline
ViBE
Member
Join Date: Jul 2011
Location: Somewhere over the...
Old 12-03-2015 , 16:01   Re: Invisible Spectator
Reply With Quote #114

does this plugin...:

1.) support AMXX 1.8.2 and above?
2.) support latest CSDM?
3.) leave the bots ingame (PODBot) and don't kick them when an admin arrives and stay spectator?
4.) hide spectating admin from player's scoreboard?
ViBE is offline
Send a message via ICQ to ViBE
ViBE
Member
Join Date: Jul 2011
Location: Somewhere over the...
Old 12-04-2015 , 00:00   Re: Invisible Spectator
Reply With Quote #115

Quote:
Originally Posted by Ejziponken View Post
Not working. Clients gets disconnected (dropped" from server everytime they join. No errors. Using linux.
meanwhile i tested the rest. most of them fails at compilation. i guess you tried out version 0.4.0. and if you still interested the reason is the old Orpheu module that you use on the server.


UPDATE

okay then. i give up. it still randomly kicks so Orpheu update is just a partial fix.

Last edited by ViBE; 12-04-2015 at 09:41. Reason: update
ViBE is offline
Send a message via ICQ to ViBE
Old 01-24-2016, 12:03
New and Clueless
This message has been deleted by New and Clueless. Reason: my bad sorry
boogalo
New Member
Join Date: Oct 2013
Old 04-12-2016 , 06:33   Re: Invisible Spectator
Reply With Quote #116

Всем привет!
Обнаружил баг.
Когда карта сменилась, и админ выбрал команду, но не выбрал скин, ввёл команду amx_spectate сервер падает. Можно пофиксить?

english ( google translate )

Hello!
Discovered a bug.
When the card is replaced, and the administrator has selected the team, but did not choose the skin, the team introduced amx_spectate server crashes. It can be fixed a?


UPD. sorry, fixed at the beginning of the page found)

Last edited by boogalo; 04-12-2016 at 06:49.
boogalo is offline
ViBE
Member
Join Date: Jul 2011
Location: Somewhere over the...
Old 05-20-2016 , 09:39   Re: Invisible Spectator
Reply With Quote #117

could somebody fix this please? or does anybody know any alternatives?
__________________
„the cake is a lie”
ViBE is offline
Send a message via ICQ to ViBE
Nutu_
Senior Member
Join Date: Mar 2016
Location: Romania
Old 06-04-2016 , 20:03   Re: Invisible Spectator
Reply With Quote #118

Good work
__________________
traveling around the world √
Nutu_ is offline
lulu3192
Junior Member
Join Date: Dec 2017
Old 06-23-2018 , 02:29   Re: Invisible Spectator
Reply With Quote #119

How can it be done to automatically move spectators into invisible spectator mode at the end round? only admins.
I tried through set_task: set_task(0.1, "make_invis") but only the message appears to me "You're now an invisible spectator", still the spectator remains. Thank you
lulu3192 is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:28.


Powered by vBulletin®
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Theme made by Freecode