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

[CS:GO] Help with force client join a team on connect


Post New Thread Reply   
 
Thread Tools Display Modes
joao7yt
Senior Member
Join Date: Nov 2014
Location: Brazil
Old 03-10-2016 , 22:57   Re: [CS:GO] Help with force client join a team on connect
Reply With Quote #31

I think we need a way to do this right after the player enter the sever, like in the Valve's servers. The team menu is disable and right after the screen with the "OK" button appears you are putted in the right team... Like said before, there's a way, but or the buy menu can't be used or the round won't get a winner when a whole team is dead... I think that there is more things than just "ChangeClientTeam(client, team);" to define if a player is in a team or not, because using "ChangeClientTeam(client, team);" when the player was never in any team yet, the round won't get a winner. Maybe a value of an EntProp...

If i'm not wrong, the eBot plugin and the Faceit plugin do that, like the Servers' Valve.

Last edited by joao7yt; 08-20-2017 at 14:45.
joao7yt is offline
splewis
Veteran Member
Join Date: Feb 2014
Location: United States
Old 03-11-2016 , 00:34   Re: [CS:GO] Help with force client join a team on connect
Reply With Quote #32

Quote:
Originally Posted by joao7yt View Post
I think we need a way to do this right after the player enter the sever, like in the Servers' Valve. The team menu is disable and right after the screen with the "OK" button appears you are putted in the right team... Like said before, there's a way, but or the buy menu can't be used or the round won't get a winner when a whole team is dead... I think that there is more things than just "ChangeClientTeam(client, team);" to define if a player is in a team or not, because using "ChangeClientTeam(client, team);" when the player was never in any team yet, the round won't get a winner. Maybe a value of an EntProp...

If i'm not wrong, the eBot plugin and the Faceit plugin do that, like the Servers' Valve.

Did you try using a joingame command listener? I've had no issues with calling CS_SwitchTeam inside that. (and there's m_iTeamNum fyi)

My only issue with forcing proper teams has been handling halftime periods.
__________________

Last edited by splewis; 03-11-2016 at 00:34.
splewis is offline
joao7yt
Senior Member
Join Date: Nov 2014
Location: Brazil
Old 03-11-2016 , 05:13   Re: [CS:GO] Help with force client join a team on connect
Reply With Quote #33

About the "jointeam", I'm already using that, but I was thinking about setting the player team without the change team menu...

Exc4libor, if you already did what you was doing, don't forget to post it
joao7yt is offline
splewis
Veteran Member
Join Date: Feb 2014
Location: United States
Old 03-11-2016 , 13:24   Re: [CS:GO] Help with force client join a team on connect
Reply With Quote #34

Quote:
Originally Posted by joao7yt View Post
About the "jointeam", I'm already using that, but I was thinking about setting the player team without the change team menu...

Exc4libor, if you already did what you was doing, don't forget to post it
That's why I'm telling you to use joingame which happens before the teamjoin menu has a chance to appear.
__________________
splewis is offline
joao7yt
Senior Member
Join Date: Nov 2014
Location: Brazil
Old 03-11-2016 , 14:33   Re: [CS:GO] Help with force client join a team on connect
Reply With Quote #35

Quote:
Originally Posted by splewis View Post
That's why I'm telling you to use joingame which happens before the teamjoin menu has a chance to appear.
There's a "joingame" command? I searched about it and I couldn't find anything... I can't test it right now, but I will.

Btw, what does this command? I have never used it...
joao7yt is offline
splewis
Veteran Member
Join Date: Feb 2014
Location: United States
Old 03-11-2016 , 16:41   Re: [CS:GO] Help with force client join a team on connect
Reply With Quote #36

Quote:
Originally Posted by joao7yt View Post
There's a "joingame" command? I searched about it and I couldn't find anything... I can't test it right now, but I will.

Btw, what does this command? I have never used it...
It gets automatically triggered when the client joins. Add a command listener for it and try it.
__________________
splewis is offline
joao7yt
Senior Member
Join Date: Nov 2014
Location: Brazil
Old 03-11-2016 , 16:43   Re: [CS:GO] Help with force client join a team on connect
Reply With Quote #37

Quote:
Originally Posted by splewis View Post
It gets automatically triggered when the client joins. Add a command listener for it and try it.
Good to know, will try as soon as possible
joao7yt is offline
joao7yt
Senior Member
Join Date: Nov 2014
Location: Brazil
Old 08-20-2017 , 21:34   Re: [CS:GO] Help with force client join a team on connect
Reply With Quote #38

Hey guys, I know it's been a long time, but I found a fancy solution, I got to hook when the Team Menu VGUI appears when you join the server. It doesn't need a timer and bypasses all the bugs related to it. Here's it:

PHP Code:
public void OnPluginStart()
{
    
HookUserMessage(GetUserMessageId("VGUIMenu"), TeamMenuHooktrue);
}

public 
Action TeamMenuHook(UserMsg msg_idProtobuf msg, const int[] playersint playersNumbool reliablebool init)
{
    
char buffermsg[64];
    
    
PbReadString(msg"name"buffermsgsizeof(buffermsg));
    
    if (
StrEqual(buffermsg"team"true))
    {
        
int client players[0];
        
        
//Do stuff here
        //You can acess the client's int as I defined it in "int client = players[0];"
        
        //Edit: Be warned that if you change the client's team here, it might throw a fatal error and crash the server.
        //      To prevent it, create a timer here (0.1 seconds seems to do the trick) and pass the client index through it.
    
}
    
    return 
Plugin_Continue;

Conclusion: only do ChangeClientTeam on player connect using this Hook, don't use "HookEvent("player_connect_full", ..., EventHookMode_Pre);" for this. You can use it for other stuff, tho. This way you will achieve the exact same way Valve does on their Match Making servers.

Last edited by joao7yt; 09-05-2017 at 19:17.
joao7yt is offline
splewis
Veteran Member
Join Date: Feb 2014
Location: United States
Old 08-21-2017 , 00:10   Re: [CS:GO] Help with force client join a team on connect
Reply With Quote #39

Quote:
Originally Posted by joao7yt View Post
Hey guys, I know it's been a long time, but I found a fancy solution, I got to hook when the Team Menu VGUI appears when you join the server. It doesn't need a timer and bypasses all the bugs related to it. Here's it:

PHP Code:
public void OnPluginStart()
{
    
HookUserMessage(GetUserMessageId("VGUIMenu"), TeamMenuHooktrue);
}

public 
Action TeamMenuHook(UserMsg msg_idProtobuf msg, const int[] playersint playersNumbool reliablebool init)
{
    
char buffermsg[64];
    
    
PbReadString(msg"name"buffermsgsizeof(buffermsg));
    
    if (
StrEqual(buffermsg"team"true))
    {
        
int client players[0];
        
        
//Do stuff here
        //You can acess the client's int as I defined it in "int client = players[0];"
    
}
    
    return 
Plugin_Handled;

Conclusion: only do ChangeClientTeam on player connect using this Hook, don't use "HookEvent("player_connect_full", ..., EventHookMode_Pre);" for this. You can use it for other stuff, tho. This way you will achieve the exact same way Valve does on their Match Making servers.
Hm, interesting... thanks for posting an update!
__________________
splewis is offline
joao7yt
Senior Member
Join Date: Nov 2014
Location: Brazil
Old 08-21-2017 , 00:20   Re: [CS:GO] Help with force client join a team on connect
Reply With Quote #40

Quote:
Originally Posted by splewis View Post
Hm, interesting... thanks for posting an update!
You are welcome. I didn't test it with the team menu disabled using that command to completely disable it, idk if it will work or not, maybe it will because i think the "team" VGUI always happens but its "show" bool must be false when that cvar is on. I will do some more tests tomorrow (or if you are up to test it...). If it works it will be amazing.
joao7yt 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 20:26.


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