|
@@ -8,7 +8,7 @@
|
|
|
|
|
|
#pragma newdecls required
|
|
|
|
|
|
-#define PLUGIN_VERSION "1.0.0"
|
|
|
+#define PLUGIN_VERSION "1.1.0"
|
|
|
public Plugin myinfo = {
|
|
|
name = "[CSRD] `jointeam` Fix",
|
|
|
author = "nosoop",
|
|
@@ -30,6 +30,9 @@ public void OnPluginStart() {
|
|
|
tf_arena_use_queue = FindConVar("tf_arena_use_queue");
|
|
|
|
|
|
AddCommandListener(OnClientJoinTeam, "jointeam");
|
|
|
+
|
|
|
+ UserMsg vguiMessage = GetUserMessageId("VGUIMenu");
|
|
|
+ HookUserMessage(vguiMessage, OnVGUIMenuPreSent, true);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -53,6 +56,42 @@ Action OnClientJoinTeam(int client, const char[] command, int argc) {
|
|
|
return Plugin_Continue;
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * Intercepts attempts to transmit the team select panel to a client, delaying transmission if
|
|
|
+ * the player is unassigned and on cooldown.
|
|
|
+ */
|
|
|
+Action OnVGUIMenuPreSent(UserMsg vguiMessage, BfRead buffer, const int[] players,
|
|
|
+ int nPlayers, bool reliable, bool init) {
|
|
|
+ // vgui usermessages are expected to only have a single recipient
|
|
|
+ if (nPlayers != 1) {
|
|
|
+ return Plugin_Continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ char name[128];
|
|
|
+ buffer.ReadString(name, sizeof(name));
|
|
|
+
|
|
|
+ if (!StrEqual(name, "arenateampanel") && !StrEqual(name, "team")) {
|
|
|
+ return Plugin_Continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ int client = players[0];
|
|
|
+ if (GetClientTeam(client)) {
|
|
|
+ return Plugin_Continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ float flNextAllowedTeamChange = GetEntDataFloat(client,
|
|
|
+ offs_CTFPlayer_flNextTimeAllowTeamChange);
|
|
|
+ if (flNextAllowedTeamChange > GetGameTime()) {
|
|
|
+ // we're not allowed to change teams right now --
|
|
|
+ // silently block the attempt then redisplay once the cooldown is over
|
|
|
+ CreateTimer(0.1 + flNextAllowedTeamChange - GetGameTime(), RedisplayTeamSelectMenu,
|
|
|
+ GetClientSerial(client), TIMER_FLAG_NO_MAPCHANGE);
|
|
|
+ return Plugin_Handled;
|
|
|
+ }
|
|
|
+
|
|
|
+ return Plugin_Continue;
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* Redisplay the team select panel.
|
|
|
*/
|