Added some non-functional tweaks & comments to that code.
#define PLUGIN "RespawnMenu"
#define VERSION "1.0"
#define AUTHOR "NapoleoN#"
//Not an impact to functionality but it is good habit to use proper variable naming convention
//to improve readability and it can help when debugging things.
// iVariable = integer
// szVariable = string
// fVariable = float
register_plugin( PLUGIN , VERSION , AUTHOR );
RegisterHam( Ham_Killed , "player" , "PostPlayerKilled" , 1 );
iMenu = menu_create( "\w[\rBB\w]\y Respawn?" , "RespawnHandler" );
menu_additem( iMenu , "\wYes" );
menu_additem( iMenu , "\wNo" );
menu_setprop( iMenu , MPROP_NUMBER_COLOR , "\r" );
public PostPlayerKilled( iVictim , iAttacker , iShouldGib )
//** You shouldn't need to check for team here since only a T or CT can be killed..and it's not possible
//** for a player to change to spectator between the time he is killed and when Ham_Killed post is executed.
//** No need to check that a player is not alive since this is called Ham_Killed post, the player is
//** definitely going to be dead.
iTeam = get_user_team(iVictim);
if(!is_user_alive(iVictim) && (iTeam == 1 || iTeam == 2))
menu_display( iVictim , iMenu );
public RespawnHandler( id , iMenuID , item )
//** You should do the team and alive checking when the user makes a menu selection. This way, if
//** the menu is still up when a new round starts (and he is spawned naturally), you would not want
//** to allow him to re-spawn via the menu. Ideally you should force-close the menu on new round.
//** Use cs_get_user_team() native for cstrike
/*iTeam = get_user_team(id);
if(!is_user_alive(id) && (iTeam == 1 || iTeam == 2))
** No need for a switch for only 1 item. Just have an if statement for menu item 0..
case 0: ExecuteHamB(Ham_CS_RoundRespawn, id);
case 1: return PLUGIN_HANDLED;
if ( item == 0 )
if ( !is_user_alive( id ) && ( CS_TEAM_T <= cs_get_user_team( id ) <= CS_TEAM_CT ) )
ExecuteHamB( Ham_CS_RoundRespawn , id );