Hello, I want to force the player to be a spectator when he joins the server, and present him with a menu where he can choose from a custom team, class, gender and so on, and after he finishes his selection, to be moved to the corresponding team and set with a custom player model according to his selection. I started with looking at Exolent's team join management plugin, and so far I made the part where the player is forced to be a spectator, but it doesn't work quite right, the player is indeed switched to the spectator team after he closes the motd window, but the hud is different and still displays money and roundtime, and he can't move. I don't know why, can you help me?
PHP Code:
#include <amxmodx>
#define PLUGIN "Classes"
#define VERSION "1.0"
#define AUTHOR "SeriousSamBG"
enum
{
TEAM_NONE = 0,
TEAM_T,
TEAM_CT,
TEAM_SPEC,
MAX_TEAMS
};
new const g_cTeamChars[MAX_TEAMS] =
{
'U',
'T',
'C',
'S'
};
// Old Style Menus
stock const FIRST_JOIN_MSG[] = "#Team_Select";
stock const FIRST_JOIN_MSG_SPEC[] = "#Team_Select_Spect";
stock const INGAME_JOIN_MSG[] = "#IG_Team_Select";
stock const INGAME_JOIN_MSG_SPEC[] = "#IG_Team_Select_Spect";
const iMaxLen = sizeof(INGAME_JOIN_MSG_SPEC);
// New VGUI Menus
stock const VGUI_JOIN_TEAM_NUM = 2;
new g_iTeam[33];
new g_iPlayers[MAX_TEAMS];
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
register_event("TeamInfo", "event_TeamInfo", "a");
register_message(get_user_msgid("ShowMenu"), "message_ShowMenu");
register_message(get_user_msgid("VGUIMenu"), "message_VGUIMenu");
}
public event_TeamInfo()
{
new id = read_data(1);
new sTeam[32], iTeam;
read_data(2, sTeam, sizeof(sTeam) - 1);
for(new i = 0; i < MAX_TEAMS; i++)
{
if(g_cTeamChars[i] == sTeam[0])
{
iTeam = i;
break;
}
}
if(g_iTeam[id] != iTeam)
{
g_iPlayers[g_iTeam[id]]--;
g_iTeam[id] = iTeam;
g_iPlayers[iTeam]++;
}
}
public message_ShowMenu(iMsgid, iDest, id)
{
static sMenuCode[iMaxLen];
get_msg_arg_string(4, sMenuCode, sizeof(sMenuCode) - 1);
if(equal(sMenuCode, FIRST_JOIN_MSG) || equal(sMenuCode, FIRST_JOIN_MSG_SPEC))
{
if(is_user_connected(id) && !(TEAM_NONE < g_iTeam[id] < TEAM_SPEC))
{
set_autojoin_task(id, iMsgid);
return PLUGIN_HANDLED;
}
}
else if(equal(sMenuCode, INGAME_JOIN_MSG) || equal(sMenuCode, INGAME_JOIN_MSG_SPEC))
{
return PLUGIN_HANDLED;
}
return PLUGIN_CONTINUE;
}
public message_VGUIMenu(iMsgid, iDest, id)
{
if(get_msg_arg_int(1) != VGUI_JOIN_TEAM_NUM)
{
return PLUGIN_CONTINUE;
}
if(is_user_connected(id) && !(TEAM_NONE < g_iTeam[id] < TEAM_SPEC))
{
set_autojoin_task(id, iMsgid);
return PLUGIN_HANDLED;
}
else if(TEAM_NONE < g_iTeam[id] < TEAM_SPEC)
{
return PLUGIN_HANDLED;
}
return PLUGIN_CONTINUE;
}
stock set_autojoin_task(id, iMsgid)
{
new iMsgBlock = get_msg_block(iMsgid);
set_msg_block(iMsgid, BLOCK_SET);
engclient_cmd(id, "jointeam", "3");
set_msg_block(iMsgid, iMsgBlock);
}
__________________