View Single Post
Byte
Senior Member
Join Date: Jun 2010
Location: 📦 CCSPlayer
Old 11-13-2017 , 09: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: Mo Beigi | Discord: Byte#0017
Community: Invex Gaming | My Plugins: Click Me!

Byte is offline