Try if this works the way you want it to.
It's a quite simple plugin, two cvars to use:
- spec_announcement -Change this to 0 if you don't want to send a chatmsg information about which player did what.
- spec_deathmessage -Change to 1 if you want the players that turns to spectator to show in the deathmsg. ( Up in the right corner by default )
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <hamsandwich>
new const gszPrefix[] = "[CTR]"
new gCvarDeathMsg
new gCvarAnnouncement
public plugin_init()
{
register_plugin( "ChooseteamReplacement", "1.0", "Rtk.Esc")
register_clcmd( "chooseteam", "replace_function" )
gCvarAnnouncement = register_cvar( "spec_announcement", "1" )
gCvarDeathMsg = register_cvar( "spec_deathmessage", "0" )
}
public replace_function(id)
{
static Name[34]
get_user_name( id, Name, charsmax(Name) )
new iAnnounce = get_pcvar_num( gCvarAnnouncement )
if ( cs_get_user_team(id) != CS_TEAM_CT )
{
cs_set_user_team( id, CS_TEAM_CT )
ExecuteHamB( Ham_CS_RoundRespawn, id )
if ( iAnnounce )
client_print( 0, print_chat, "%s%s respawned as Ct again", gszPrefix, Name )
}
else
{
cs_set_user_team( id, CS_TEAM_SPECTATOR )
if ( get_pcvar_num( gCvarDeathMsg ) )
user_kill(id, 1)
else
{
user_silentkill(id)
}
if ( iAnnounce )
client_print( 0, print_chat, "%s%s switched team to spectator", gszPrefix, Name )
}
return PLUGIN_HANDLED;
}