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

CS:GO Force Team Join on Connect


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Ren3gade
Senior Member
Join Date: Jul 2010
Old 08-17-2013 , 07:57   CS:GO Force Team Join on Connect
Reply With Quote #1

I need a plugin that will fully disable the team select menu when you first join the server, or when the map changes, or when the match ends, or whenever. I want it to auto-throw every player onto CT or T and keep them balanced. I also would like MOTD to be disabled as well.

Can someone please help me with this?
Ren3gade is offline
cREANy0
SourceMod Donor
Join Date: Jul 2012
Location: Germany
Old 08-17-2013 , 08:57   Re: CS:GO Force Team Join on Connect
Reply With Quote #2

I need it too!
__________________
cREANy0 is offline
Wilczek
AlliedModders Donor
Join Date: Oct 2012
Location: Poland
Old 08-17-2013 , 12:10   Re: CS:GO Force Team Join on Connect
Reply With Quote #3

Have you tried mp_force_pick_time 0/1 ?
__________________
Wilczek is offline
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 08-17-2013 , 12:34   Re: CS:GO Force Team Join on Connect
Reply With Quote #4

Just changeclientteam inside of onclientputinserver. You'll bypass the jointeam menu. May require setting m_iclass before spawning. Haven't done extensive testing, only found it shortly before leaving computer for errands.
__________________
thetwistedpanda is offline
Ren3gade
Senior Member
Join Date: Jul 2010
Old 08-17-2013 , 15:33   Re: CS:GO Force Team Join on Connect
Reply With Quote #5

Quote:
Originally Posted by Wilczek View Post
Have you tried mp_force_pick_time 0/1 ?
Okay i set that and im pretty sure it works, but people may be getting stuck on the MOTD?
how can I disable MOTD? or is there a plugin to do it for me?
Ren3gade is offline
Ren3gade
Senior Member
Join Date: Jul 2010
Old 08-17-2013 , 15:38   Re: CS:GO Force Team Join on Connect
Reply With Quote #6

Yes, it works when you first join the server. But once the match ends and the map changes or whatever.. it doesn't force the team join for some reason?
and I just tried re-joining the server and it still sits on the MOTD.

Can someone point me in the right direction on this please?

Last edited by Ren3gade; 08-17-2013 at 15:39.
Ren3gade is offline
Ren3gade
Senior Member
Join Date: Jul 2010
Old 08-17-2013 , 15:39   Re: CS:GO Force Team Join on Connect
Reply With Quote #7

Quote:
Originally Posted by thetwistedpanda View Post
Just changeclientteam inside of onclientputinserver. You'll bypass the jointeam menu. May require setting m_iclass before spawning. Haven't done extensive testing, only found it shortly before leaving computer for errands.
I'm not really sure how to do that.
Ren3gade is offline
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 08-17-2013 , 17:46   Re: CS:GO Force Team Join on Connect
Reply With Quote #8

I had a bit more time to fiddle with this earlier. I can find no way to intercept the team selection panel. No combination of a dozen or so events, VGUI hooking for the actual "team" panel, etc will make it disappear on its own or properly prevent it from appearing. As such, it's not possible to make the menu automatically disappear after a match restarts (without map change).

The closest work around that I'm still trying to iron out the kinks for is hooking player_activate (or possibly player_connect_full) and doing the logic to force spawn players there. On first connect, this usually results in the menu for selecting initial teams to be skipped and correctly spawns bots as living, but of course the MOTD still remains. At the end of the match, cs_match_end_restart gets fired, and here you can once again force them to spawn, yet the team selection panel appears and waits for user input. Since this fires "jointeam" again, in theory you can save their pre-spawned team, ignore the input to jointeam, and then the player should already be alive waiting to be played. If I get the clusterfuck running properly I'll post the code.


Scroll Down - Panduh Did Good!
__________________

Last edited by thetwistedpanda; 08-18-2013 at 15:04. Reason: Relevant post below.
thetwistedpanda is offline
Ren3gade
Senior Member
Join Date: Jul 2010
Old 08-17-2013 , 22:30   Re: CS:GO Force Team Join on Connect
Reply With Quote #9

Quote:
Originally Posted by thetwistedpanda View Post
I had a bit more time to fiddle with this earlier. I can find no way to intercept the team selection panel. No combination of a dozen or so events, VGUI hooking for the actual "team" panel, etc will make it disappear on its own or properly prevent it from appearing. As such, it's not possible to make the menu automatically disappear after a match restarts (without map change).

The closest work around that I'm still trying to iron out the kinks for is hooking player_activate (or possibly player_connect_full) and doing the logic to force spawn players there. On first connect, this usually results in the menu for selecting initial teams to be skipped and correctly spawns bots as living, but of course the MOTD still remains. At the end of the match, cs_match_end_restart gets fired, and here you can once again force them to spawn, yet the team selection panel appears and waits for user input. Since this fires "jointeam" again, in theory you can save their pre-spawned team, ignore the input to jointeam, and then the player should already be alive waiting to be played. If I get the clusterfuck running properly I'll post the code.
Damn, i didnt think it would be this difficult lol. Thanks man!
Ren3gade is offline
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 08-18-2013 , 15:01   Re: CS:GO Force Team Join on Connect
Reply With Quote #10

