can someone make the plugin that will transfer ONLY alive player to spec ONLY!
PHP Code:
#include < amxmodx >
#include < fun >
#include < engine >
#include < cstrike >
#include < hamsandwich >
new g_iMsgSayText, Float:g_vSavedOrigin[ 33 ][ 3 ], bool:g_bWasAlive[ 33 ];
public plugin_init( ) {
register_plugin( "Team Changer", "1.0", "SchlumPF" );
register_clcmd( "say /spec", "CmdSpectator" );
register_clcmd( "say /ct", "CmdCounterTerrorist" );
register_clcmd( "say /t", "CmdTerrorist" );
g_iMsgSayText = get_user_msgid( "SayText" );
set_msg_block( get_user_msgid( "ClCorpse" ), BLOCK_SET );
}
public CmdSpectator( const id ) {
if( cs_get_user_team( id ) == CS_TEAM_SPECTATOR ) {
SendMessage( id, "^4[XJ] You are already a^3 spectator^4, say '^1/ct^4' to change your team." );
return PLUGIN_HANDLED;
}
if( ( g_bWasAlive[ id ] = bool:is_user_alive( id ) ) )
entity_get_vector( id, EV_VEC_origin, g_vSavedOrigin[ id ] );
entity_set_int( id, EV_INT_deadflag, DEAD_DISCARDBODY );
cs_set_user_team( id, CS_TEAM_SPECTATOR );
SendMessage( id, "^4[XJ] You became a^3 spectator^1." );
return PLUGIN_HANDLED;
}
public CmdCounterTerrorist( const id ) {
if( cs_get_user_team( id ) == CS_TEAM_CT ) {
SendMessage( id, "^4[XJ] You are already a^3 counter-terrorist^4, say '^1/spec^4' to change your team." );
return PLUGIN_HANDLED;
}
cs_set_user_team( id, CS_TEAM_CT );
ExecuteHamB( Ham_CS_RoundRespawn, id );
if( !user_has_weapon( id, CSW_KNIFE ) )
give_item( id, "weapon_knife" );
if( !user_has_weapon( id, CSW_USP ) ) {
give_item( id, "weapon_usp" );
cs_set_user_bpammo( id, CSW_USP, 100 );
}
if( g_bWasAlive[ id ] ) {
g_bWasAlive[ id ] = false;
entity_set_origin( id, g_vSavedOrigin[ id ] );
}
SendMessage( id, "^4[XJ] You became a^3 counter-terrorist^4." );
return PLUGIN_HANDLED;
}
public CmdTerrorist( const id ) {
if( cs_get_user_team( id ) == CS_TEAM_T ) {
SendMessage( id, "^4[XJ] You are already a^3 terrorist^4, say '^1/spec^4' to change your team." );
return PLUGIN_HANDLED;
}
cs_set_user_team( id, CS_TEAM_T );
ExecuteHamB( Ham_CS_RoundRespawn, id );
if( !user_has_weapon( id, CSW_KNIFE ) )
give_item( id, "weapon_knife" );
if( !user_has_weapon( id, CSW_GLOCK18 ) ) {
give_item( id, "weapon_glock18" );
cs_set_user_bpammo( id, CSW_GLOCK18, 120 );
}
if( g_bWasAlive[ id ] ) {
g_bWasAlive[ id ] = false;
entity_set_origin( id, g_vSavedOrigin[ id ] );
}
SendMessage( id, "^4[XJ] You became a^3 terrorist^4." );
return PLUGIN_HANDLED;
}
SendMessage( const id, const szMessage[ ] ) {
message_begin( MSG_ONE_UNRELIABLE , g_iMsgSayText, _, id );
write_byte( id );
write_string( szMessage );
message_end( );
}