AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Custom menu instead of team select menu. (https://forums.alliedmods.net/showthread.php?t=236765)

Neeeeeeeeeel.- 03-10-2014 20:59

Custom menu instead of team select menu.
 
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);



Destro- 03-11-2014 17:41

Re: Custom menu instead of team select menu.
 
#Terrorist_Select ?

Neeeeeeeeeel.- 03-11-2014 17:43

Re: Custom menu instead of team select menu.
 
Quote:

Originally Posted by Destro- (Post 2110615)
#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.

sb123 03-12-2014 05:18

Re: Custom menu instead of team select menu.
 
1 Attachment(s)
Try this code


All times are GMT -4. The time now is 05:56.

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