AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [CS:GO] Final and fancy solution for putting a player in a team on connect (https://forums.alliedmods.net/showthread.php?t=300549)

joao7yt 09-06-2017 18:39

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

Originally Posted by Neuro Toxin (Post 2547190)
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.

Byte 11-13-2017 09:14

Re: [CS:GO] Final and fancy solution for putting a player in a team on connect
 
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();



joao7yt 11-13-2017 09:38

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

Originally Posted by Byte (Post 2560209)
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;



pride95 03-08-2018 05:49

Re: [CS:GO] Final and fancy solution for putting a player in a team on connect
 
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.

joao7yt 03-08-2018 06:38

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

Originally Posted by pride95 (Post 2581908)
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.

pride95 03-08-2018 07:36

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

Originally Posted by joao7yt (Post 2581910)
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.

joao7yt 03-08-2018 11:44

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

Originally Posted by pride95 (Post 2581919)
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...

pride95 03-08-2018 11:51

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

Originally Posted by joao7yt (Post 2581944)
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 (Post 2581908)
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.

joao7yt 03-08-2018 12:04

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

Originally Posted by pride95 (Post 2581947)
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

Sipro 03-22-2018 14:13

Re: [CS:GO] Final and fancy solution for putting a player in a team on connect
 
It is working for CS:S?


All times are GMT -4. The time now is 23:34.

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