This is the result of god knows how many hours of testing (~20?) and head banging attempting to get the desired results for my private idle manager / drop detector plugin. This specific paste wasn't tested, but it's a copy/paste of the important parts of my plugin, which works as desired, so this should work too as long as I didn't derp somewhere.

This prevents the first team selection menu from appearing, and if a new match occurs (without team change), somehow manages to automatically close the team selection panel (this was an accidental side effect). I can't attest to how this works in normal game play though, as my goal was for Idle/Achievement servers. If it works for you, feel free to support my booze fund in my signature, as after this headache I could definitely use a few bottles . *quietly weeps at the loss of potential sales from posting this*

PHP Code:
#include <cstrike>
#include <sourcemod>
#include <sdktools>

public OnPluginStart()
{
    
HookEvent("player_connect_full"Event_OnFullConnectEventHookMode_Pre);
    
HookEvent("cs_match_end_restart"Event_OnMatchRestartEventHookMode_Pre);
    
HookEvent("player_team"Event_OnPlayerTeamEventHookMode_Pre);
    
HookEvent("player_death"Event_OnPlayerDeathEventHookMode_Pre);
    
AddCommandListener(Command_Join"jointeam");
}

public 
Action:Event_OnFullConnect(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    if(!
client || !IsClientInGame(client))
        return 
Plugin_Continue;

    new 
iRediBlue;
    for(new 
1<= MaxClientsi++)
    {
        if(!
IsClientInGame(i))
            continue;

        new 
iTeam GetClientTeam(i);
        if(
iTeam == CS_TEAM_T)
            
iRed++;
        else if(
iTeam == CS_TEAM_CT)
            
iBlue++;
    }

    if(
iRed iBlue)
        
SetEntProp(clientProp_Send"m_iTeamNum"CS_TEAM_T);
    else
        
SetEntProp(clientProp_Send"m_iTeamNum"CS_TEAM_CT);

    
ForcePlayerSuicide(client);
    
CS_RespawnPlayer(client);
    return 
Plugin_Continue;
}

public 
Action:Event_OnMatchRestart(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
iRediBlueiJoin;
    for(new 
1<= MaxClientsi++)
    {
        if(!
IsClientInGame(i))
            continue;

        switch(
GetClientTeam(i))
        {
            case 
CS_TEAM_T:
                
iRed++;
            case 
CS_TEAM_CT:
                
iBlue++;
        }
    }

    for(new 
1<= MaxClientsi++)
    {
        if(!
IsClientInGame(i))
            continue;

        if(
iRed iBlue)
            
iJoin CS_TEAM_T;
        else if(
iBlue iRed)
            
iJoin CS_TEAM_CT;
        else
            
iJoin GetRandomInt(CS_TEAM_TCS_TEAM_CT);

        switch(
iJoin)
        {
            case 
CS_TEAM_T:
                
iRed++;
            case 
CS_TEAM_CT:
                
iBlue++;
        }

        
ChangeClientTeam(iiJoin);
    }
}

public 
Action:Event_OnPlayerTeam(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    if(!
client || !IsClientInGame(client))
        return 
Plugin_Continue;

    if(!
IsPlayerAlive(client))
        
CreateTimer(0.1Timer_RespawnGetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
    return 
Plugin_Continue;
}

public 
Action:Timer_Respawn(Handle:timerany:userid)
{
    new 
client GetClientOfUserId(userid);
    if(!
client)
        return 
Plugin_Continue;

    new 
iTeam GetClientTeam(client);
    if(
iTeam <= CS_TEAM_SPECTATOR)
        return 
Plugin_Continue;

    if(
IsPlayerAlive(client))
        return 
Plugin_Continue;

    
CS_RespawnPlayer(client);

    return 
Plugin_Continue;
}

public 
Action:Command_Join(client, const String:command[], argc)
{
    
decl String:sJoining[8];
    
GetCmdArg(1sJoiningsizeof(sJoining));
    new 
iJoining StringToInt(sJoining);
    if(
iJoining == CS_TEAM_SPECTATOR)
        return 
Plugin_Continue;

    new 
iTeam GetClientTeam(client);
    if(
iJoining == iTeam)
        return 
Plugin_Handled;
    else
    {
        
SetEntProp(clientProp_Send"m_iTeamNum"iJoining);
        
ForcePlayerSuicide(client);
        
CS_RespawnPlayer(client);
    }

    return 
Plugin_Continue;
}


public 
Action:Event_OnPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    if(!
client || !IsClientInGame(client))
        return 
Plugin_Continue;

    
CreateTimer(0.1Timer_RespawnGetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);

    return 
Plugin_Continue;

__________________

Last edited by thetwistedpanda; 08-18-2013 at 19:55. Reason: Forgot an event.
thetwistedpanda is offline
Reply



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 07:12.


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