Raised This Month: $32 Target: $400
 8% 

CS:GO Force Team Join on Connect


Post New Thread Reply   
 
Thread Tools Display Modes
Ren3gade
Senior Member
Join Date: Jul 2010
Old 08-18-2013 , 19:24   Re: CS:GO Force Team Join on Connect
Reply With Quote #11

Quote:
Originally Posted by thetwistedpanda View Post
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);
    
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;


Thank you very much for this. I tested it and it forces players onto a team, which is great. But when I used it, it made it so the round wouldnt end? When all the Ts were dead, it didnt end. and when the round time ran out, it still didnt end the round and start a new one?
Ren3gade is offline
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 08-18-2013 , 19:34   Re: CS:GO Force Team Join on Connect
Reply With Quote #12

Did you happen to have mp_ignore_round_win_conditions enabled? It's possible I'm missing a key element of the system from the copy/paste - I know in my inital testings I had that problem happen and I made a temporary patch to auto create a buyzone/hostage to ensure it auto ended. But I had corrected that before grabbing the snippets.

Oh, something missing: I auto respawn on player_death.

Updated the above snippet with that in consideration.
__________________

Last edited by thetwistedpanda; 08-18-2013 at 19:55.
thetwistedpanda is offline
Ren3gade
Senior Member
Join Date: Jul 2010
Old 08-18-2013 , 21:41   Re: CS:GO Force Team Join on Connect
Reply With Quote #13

Quote:
Originally Posted by thetwistedpanda View Post
Did you happen to have mp_ignore_round_win_conditions enabled? It's possible I'm missing a key element of the system from the copy/paste - I know in my inital testings I had that problem happen and I made a temporary patch to auto create a buyzone/hostage to ensure it auto ended. But I had corrected that before grabbing the snippets.

Oh, something missing: I auto respawn on player_death.

Updated the above snippet with that in consideration.
I used that updated snippet, and now it forces you onto a team fine still, but once everyone is in the server, and a few people die and start respawning, it says Round Draw and then the round restarts. and it does that every time. :/

Bets.tf (http://www.gametracker.com/server_in...1.42.39:28015/) has theirs setup perfectly. Idk how, but they have it set so the Terrorist team is called Idlers, and CTs are Active. And when you are active/playing your on CT and you can kill the terrorists (idlers) and when your idle/afk you get moved to the idlers team. And the CTs can kill the Ts over and over and over again. It instantly respawns the Ts when they die, so CTs can constantly keep killing them and get achievements, and then there is 1 round per match. After the 5 minute round, the match ends and switches right back to the same map and forces players back onto teams.

and i checked my server.cfg and casual_server.cfg configs and neither of them have any commands with "mp_ignore_round_win_conditions"

Last edited by Ren3gade; 08-18-2013 at 21:47.
Ren3gade is offline
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 08-18-2013 , 22:40   Re: CS:GO Force Team Join on Connect
Reply With Quote #14

The team names are just mp_teamname_1 and mp_teamname_2 - these let you set your own team names. And I'm only posting the snippet to attempt auto team joining - I'm not posting my idle manager ;3.

Update:
I'll post snippets later - working method to bypass join team menu
On Connect
- "player_connect_full" - set their team and spawn them. I had glitches, so forced m_lifeState 0 pre-respawn.

On Match End
- "round_prestart" - loop through players, swap them to spec then back to their team, then respawn them. Like above, ran into weird glitches, forcing m_lifeState 0 corrected most of them.

Don't bother hooking CS_TerminateRound, specifically the *_GameStart reason. It will fire frequently until you narrow out all the kinks, but trying to block it isn't a solution. Lost 12-20 hours in this task alone before saying f*** it.
__________________

Last edited by thetwistedpanda; 09-07-2013 at 16:37.
thetwistedpanda is offline
cREANy0
SourceMod Donor
Join Date: Jul 2012
Location: Germany
Old 08-18-2013 , 23:51   Re: CS:GO Force Team Join on Connect
Reply With Quote #15

Quote:
Originally Posted by thetwistedpanda View Post
The team names are just mp_teamflag_1 and mp_teamflag_2 - these let you set your own team names. And I'm only posting the snippet to attempt auto team joining - I'm not posting my idle manager ;3.
unfortunately ;)
__________________

Last edited by cREANy0; 08-18-2013 at 23:51.
cREANy0 is offline
Zephyrus
Cool Pig B)
Join Date: Jun 2010
Location: Hungary
Old 09-24-2013 , 16:07   Re: CS:GO Force Team Join on Connect
Reply With Quote #16

Quote:
Originally Posted by Ren3gade View Post
I used that updated snippet, and now it forces you onto a team fine still, but once everyone is in the server, and a few people die and start respawning, it says Round Draw and then the round restarts. and it does that every time. :/

Bets.tf (http://www.gametracker.com/server_in...1.42.39:28015/) has theirs setup perfectly. Idk how, but they have it set so the Terrorist team is called Idlers, and CTs are Active. And when you are active/playing your on CT and you can kill the terrorists (idlers) and when your idle/afk you get moved to the idlers team. And the CTs can kill the Ts over and over and over again. It instantly respawns the Ts when they die, so CTs can constantly keep killing them and get achievements, and then there is 1 round per match. After the 5 minute round, the match ends and switches right back to the same map and forces players back onto teams.

and i checked my server.cfg and casual_server.cfg configs and neither of them have any commands with "mp_ignore_round_win_conditions"
as they are my servers you could have just asked me on steam lmao
__________________
Taking private C++/PHP/SourcePawn requests, PM me.
Zephyrus is offline
Ren3gade
Senior Member
Join Date: Jul 2010
Old 09-28-2013 , 23:53   Re: CS:GO Force Team Join on Connect
Reply With Quote #17

Quote:
Originally Posted by Zephyrus View Post
as they are my servers you could have just asked me on steam lmao
Oh those are yours lol. Didn't realize it!
Ren3gade is offline
kimo
Junior Member
Join Date: Jan 2009
Old 03-02-2014 , 10:11   Re: CS:GO Force Team Join on Connect
Reply With Quote #18

mark~~ try it
kimo is offline
raizo11
BANNED
Join Date: Dec 2013
Location: https://t.me/pump_upp
Old 03-14-2015 , 17:50   Re: CS:GO Force Team Join on Connect
Reply With Quote #19

Round time and timeleft unlimited....can u fixed this?
raizo11 is offline
Send a message via ICQ to raizo11 Send a message via AIM to raizo11 Send a message via MSN to raizo11 Send a message via Yahoo to raizo11 Send a message via Skype™ to raizo11
joao7yt
Senior Member
Join Date: Nov 2014
Location: Brazil
Old 08-21-2017 , 08:52   Re: CS:GO Force Team Join on Connect
Reply With Quote #20

Guys, I know it's late, but her it's the solution: https://forums.alliedmods.net/showthread.php?t=300549

Last edited by joao7yt; 08-21-2017 at 17:05.
joao7yt 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 09:04.


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