Raised This Month: $12 Target: $400
 3% 

PUG Auto Spec on Connect & 5v5 Team lock


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   Counter-Strike        Category:   Admin Commands       
CookieCrumbler
Senior Member
Join Date: Feb 2013
Location: Australia
Old 02-10-2018 , 08:39   PUG Auto Spec on Connect & 5v5 Team lock
Reply With Quote #1

PUG Auto Spec on Connect & 5v5 Team lock

Features
Blocks the MOTD and the Team VGUI on connect and places you straight onto Spectator
Infinite Team Change
5v5 Team Limit

Credits
Coder for our community.
hornet


Code:
#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
#include <cstrike>
 
#define VGUI_SELECT_TEAM            2
#define MENU_JOINTEAM           1
#define GAMESTATE_JOINTEAM      4
 
#define XO_PLAYER           5
 
#define m_iPlayerTeam           114
#define m_iJoiningState         121
#define m_bHasChangeTeamThisRound   125
#define m_iMenu             205
 
new g_pcvarTeamLimit;
 
public plugin_init()
{
    register_plugin( "Auto Spec + Team Limiter", "0.0.1", "hornet" );
   
    register_clcmd( "jointeam", "ClientCommand_Team" );
    register_clcmd( "chooseteam", "ClientCommand_Team" );
    register_clcmd( "menuselect", "ClientCommand_Team" );
   
    register_message( get_user_msgid( "MOTD" ), "Message_MOTD" );
    register_message( get_user_msgid( "ShowMenu" ), "Message_ShowMenu" );
    register_message( get_user_msgid( "VGUIMenu" ), "Message_VGUIMenu" );
   
    g_pcvarTeamLimit = register_cvar( "pug_team_limit", "5" );
}
 
public client_disconnected( id )
{
    remove_task( id );
}
 
public ClientCommand_Team( id )
{
    if( ( get_pdata_int( id, m_iMenu ) == MENU_JOINTEAM && get_pdata_int( id, m_iJoiningState ) == GAMESTATE_JOINTEAM ) || get_pdata_int( id, m_iPlayerTeam ) == 3 )
    {
        new Players[ 32 ], iNum[ 3 ];
        get_players( Players, iNum[ 2 ], "e", "CT" );
        get_players( Players, iNum[ 1 ], "e", "TERRORIST" );
       
        new szArg[ 4 ];
        read_argv( 1, szArg, charsmax( szArg ) );
       
        new iTeam = str_to_num( szArg );
       
        if( iNum[ iTeam ] >= get_pcvar_num( g_pcvarTeamLimit ) )
        {
            client_print( id, print_center, "The team is full!" );
            engclient_cmd( id, "jointeam", "3" );
           
            return PLUGIN_HANDLED;
        }
    }
   
    return PLUGIN_CONTINUE;
}
 
public Message_MOTD()
{
    return PLUGIN_HANDLED;
}
 
public Message_ShowMenu( iMsg, iDest, id )
{
    if( cs_get_user_team( id ) != CS_TEAM_UNASSIGNED )
        return PLUGIN_CONTINUE;
   
    static MESSAGE[] = "#Team_Select", szMsg[ charsmax( MESSAGE ) ];
    get_msg_arg_string( 4, szMsg, charsmax( szMsg ) );
 
    if( equal( szMsg, MESSAGE ) )
    {
        static data[ 2 ];
        data[ 0 ] = iMsg;
        set_task(0.1, "task_JoinTeam", id, data, sizeof(  data ) );
       
        return PLUGIN_HANDLED;
    }
   
    return PLUGIN_CONTINUE;
}
 
public Message_VGUIMenu( iMsg, iDest, id )
{  
    if( get_msg_arg_int( 1 ) != VGUI_SELECT_TEAM || cs_get_user_team( id ) != CS_TEAM_UNASSIGNED )
        return PLUGIN_CONTINUE;
   
    static data[ 2 ];
    data[ 0 ] = iMsg;
    set_task(0.1, "task_JoinTeam", id, data, sizeof(  data ) );
   
    return PLUGIN_HANDLED;
}
 
