I added it to block the menu to choose team and when I try to join the game it crashed.. (I cant have logs because I dont have a dedicated server, I use new game to test)
The message when it crashs says: Fatal error: New message started when msg '86' has not been sent yet
PHP Code:
public message_showmenu(msgid, dest, id)
{
join_user(msgid, id);
return PLUGIN_HANDLED;
}
public message_vguimenu(msgid, dest, id)
{
join_user(msgid, id);
return PLUGIN_HANDLED;
}
public join_user(msg, id){
if (get_user_team(id)){
return;
}
new msg_block;
msg_block = get_msg_block(msg);
set_msg_block(msg, BLOCK_SET);
engclient_cmd(id, "jointeam", "5");
engclient_cmd(id, "joinclass", "5");
set_msg_block(msg, msg_block);
}
I hope someone can help me or tell how block the choosemenu/jointeam right
Edit, solution:
PHP Code:
const OFFSET_VGUIMENU = 2;
enum _:MESSAGES_STRUCT
{
SHOWMENU,
VGUIMENU
};
new g_message[MESSAGES_STRUCT];
public plugin_init() {
register_clcmd("chooseteam", "clcmd_chooseteam");
register_clcmd("jointeam", "clcmd_chooseteam");
g_message[SHOWMENU] = get_user_msgid("ShowMenu");
g_message[VGUIMENU] = get_user_msgid("VGUIMenu");
register_message(g_message[SHOWMENU], "message_showmenu");
register_message(g_message[VGUIMENU], "message_vguimenu");
}
public clcmd_chooseteam(id){
return PLUGIN_HANDLED;
}
public client_jointeam_tt(id){
if (is_user_bot(id)){
return;
}
static vgui;
vgui = (get_pdata_int(id, 510) & (1<<0));
if (vgui)
set_pdata_int(id, 510, get_pdata_int(id, 510) & ~(1<<0));
set_msg_block(get_user_msgid("ShowMenu"), BLOCK_ONCE);
set_msg_block(get_user_msgid("VGUIMenu"), BLOCK_ONCE);
engclient_cmd(id, "jointeam", "1");
engclient_cmd(id, "joinclass", "5");
set_msg_block(get_user_msgid("ShowMenu"), get_msg_block(get_user_msgid("ShowMenu")));
set_msg_block(get_user_msgid("ShowMenu"), get_msg_block(get_user_msgid("VGUIMenu")));
if (vgui)
set_pdata_int(id, 510, get_pdata_int(id, 510));
ExecuteHamB(Ham_CS_RoundRespawn, id);
}
public client_jointeam_ct(id){
if (is_user_bot(id)){
return;
}
static vgui;
vgui = (get_pdata_int(id, 510) & (1<<0));
if (vgui)
set_pdata_int(id, 510, get_pdata_int(id, 510) & ~(1<<0));
set_msg_block(get_user_msgid("ShowMenu"), BLOCK_ONCE);
set_msg_block(get_user_msgid("VGUIMenu"), BLOCK_ONCE);
engclient_cmd(id, "jointeam", "2");
engclient_cmd(id, "joinclass", "5");
set_msg_block(get_user_msgid("ShowMenu"), get_msg_block(get_user_msgid("ShowMenu")));
set_msg_block(get_user_msgid("ShowMenu"), get_msg_block(get_user_msgid("VGUIMenu")));
if (vgui)
set_pdata_int(id, 510, get_pdata_int(id, 510));
ExecuteHamB(Ham_CS_RoundRespawn, id);
}
public message_showmenu(msgid, dest, id)
{
static message[21];
get_msg_arg_string(4, message, charsmax(message));
if (containi(message, "Team_Select") != -1)
return PLUGIN_HANDLED;
return PLUGIN_CONTINUE;
}
public message_vguimenu(msgid, dest, id)
{
if (get_msg_arg_int(1) != OFFSET_VGUIMENU)
return PLUGIN_CONTINUE;
return PLUGIN_HANDLED;
}
You have to call "client_jointeam_ct" or "client_jointeam_tt" when you want to make the player join the team.