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_id, Protobuf msg, const int[] players, int playersNum, bool reliable, bool init)
{
char buffermsg[64];
PbReadString(msg, "name", buffermsg, sizeof(buffermsg));
if (StrEqual(buffermsg, "team", true)) {
int client = players[0];
if (g_IsFirstTeamSelection[client]) {
g_IsFirstTeamSelection[client] = false;
RequestFrame(UserMessage_VGUIMenu_NextFrame, client);
}
}
return Plugin_Continue;
}
void UserMessage_VGUIMenu_NextFrame(int client)
{
if (IsClientInGame(client)) {
//Change client team to spectator to remove VGUIMenu
ChangeClientTeam(client, CS_TEAM_SPECTATOR);
CreateTimer(0.1, Timer_ShowTeamMenu, client);
}
}
public void OnClientConnected(int client)
{
g_IsFirstTeamSelection[client] = true;
}
public Action Timer_ShowTeamMenu(Handle Timer, int 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", clients, 1);
if (GetUserMessageType() == UM_Protobuf) {
PbSetString(bf, "name", "team");
PbSetBool(bf, "show", true);
}
else {
BfWriteString(bf, "team"); // panel name
BfWriteByte(bf, 1); // bShow
BfWriteByte(bf, 0); // count
}
EndMessage();
}
__________________