HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmod>
  2.  
  3. #pragma semicolon 1
  4.  
  5. const TASKID_Autojoin = 583079;
  6.  
  7. new const FIRST_JOIN_MSG[] = "#Team_Select";
  8. new const FIRST_JOIN_MSG_SPEC[] = "#Team_Select_Spect";
  9. new const INGAME_JOIN_MSG[] = "#IG_Team_Select";
  10. new const INGAME_JOIN_MSG_SPEC[] = "#IG_Team_Select_Spect";
  11. const iMaxLen = sizeof( INGAME_JOIN_MSG_SPEC );
  12.  
  13. public plugin_init() {
  14. register_plugin( "Auto CT Join", "1.0", "Exolent" );
  15.  
  16. register_message( get_user_msgid("ShowMenu"), "msgShowMenu" );
  17. register_message( get_user_msgid("VGUIMenu"), "msgVGUIMenu" );
  18.  
  19. // I know this is gay but ffs sometimes it doesnt blocked...
  20. register_clcmd( "chooseteam", "cmdBlock" );
  21. }
  22.  
  23. public plugin_cfg() {
  24. set_cvar_num( "mp_limitteams", 32 );
  25. set_cvar_num( "mp_autoteambalance", 0 );
  26. set_cvar_num( "sv_restart", 1 );
  27. }
  28.  
  29. public cmdBlock( id )
  30. return PLUGIN_HANDLED;
  31.  
  32. public client_disconnect( id )
  33. remove_task( id + TASKID_Autojoin );
  34.  
  35. public msgShowMenu( iMsgid, iDest, id ) {
  36. static sMenuCode[iMaxLen];
  37. get_msg_arg_string(4, sMenuCode, sizeof(sMenuCode) - 1);
  38.  
  39. if( equal(sMenuCode, FIRST_JOIN_MSG) || equal(sMenuCode, FIRST_JOIN_MSG_SPEC) ) {
  40. if( should_autojoin(id) ) {
  41. set_autojoin_task(id, iMsgid);
  42. return PLUGIN_HANDLED;
  43. }
  44. }
  45. else if( equal(sMenuCode, INGAME_JOIN_MSG) || equal(sMenuCode, INGAME_JOIN_MSG_SPEC) )
  46. return PLUGIN_HANDLED;
  47.  
  48. return PLUGIN_CONTINUE;
  49. }
  50.  
  51. public msgVGUIMenu( iMsgid, iDest, id ) {
  52. if( get_msg_arg_int(1) != 2 )
  53. return PLUGIN_CONTINUE;
  54.  
  55. if( should_autojoin(id) ) {
  56. set_autojoin_task(id, iMsgid);
  57. return PLUGIN_HANDLED;
  58. }
  59.  
  60. return PLUGIN_CONTINUE;
  61. }
  62.  
  63. public task_Autojoin( iParam[], id )
  64. handle_join( id - TASKID_Autojoin, iParam[0] );
  65.  
  66. handle_join( id, iMsgid ) {
  67. new iMsgBlock = get_msg_block( iMsgid );
  68. set_msg_block( iMsgid, BLOCK_SET );
  69.  
  70. engclient_cmd( id, "jointeam", "2" );
  71.  
  72. new iClass[2];
  73. iClass[0] = random_num( '1', '4' );
  74. engclient_cmd( id, "joinclass", iClass );
  75.  
  76. set_msg_block( iMsgid, iMsgBlock );
  77. }
  78.  
  79. set_autojoin_task( id, iMsgid ) {
  80. new iParam[1];
  81. iParam[0] = iMsgid;
  82. set_task( 0.1, "task_Autojoin", id + TASKID_Autojoin, iParam, sizeof(iParam) );
  83. }
  84.  
  85. should_autojoin( id )
  86. return ( is_user_connected(id) && get_user_team(id) != 2 && !task_exists(id + TASKID_Autojoin) );
  87.