public task_JoinTeam( data[], id )
{
    static block;
   
    block = get_msg_block( data[ 0 ] );
    set_msg_block( data[0], BLOCK_SET );
    engclient_cmd( id, "jointeam", "6" );
    set_msg_block( data[0], block );
   
    set_pdata_int( id, m_bHasChangeTeamThisRound, 0, XO_PLAYER )
}
Attached Files
File Type: sma Get Plugin or Get Source (autospec_and_5v5teamlimit.sma - 1055 views - 3.0 KB)
__________________
--------------------------------------------------
C is for cookie ... thats good enuff 4 me

Last edited by CookieCrumbler; 02-10-2018 at 08:43.
CookieCrumbler is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 02-21-2018 , 10:46   Re: PUG Auto Spec on Connect & 5v5 Team lock
Reply With Quote #2

You can remove motd.txt or set motdfile cvar to "" to avoid motd display for all players.
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
vitorrossi
Senior Member
Join Date: Apr 2012
Location: NY, USA
Old 03-12-2018 , 14:55   Re: PUG Auto Spec on Connect & 5v5 Team lock
Reply With Quote #3

Code:
set_pdata_int( id, m_bHasChangeTeamThisRound, 0, XO_PLAYER )
This offset is a boolean. You should use set_pdata_bool instead
vitorrossi is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 03-12-2018 , 15:19   Re: PUG Auto Spec on Connect & 5v5 Team lock
Reply With Quote #4

Quote:
Originally Posted by vitorrossi View Post
Code:
set_pdata_int( id, m_bHasChangeTeamThisRound, 0, XO_PLAYER )
This offset is a boolean. You should use set_pdata_bool instead
No. The boolean offset is 521 - 20 = 501 for windows(the value to use with get/set_pdata_bool). The value he's using is 125, the converted value, so *_pdata_int is correct here. Tho, if you convert bool offsets most likely you are going to need to use flags to get the correct value.
__________________

Last edited by HamletEagle; 03-12-2018 at 15:20.
HamletEagle is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 03-12-2018 , 15:43   Re: PUG Auto Spec on Connect & 5v5 Team lock
Reply With Quote #5

Quote:
Originally Posted by vitorrossi View Post
Code:
set_pdata_int( id, m_bHasChangeTeamThisRound, 0, XO_PLAYER )
This offset is a boolean. You should use set_pdata_bool instead
That native is not available in 1.8.2 AFAIK.

The thing is that at offset 125 (byte offset 500) there are these two members:
Code:
bool m_bMissionBriefing; // 500
bool m_bTeamChanged; // 501
if you set 500 as an integer then you'll be setting 2 members actually.

You should use this Connor's set_pdata_bool as such:
PHP Code:
#if AMXX_VERSION_NUM < 183
const INT_BYTES 4;
const 
BYTE_BITS 8;

set_pdata_char(entcharbased_offsetvalueintbase_linuxdiff 5)
{
    
value &= 0xFF;
    new 
int_offset_value get_pdata_int(entcharbased_offset INT_BYTESintbase_linuxdiff);
    new 
bit_decal = (charbased_offset INT_BYTES) * BYTE_BITS;
    
int_offset_value &= ~(0xFF<<bit_decal); // clear byte
    
int_offset_value |= value<<bit_decal;
    
set_pdata_int(entcharbased_offset INT_BYTESint_offset_valueintbase_linuxdiff);
    return 
1;
}

set_pdata_bool(entcharbased_offsetbool:valueintbase_linuxdiff 5)
{
    
set_pdata_char(entcharbased_offset_:valueintbase_linuxdiff);
}
#endif 
__________________

Last edited by klippy; 03-12-2018 at 15:44.
klippy is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 04-13-2020 , 09:20   Re: PUG Auto Spec on Connect & 5v5 Team lock
Reply With Quote #6

https://forums.alliedmods.net/showthread.php?p=1643945
Unapproved.
__________________
HamletEagle is offline
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 11:02.


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