AlliedModders

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

God Of Gaming 05-02-2018 21:32

hook team select menu
 
Plugin is supposed to replace the team and faction selection menu with a custom one that would allow me to add custom player skins, potentially more than 4 per team. It appears to work in-game, it does what it's supposed to, but in the server console I see error messages and I don't know how to fix them. I even got disconnected once because of message channel overflow or something like that. Error shows up when a player connects, and exact error is:

Code:

Invalid message id
[AMXX] Run time error 10 (plugin "cs_beta20.amxx") (native "set_msg_block") - debug not enabled!

Here's the plugin code, help me fix it please

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fakemeta>
#include <fun>
#include <hamsandwich>

// Plugin information
#define PLUGIN "CS Beta 2.0"
#define VERSION "1.0"
#define AUTHOR "God Of Gaming"

enum
{
    
TEAM_NONE 0,
    
TEAM_T,
    
TEAM_CT,
    
TEAM_SPEC,
    
    
MAX_TEAMS
};

new const 
g_cTeamCharsMAX_TEAMS ] = { 'U''T''C''S' };

new 
g_iTeam33 ];
new 
g_iPlayersMAX_TEAMS ];
new 
g_MenuTitle[64];
new 
g_TMenuTitle[64];
new 
g_CTMenuTitle[64];
new 
g_IfColoredMenus;
new 
iMsgBlock;
new 
iMessage;
new 
pl_faction[33];

new 
terror_beta_model[] = "models/player/terror_beta/terror_beta.mdl";
new 
urban_beta_model[] = "models/player/urban_beta/urban_beta.mdl";
//const random_bot_skin_T[][] = { "terror_beta", "urban_beta" };
//const random_bot_skin_CT[][] = { "terror_beta", "urban_beta" };

// 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 sizeofINGAME_JOIN_MSG_SPEC );

// New VGUI Menus
stock const VGUI_JOIN_TEAM_NUM 2;

public 
plugin_precache() {
    
precache_modelterror_beta_model );
    
precache_modelurban_beta_model );
}

public 
plugin_init() {
    
cs_set_no_knives);
    
register_event"TeamInfo""event_TeamInfo""a" );
    
register_messageget_user_msgid"ShowMenu" ), "message_ShowMenu" );
    
register_messageget_user_msgid"VGUIMenu" ), "message_VGUIMenu" );
    
RegisterHamHam_Spawn"player""Ham_CBasePlayer_Spawn_Post");

    
// Menu
    
g_IfColoredMenus colored_menus();
    if( 
g_IfColoredMenus ) {
        
formatexg_MenuTitle63"\wSelect a team:" );
        
formatexg_TMenuTitle63"\wSelect a terrorist group:" );
        
formatexg_CTMenuTitle63"\wSelect a counter-terrorist group:" );
    }
    else {
        
formatexg_MenuTitle63"Select a team:" );
        
formatexg_TMenuTitle63"Select a terrorist group:" );
        
formatexg_CTMenuTitle63"Select a counter-terrorist group:" );
    }
    
register_menucmdregister_menuidg_MenuTitle ), 1023"actionTeamMenu" );
    
register_menucmdregister_menuidg_TMenuTitle ), 1023"actionTTeamMenu" );
    
register_menucmdregister_menuidg_CTMenuTitle ), 1023"actionCTTeamMenu" );

    
register_pluginPLUGINVERSIONAUTHOR );
}

public 
event_TeamInfo() {
    new 
id read_data);
    new 
sTeam32 ], iTeam;

    
read_data2sTeamsizeofsTeam ) - );

    for( new 
0MAX_TEAMSi++ ) {
        if( 
g_cTeamChars[i] == sTeam[0] ) {
            
iTeam i;
            break;
        }
    }

    if( 
g_iTeamid ] != iTeam ) {
        
g_iPlayersg_iTeamid ] ]--;
        
g_iTeamid ] = iTeam;
        
g_iPlayersiTeam ]++;
    }
}

public 
message_ShowMenuiMsgidiDestid ) {
    static 
sMenuCodeiMaxLen ];

    if( 
is_user_botid ) ) return PLUGIN_CONTINUE;

    
get_msg_arg_string4sMenuCodesizeofsMenuCode ) - );

    if( 
equalsMenuCodeFIRST_JOIN_MSG ) || equalsMenuCodeFIRST_JOIN_MSG_SPEC ) ) {
        if( 
is_user_connectedid ) && !( TEAM_NONE g_iTeamid ] < TEAM_SPEC ) ) {
            new 
args];

            
args] = id;
            
iMessage iMsgid;
            
set_task0.1"set_autojoin_task"idargs);

            return 
PLUGIN_HANDLED;
        }
    }
    else if( 
equalsMenuCodeINGAME_JOIN_MSG ) || equalsMenuCodeINGAME_JOIN_MSG_SPEC ) ) {
        if( 
is_user_connectedid ) && !( TEAM_NONE g_iTeamid ] < TEAM_SPEC ) ) {
            new 
args];

            
args] = id;
            
iMessage iMsgid;
            
set_task0.1"set_autojoin_task"idargs);
        }
        return 
PLUGIN_HANDLED;
    }

    return 
PLUGIN_CONTINUE;
}

public 
message_VGUIMenuiMsgidiDestid ) {
    if( 
is_user_botid ) ) return PLUGIN_CONTINUE;

    if( 
get_msg_arg_int) != VGUI_JOIN_TEAM_NUM ) {
        return 
PLUGIN_CONTINUE;
    }

    if( 
is_user_connectedid ) && !( TEAM_NONE g_iTeamid ] < TEAM_SPEC ) ) {
        new 
args];
    
        
args] = id;
        
iMessage iMsgid;
        
set_task0.1"set_autojoin_task"idargs);

        return 
PLUGIN_HANDLED;
    }
    else if( 
TEAM_NONE g_iTeamid ] < TEAM_SPEC ) {
        return 
PLUGIN_HANDLED;
    }

    return 
PLUGIN_CONTINUE;
}

public 
set_autojoin_taskargs[] ) {
    
iMsgBlock get_msg_blockiMessage );
    
set_msg_blockiMessageBLOCK_SET );

    
// Init variables
    
new menu512 ], keys;

    
// Add menu header
    
new len;
    
len formatexmenu511"%s^n^n"g_MenuTitle );

    
keys |= ( 1<<);
    
len += formatexmenulen ], 511-len"\w1. Terrorist Faction" );

    
keys |= ( 1<<);
    
len += formatexmenulen ], 511-len"^n2. Counter-Terrorist force" );

    
keys |= ( 1<<);
    
len += formatexmenulen ], 511-len"^n3. (AUTO-SELECT)");

    
keys |= ( 1<<);
    
len += formatexmenulen ], 511-len"^n^n0. Spectator" );

    
// Finally show the generated menu
    
show_menuargs], keysmenu );

    return 
PLUGIN_CONTINUE;
}

public 
showTTeamMenuid ) {
    
// Init variables
    
new menu512 ], keys;

    
// Add menu header
    
new len;
    
len formatexmenu511"%s^n^n"g_TMenuTitle );

    
keys |= ( 1<<);
    
len += formatexmenulen ], 511-len"\w1. The Phoenix Faction" );

    
// Finally show the generated menu
    
show_menuidkeysmenu );

    return 
PLUGIN_CONTINUE;
}

public 
showCTTeamMenuid ) {
    
// Init variables
    
new menu512 ], keys;

    
// Add menu header
    
new len;
    
len formatexmenu511"%s^n^n"g_CTMenuTitle );

    
keys |= ( 1<<);
    
len += formatexmenulen ], 511-len"\w1. Seal Team 6 (DEVGRU)" );

    
// Finally show the generated menu
    
show_menuidkeysmenu );

    return 
PLUGIN_CONTINUE;
}

// Handles Menus
public actionTeamMenuidkey ) {
    switch( 
key ) {
        case 
0:
        {
            
showTTeamMenuid ); //T
        
}
        case 
1:
        {
            
showCTTeamMenuid ); //CT
        
}
        case 
2:
        {
            
engclient_cmdid"jointeam""5" ); //Auto
            
engclient_cmdid"joinclass""5" );
            
set_msg_blockiMessageiMsgBlock );
        }
        default:
        {
            
engclient_cmdid"jointeam""6" ); //SPEC
            
set_msg_blockiMessageiMsgBlock );
        }
    }
}

public 
actionTTeamMenuidkey ) {
    switch( 
key ) {
        case 
0:
        {
            
pl_factionid ] = 0//terror
        
}
        default
        {
            
pl_factionid ] = 0//terror
        
}
    }

    
engclient_cmdid"jointeam""1" );
    
engclient_cmdid"joinclass""1" );
    
set_msg_blockiMessageiMsgBlock );
}

public 
actionCTTeamMenuidkey ) {
    switch( 
key ) {
        case 
0:
        {
            
pl_factionid ] = 0//urban
        
}
        default:
        {
            
pl_factionid ] = 0//urban
        
}
    }

    
engclient_cmdid"jointeam""2" );
    
engclient_cmdid"joinclass""1" );
    
set_msg_blockiMessageiMsgBlock );
}

public 
Ham_CBasePlayer_Spawn_Postid ) {
    if( 
is_user_aliveid ) ) {
        if( 
cs_get_user_teamid ) == CsTeams:CS_TEAM_T ) {
            
g_iTeamid ] = 1;

/*            if( is_user_bot( id ) )
                cs_set_user_model( id, random_bot_skin_T[ random( sizeof( random_bot_skin_T ) ) ] );
            else
                switch(pl_faction[ id ] ) {
                    case 0:
                    {*/
                        
cs_set_user_modelid"terror_beta" );
/*                    }
                }*/
        
}
        else if( 
cs_get_user_teamid ) == CsTeams:CS_TEAM_CT ) {
            
g_iTeamid ] = 2;

/*            if( is_user_bot( id ) )
                cs_set_user_model( id, random_bot_skin_CT[ random( sizeof( random_bot_skin_CT ) ) ] );
            else
                switch(pl_faction[ id ] ) {
                    case 0:
                    {*/
                        
cs_set_user_modelid"urban_beta" );
/*                    }
                }*/
        
}
    }
}

public 
client_disconnectid ) {
    
remove_taskid );
    
set_msg_blockiMessageiMsgBlock );




All times are GMT -4. The time now is 04:42.

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