PHP Code:
/* Formatright © 2010, ConnorMcLeod
This plugin is free software;
you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this plugin; if not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <amxmodx>
#include <fakemeta>
#include <csdm>
#define VERSION "0.0.1"
#define PLUGIN "Csdm ChooseTeam"
const XO_PLAYER = 5
const m_iTeam = 114
const m_iMenuShown = 125
const m_fHasChangedTeamThisRound = (1<<8)
const m_iMenuCode = 205
#define cs_get_user_team_index(%0) get_pdata_int(%0, m_iTeam, XO_PLAYER)
#define cs_get_user_menu(%0) get_pdata_int(%0, m_iMenuCode, XO_PLAYER)
#define cs_set_user_menu(%0,%1) set_pdata_int(%0, m_iMenuCode, %1, XO_PLAYER)
const Menu_TeamSelect = 1
const Menu_ChooseAppearance = 3
enum { TEAM_UNASSIGNED, TEAM_TERRORIST, TEAM_CT, TEAM_SPECTATOR }
const CHOOSETEAM_KEYS = MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_0
public plugin_init()
{
register_plugin(PLUGIN, VERSION, "ConnorMcLeod")
register_clcmd("chooseteam", "ClCmd_ChooseTeam")
register_clcmd("menuselect", "ClCmd_MenuSelect")
register_event("TextMsg", "Event_TextMsg_Too_Many", "b", "1=4", "2&#Too_Many_")
}
public Event_TextMsg_Too_Many( id )
{
engclient_cmd(id, "jointeam", "5")
}
public ClCmd_ChooseTeam( id )
{
new iMenu = cs_get_user_menu(id)
if( iMenu != Menu_ChooseAppearance && (iMenu != Menu_TeamSelect || !(TEAM_UNASSIGNED < cs_get_user_team_index(id) < TEAM_SPECTATOR)) )
{
show_menu(id, CHOOSETEAM_KEYS, "#IG_Team_Select_Spect")
cs_set_user_menu(id, Menu_TeamSelect)
}
return PLUGIN_HANDLED
}
public ClCmd_MenuSelect( id )
{
switch( cs_get_user_menu(id) )
{
case Menu_TeamSelect:
{
new szKey[3]
if( read_argv(1, szKey, charsmax(szKey)) == 1 )
{
switch( szKey[0] - '0' )
{
case 1,2,5:
{
if( !is_user_alive(id) )
{
new iMenuShown = get_pdata_int(id, m_iMenuShown, XO_PLAYER)
if( iMenuShown & m_fHasChangedTeamThisRound )
{
set_pdata_int(id, m_iMenuShown, iMenuShown & ~m_fHasChangedTeamThisRound, XO_PLAYER)
}
}
}
case 6:
{
if( is_user_alive(id) )
{
set_pev(id, pev_deadflag, DEAD_DEAD)
}
}
}
}
}
case Menu_ChooseAppearance:
{
engclient_cmd(id, "joinclass", "2")
csdm_respawn(id)
return PLUGIN_HANDLED
}
}
return PLUGIN_CONTINUE
}