Junior Member
Join Date: Feb 2013
Location: Bulgaria
|
05-02-2018
, 21:32
hook team select menu
|
#1
|
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_cTeamChars[ MAX_TEAMS ] = { 'U', 'T', 'C', 'S' };
new g_iTeam[ 33 ];
new g_iPlayers[ MAX_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 = sizeof( INGAME_JOIN_MSG_SPEC );
// New VGUI Menus
stock const VGUI_JOIN_TEAM_NUM = 2;
public plugin_precache() {
precache_model( terror_beta_model );
precache_model( urban_beta_model );
}
public plugin_init() {
cs_set_no_knives( 1 );
register_event( "TeamInfo", "event_TeamInfo", "a" );
register_message( get_user_msgid( "ShowMenu" ), "message_ShowMenu" );
register_message( get_user_msgid( "VGUIMenu" ), "message_VGUIMenu" );
RegisterHam( Ham_Spawn, "player", "Ham_CBasePlayer_Spawn_Post", 1 );
// Menu
g_IfColoredMenus = colored_menus();
if( g_IfColoredMenus ) {
formatex( g_MenuTitle, 63, "\wSelect a team:" );
formatex( g_TMenuTitle, 63, "\wSelect a terrorist group:" );
formatex( g_CTMenuTitle, 63, "\wSelect a counter-terrorist group:" );
}
else {
formatex( g_MenuTitle, 63, "Select a team:" );
formatex( g_TMenuTitle, 63, "Select a terrorist group:" );
formatex( g_CTMenuTitle, 63, "Select a counter-terrorist group:" );
}
register_menucmd( register_menuid( g_MenuTitle ), 1023, "actionTeamMenu" );
register_menucmd( register_menuid( g_TMenuTitle ), 1023, "actionTTeamMenu" );
register_menucmd( register_menuid( g_CTMenuTitle ), 1023, "actionCTTeamMenu" );
register_plugin( PLUGIN, VERSION, AUTHOR );
}
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 ];
if( is_user_bot( id ) ) return PLUGIN_CONTINUE;
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 ) ) {
new args[ 1 ];
args[ 0 ] = id;
iMessage = iMsgid;
set_task( 0.1, "set_autojoin_task", id, args, 1 );
return PLUGIN_HANDLED;
}
}
else if( equal( sMenuCode, INGAME_JOIN_MSG ) || equal( sMenuCode, INGAME_JOIN_MSG_SPEC ) ) {
if( is_user_connected( id ) && !( TEAM_NONE < g_iTeam[ id ] < TEAM_SPEC ) ) {
new args[ 1 ];
args[ 0 ] = id;
iMessage = iMsgid;
set_task( 0.1, "set_autojoin_task", id, args, 1 );
}
return PLUGIN_HANDLED;
}
return PLUGIN_CONTINUE;
}
public message_VGUIMenu( iMsgid, iDest, id ) {
if( is_user_bot( id ) ) return PLUGIN_CONTINUE;
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 ) ) {
new args[ 1 ];
args[ 0 ] = id;
iMessage = iMsgid;
set_task( 0.1, "set_autojoin_task", id, args, 1 );
return PLUGIN_HANDLED;
}
else if( TEAM_NONE < g_iTeam[ id ] < TEAM_SPEC ) {
return PLUGIN_HANDLED;
}
return PLUGIN_CONTINUE;
}
public set_autojoin_task( args[] ) {
iMsgBlock = get_msg_block( iMessage );
set_msg_block( iMessage, BLOCK_SET );
// Init variables
new menu[ 512 ], keys;
// Add menu header
new len;
len = formatex( menu, 511, "%s^n^n", g_MenuTitle );
keys |= ( 1<<0 );
len += formatex( menu[ len ], 511-len, "\w1. Terrorist Faction" );
keys |= ( 1<<1 );
len += formatex( menu[ len ], 511-len, "^n2. Counter-Terrorist force" );
keys |= ( 1<<2 );
len += formatex( menu[ len ], 511-len, "^n3. (AUTO-SELECT)");
keys |= ( 1<<9 );
len += formatex( menu[ len ], 511-len, "^n^n0. Spectator" );
// Finally show the generated menu
show_menu( args[ 0 ], keys, menu );
return PLUGIN_CONTINUE;
}
public showTTeamMenu( id ) {
// Init variables
new menu[ 512 ], keys;
// Add menu header
new len;
len = formatex( menu, 511, "%s^n^n", g_TMenuTitle );
keys |= ( 1<<0 );
len += formatex( menu[ len ], 511-len, "\w1. The Phoenix Faction" );
// Finally show the generated menu
show_menu( id, keys, menu );
return PLUGIN_CONTINUE;
}
public showCTTeamMenu( id ) {
// Init variables
new menu[ 512 ], keys;
// Add menu header
new len;
len = formatex( menu, 511, "%s^n^n", g_CTMenuTitle );
keys |= ( 1<<0 );
len += formatex( menu[ len ], 511-len, "\w1. Seal Team 6 (DEVGRU)" );
// Finally show the generated menu
show_menu( id, keys, menu );
return PLUGIN_CONTINUE;
}
// Handles Menus
public actionTeamMenu( id, key ) {
switch( key ) {
case 0:
{
showTTeamMenu( id ); //T
}
case 1:
{
showCTTeamMenu( id ); //CT
}
case 2:
{
engclient_cmd( id, "jointeam", "5" ); //Auto
engclient_cmd( id, "joinclass", "5" );
set_msg_block( iMessage, iMsgBlock );
}
default:
{
engclient_cmd( id, "jointeam", "6" ); //SPEC
set_msg_block( iMessage, iMsgBlock );
}
}
}
public actionTTeamMenu( id, key ) {
switch( key ) {
case 0:
{
pl_faction[ id ] = 0; //terror
}
default
{
pl_faction[ id ] = 0; //terror
}
}
engclient_cmd( id, "jointeam", "1" );
engclient_cmd( id, "joinclass", "1" );
set_msg_block( iMessage, iMsgBlock );
}
public actionCTTeamMenu( id, key ) {
switch( key ) {
case 0:
{
pl_faction[ id ] = 0; //urban
}
default:
{
pl_faction[ id ] = 0; //urban
}
}
engclient_cmd( id, "jointeam", "2" );
engclient_cmd( id, "joinclass", "1" );
set_msg_block( iMessage, iMsgBlock );
}
public Ham_CBasePlayer_Spawn_Post( id ) {
if( is_user_alive( id ) ) {
if( cs_get_user_team( id ) == CsTeams:CS_TEAM_T ) {
g_iTeam[ id ] = 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_model( id, "terror_beta" );
/* }
}*/
}
else if( cs_get_user_team( id ) == CsTeams:CS_TEAM_CT ) {
g_iTeam[ id ] = 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_model( id, "urban_beta" );
/* }
}*/
}
}
}
public client_disconnect( id ) {
remove_task( id );
set_msg_block( iMessage, iMsgBlock );
}
__________________
Last edited by God Of Gaming; 05-02-2018 at 21:33.
Reason: replacing [CODE] with [PHP] for coloring
|
|