Raised This Month: $32 Target: $400
 8% 

Custom menu instead of team select menu.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Neeeeeeeeeel.-
Some Guy Yellin'
Join Date: Jul 2010
Location: Argentina
Old 03-10-2014 , 20:59   Custom menu instead of team select menu.
Reply With Quote #1

I want to join players in CT team always with a custom menu instead of default team select menu. This code works in most cases but sometimes (2/10 times) using old style menu it joins me on TT menu. I don't know how to fix it...

Auto join on connect plugin doesn't fit to my needs...
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

new g_msgid[33];
new 
ingame[33];
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);
stock const VGUI_JOIN_TEAM_NUM 2;
const 
OFFSET_CSMENUCODE 205;
const 
KEYSMENU MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9|MENU_KEY_0;

public 
plugin_init(){
    
register_clcmd("chooseteam""clcmd_changeteam");
    
register_clcmd("jointeam""clcmd_changeteam");
    
register_menu("Access Menu"KEYSMENU"menu_access");
    
register_message(get_user_msgid("ShowMenu"), "message_ShowMenu");
    
register_message(get_user_msgid("VGUIMenu"), "message_VGUIMenu");
}
public 
message_VGUIMenu(iMsgidiDestid){
    if(
get_msg_arg_int(1) != VGUI_JOIN_TEAM_NUM){
        return 
PLUGIN_CONTINUE;
    }
    
    if(
is_user_connected(id) && !ingame[id]){
        
g_msgid[id] = iMsgid;
        
show_menu_access(id);
        return 
PLUGIN_HANDLED;
    }
    
    return 
PLUGIN_HANDLED;
}
public 
message_ShowMenu(iMsgidiDestid){
    static 
sMenuCode[iMaxLen];
    
get_msg_arg_string(4sMenuCodesizeof(sMenuCode)-1);
    if(
equal(sMenuCodeFIRST_JOIN_MSG) || equal(sMenuCodeFIRST_JOIN_MSG_SPEC) || 
    
equal(sMenuCodeINGAME_JOIN_MSG) || equal(sMenuCodeINGAME_JOIN_MSG_SPEC)){
        if(
is_user_connected(id)  && !ingame[id]){
            
g_msgid[id] = iMsgid;
            
show_menu_access(id);
            return 
PLUGIN_HANDLED;
        }
    }
    return 
PLUGIN_HANDLED;
}
public 
clcmd_changeteam(id){
    if(!
ingameid ]){
        
show_menu_access(id);
    }
    return 
PLUGIN_HANDLED;
}
public 
show_menu_access(id){
    static 
menu[256];
    new 
len;
    
    
len += formatex(menu[len], charsmax(menu)-len"\wAccess Menu^n^n");
    
len += formatex(menu[len], charsmax(menu)-len"\y1. \rAccess^n");
    
len += formatex(menu[len], charsmax(menu)-len"\y0. \rSalir");
    
    
set_pdata_int(idOFFSET_CSMENUCODE0);
    
show_menu(idKEYSMENUmenu, -1"Access Menu");
}
public 
menu_access(idkey){
    if (
key == 0){
        static 
msg_block;
        
msg_block get_msg_block(g_msgid[id]);
        
set_msg_block(g_msgid[id], BLOCK_SET);
        
engclient_cmd(id"jointeam""2");
        
engclient_cmd(id"joinclass""5");
        
set_msg_block(g_msgid[id], msg_block);
        
ingame[id] = 1;
    }
}
public 
client_putinserver(id){
    
show_menu_access(id);

__________________
Neeeeeeeeeel.- is offline
Send a message via Skype™ to Neeeeeeeeeel.-
Destro-
Veteran Member
Join Date: Jun 2010
Location: $me->location();
Old 03-11-2014 , 17:41   Re: Custom menu instead of team select menu.
Reply With Quote #2

#Terrorist_Select ?
__________________
Destro- is offline
Neeeeeeeeeel.-
Some Guy Yellin'
Join Date: Jul 2010
Location: Argentina
Old 03-11-2014 , 17:43   Re: Custom menu instead of team select menu.
Reply With Quote #3

Quote:
Originally Posted by Destro- View Post
#Terrorist_Select ?
I tried before posting but didn't work.

I logged sMenuCode variable and I noticed that when the plugin put me in TT team #Terrorist_Select is called before.
__________________

Last edited by Neeeeeeeeeel.-; 03-11-2014 at 18:03.
Neeeeeeeeeel.- is offline
Send a message via Skype™ to Neeeeeeeeeel.-
sb123
Senior Member
Join Date: Jan 2007
Old 03-12-2014 , 05:18   Re: Custom menu instead of team select menu.
Reply With Quote #4

Try this code
Attached Files
File Type: sma Get Plugin or Get Source (custom_team_select_menu.sma - 692 views - 7.9 KB)
__________________
sb123 is offline
Send a message via ICQ to sb123 Send a message via MSN to sb123 Send a message via Yahoo to sb123
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 20:10.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode