Raised This Month: $65 Target: $400
 16% 

[CS:GO] Final and fancy solution for putting a player in a team on connect


Post New Thread Reply   
 
Thread Tools Display Modes
joao7yt
Senior Member
Join Date: Nov 2014
Location: Brazil
Old 09-06-2017 , 19:39   Re: [CS:GO] Final and fancy solution for putting a player in a team on connect
Reply With Quote #21

Quote:
Originally Posted by Neuro Toxin View Post
The spawn is the very first one from connect.

It's been a while since the update that fucked with this stuff.

Im pretty sure if you block the team menu the continue screen doesn't show.
No, the continue screen always show, there's no way to hide/close it. That being said and you agreeding with me that you can't change the client's team with that screen being showed because it will bug the team menu for that client, the way to hook when that screen is gone is hooking when "team" vguimenu appears. And it's what my code does.

You could "bypass" the bugs by adding a timer to put the client in a team when the "Continue" screen (this one) was gone, but if the player minimize the game, the "Continue" screen is paused, making the timer useless, since it would trigger "ChangeClientTeam" with the "Continue" screen being showed.

Last edited by joao7yt; 09-06-2017 at 19:40.
joao7yt is offline
Byte
Senior Member
Join Date: Jun 2010
Location: 📦 CCSPlayer
Old 11-13-2017 , 10:14   Re: [CS:GO] Final and fancy solution for putting a player in a team on connect
Reply With Quote #22

This post ended up helping me do something.
This is kinda crappy but...I hook the VGUIMenu, if its the first appearance, I move the client to spectator to get rid of the menu, then I show a new team menu one 0.1 seconds later.

The difference is the new menu doesn't have the countdown of mp_force_pick_time seconds. Also I want people to see the menu just without a countdown.

Some questions:
  • Is there a better way to block the first occurance of the usermessage?
  • Is there a way to handle which team a user joins normally if mp_force_pick_time reaches 0
  • Yes I know I could have just set mp_force_pick_time to a really high value

PHP Code:
public Action UserMessage_VGUIMenu(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];
    
    if (
g_IsFirstTeamSelection[client]) {
      
g_IsFirstTeamSelection[client] = false;
      
RequestFrame(UserMessage_VGUIMenu_NextFrameclient);
    }
  }
  
  return 
Plugin_Continue;
}

void UserMessage_VGUIMenu_NextFrame(int client)
{
  if (
IsClientInGame(client)) {
    
//Change client team to spectator to remove VGUIMenu
    
ChangeClientTeam(clientCS_TEAM_SPECTATOR);
    
CreateTimer(0.1Timer_ShowTeamMenuclient);
  }
}

public 
void OnClientConnected(int client)
{
  
g_IsFirstTeamSelection[client] = true;
}

public 
Action Timer_ShowTeamMenu(Handle Timerint client)
{
  if (
IsClientInGame(client))
    
UTIL_TeamMenu(client);
}

// This helper procedure will re-display the team join menu
// and is equivalent to what ClientCommand(client, "chooseteam") did in the past
void UTIL_TeamMenu(int client)
{
    
int clients[1];
    
Handle bf;
    
clients[0] = client;
    
bf StartMessage("VGUIMenu"clients1);
    
    if (
GetUserMessageType() == UM_Protobuf) {
        
PbSetString(bf"name""team");
        
PbSetBool(bf"show"true);
    }
    else {
        
BfWriteString(bf"team"); // panel name
        
BfWriteByte(bf1); // bShow
        
BfWriteByte(bf0); // count
    
}
    
    
EndMessage();

__________________
STEAM: /id/invexbyte | Github: InvexByte | My Community: Invex Gaming
My Plugins: Click Me!

Byte is offline
joao7yt
Senior Member
Join Date: Nov 2014
Location: Brazil
Old 11-13-2017 , 10:38   Re: [CS:GO] Final and fancy solution for putting a player in a team on connect
Reply With Quote #23

Quote:
Originally Posted by Byte View Post
This post ended up helping me do something.
This is kinda crappy but...I hook the VGUIMenu, if its the first appearance, I move the client to spectator to get rid of the menu, then I show a new team menu one 0.1 seconds later.

The difference is the new menu doesn't have the countdown of mp_force_pick_time seconds. Also I want people to see the menu just without a countdown.

Some questions:
  • Is there a better way to block the first occurance of the usermessage?
  • Is there a way to handle which team a user joins normally if mp_force_pick_time reaches 0
  • Yes I know I could have just set mp_force_pick_time to a really high value

PHP Code:
public Action UserMessage_VGUIMenu(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];
    
    if (
g_IsFirstTeamSelection[client]) {
      
g_IsFirstTeamSelection[client] = false;
      
RequestFrame(UserMessage_VGUIMenu_NextFrameclient);
    }
  }
  
  return 
Plugin_Continue;
}

void UserMessage_VGUIMenu_NextFrame(int client)
{
  if (
IsClientInGame(client)) {
    
//Change client team to spectator to remove VGUIMenu
    
ChangeClientTeam(clientCS_TEAM_SPECTATOR);
    
CreateTimer(0.1Timer_ShowTeamMenuclient);
  }
}

public 
void OnClientConnected(int client)
{
  
g_IsFirstTeamSelection[client] = true;
}

public 
Action Timer_ShowTeamMenu(Handle Timerint client)
{
  if (
IsClientInGame(client))
    
UTIL_TeamMenu(client);
}

// This helper procedure will re-display the team join menu
// and is equivalent to what ClientCommand(client, "chooseteam") did in the past
void UTIL_TeamMenu(int client)
{
    
int clients[1];
    
Handle bf;
    
clients[0] = client;
    
bf StartMessage("VGUIMenu"clients1);
    
    if (
GetUserMessageType() == UM_Protobuf) {
        
PbSetString(bf"name""team");
        
PbSetBool(bf"show"true);
    }
    else {
        
BfWriteString(bf"team"); // panel name
        
BfWriteByte(bf1); // bShow
        
BfWriteByte(bf0); // count
    
}
    
    
EndMessage();

  • You can suppress the team menu from showing when the player connects using sv_disable_show_team_select_menu 1. but that will disable it and people won't be able to press M. idk if you can force it showing using "PbSetBool(bf, "show", true);" tho...
  • You can use mp_force_assign_teams, but if you need to hook it and actually choose it, you need to see if some usermessage is called when the teammenu countdown ends, if so, just hook it. Use the follwing and watch your console.

PHP Code:
#pragma semicolon 1
#include <sourcemod>

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));
     
    
PrintToServer("%s"buffermsg);
    
    return 
Plugin_Continue;

joao7yt is offline
pride95
Senior Member
Join Date: Aug 2015
Old 03-08-2018 , 06:49   Re: [CS:GO] Final and fancy solution for putting a player in a team on connect
Reply With Quote #24

For CS:GO:

mp_force_pick_time 0
mp_force_assign_teams 0

HookEvent: player_connect_full, then requestframe changeclientteam.

This works without any bugs (like buying weapons). This is for people which don't want to use vguimenu.
pride95 is offline
joao7yt
Senior Member
Join Date: Nov 2014
Location: Brazil
Old 03-08-2018 , 07:38   Re: [CS:GO] Final and fancy solution for putting a player in a team on connect
Reply With Quote #25

Quote:
Originally Posted by pride95 View Post
For CS:GO:

mp_force_pick_time 0
mp_force_assign_teams 0

HookEvent: player_connect_full, then requestframe changeclientteam.

This works without any bugs (like buying weapons). This is for people which don't want to use vguimenu.
This can work for auto sorting the players evenly, but canít be used if you need to put a specific player, like using his steamid, in a specific team.
joao7yt is offline
pride95
Senior Member
Join Date: Aug 2015
Old 03-08-2018 , 08:36   Re: [CS:GO] Final and fancy solution for putting a player in a team on connect
Reply With Quote #26

Quote:
Originally Posted by joao7yt View Post
This can work for auto sorting the players evenly, but canít be used if you need to put a specific player, like using his steamid, in a specific team.
why not?
GetClientAuthId works in player_connect_full. then you check the steamid and use ChangeClientTeam.
pride95 is offline
joao7yt
Senior Member
Join Date: Nov 2014
Location: Brazil
Old 03-08-2018 , 12:44   Re: [CS:GO] Final and fancy solution for putting a player in a team on connect
Reply With Quote #27

Quote:
Originally Posted by pride95 View Post
why not?
GetClientAuthId works in player_connect_full. then you check the steamid and use ChangeClientTeam.
Thereís a 5 seconds countdown before you are assigned to a team. If you do a ChangeClientTeam before that countdown ends, it will bug the buy menu and etc... and no, itís not possible to just create a timer because if you minimize the game while the countdown is running, the countdown pauses...
joao7yt is offline
pride95
Senior Member
Join Date: Aug 2015
Old 03-08-2018 , 12:51   Re: [CS:GO] Final and fancy solution for putting a player in a team on connect
Reply With Quote #28

Quote:
Originally Posted by joao7yt View Post
Thereís a 5 seconds countdown before you are assigned to a team. If you do a ChangeClientTeam before that countdown ends, it will bug the buy menu and etc... and no, itís not possible to just create a timer because if you minimize the game while the countdown is running, the countdown pauses...
Quote:
Originally Posted by pride95 View Post
For CS:GO:

mp_force_pick_time 0
mp_force_assign_teams 0

HookEvent: player_connect_full, then requestframe changeclientteam.

This works without any bugs (like buying weapons). This is for people which don't want to use vguimenu.
read the bold text. this is tested. don't speak if you didn't tested my way. with mp_force_assign_teams that countdown doesn't exist so the bug with buymenu doesn't exist as well.
pride95 is offline
joao7yt
Senior Member
Join Date: Nov 2014
Location: Brazil
Old 03-08-2018 , 13:04   Re: [CS:GO] Final and fancy solution for putting a player in a team on connect
Reply With Quote #29

Quote:
Originally Posted by pride95 View Post
read the bold text. this is tested. don't speak if you didn't tested my way. with mp_force_assign_teams that countdown doesn't exist so the bug with buymenu doesn't exist as well.
If the countdown doesnít exists, it should work. iím not on my computer, as you didnít mentioned that the countdown doesnít even appear, I just speculated that that wouldnít work
joao7yt is offline
Sipro
Junior Member
Join Date: Dec 2016
Old 03-22-2018 , 15:13   Re: [CS:GO] Final and fancy solution for putting a player in a team on connect
Reply With Quote #30

It is working for CS:S?
Sipro 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 04:29.


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