Hello,
this plugin controls the team selection of players so that there are even teams in the beginning, and later so that people can join the losing team. It's based on
bmann's Teamlocker plugin
In the first 2 minutes of a map: forces players to use auto-select (5) by disabling T (1) and CT (2) selection.
After 2 minutes: Locks auto select (5) and unlocks T (1) and CT (2) so people can join the weaker team.
The plugin looks at both the team menu (command "chooseteam") and the "jointeam" console command. I also had to prevent vgui menus since they allowed to bypass the lock for whatever reason.
Basically the plugin works, but every now and then I get people connecting late and joining the winning team excusing themselves with:
"It's not my fault, I pressed 5 and the server put me in that team".
Since auto-select is disabled at that moment, they must be either lying or there is some way not covered in this plugin.
Can anyone think of any way to bypass the plugin?
PHP Code:
/*
* Original Teamlocker version by Bmann_420
*
* https://forums.alliedmods.net/showthread.php?t=48251
*/
new const PLUGIN[] = "Teamlocker";
new const VERSION[] = "1.8"
new const AUTHOR[] = "Aydeev";
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#define TERROR 1
#define CT 2
#define AUTO 5
new bool:blockjoining[6]
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR);
register_menucmd(register_menuid("Team_Select",1), (1<<0)|(1<<1)|(1<<4), "team_select");
register_clcmd("jointeam", "join_team");
register_message(get_user_msgid("VGUIMenu"), "prevent_vgui_menu")
blockjoining[TERROR] = true
blockjoining[CT] = true
set_task( 120.0, "unlockTeams" )
}
public prevent_vgui_menu(msgid, dest, id) {
if (get_msg_arg_int(1) == 2 ) {
set_user_info(id, "_vgui_menus", "0")
client_cmd(id, "chooseteam")
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
public team_select(id, key)
{
check_blocked(id, key+1)
return PLUGIN_HANDLED
}
public join_team(id)
{
new arg[2]
read_argv(1, arg, 1)
check_blocked(id, str_to_num(arg))
return PLUGIN_HANDLED
}
public check_blocked(id, team) {
new teamstring[2]
num_to_str(team, teamstring,1)
//Admin immunity
if (get_user_flags(id) & ADMIN_KICK )
{
engclient_cmd(id, "jointeam", teamstring)
return PLUGIN_HANDLED
}
// Selected team is blocked, try again and print message
if ( blockjoining[team])
{
engclient_cmd(id, "chooseteam")
switch(team)
{
case AUTO: client_print(id, print_chat, "[Teamlocker] Auto-select disabled. Check the scores and join the losing team")
default: client_print(id, print_chat,"[Teamlocker] Manual team picking disabled. Use 5 (Auto-select) to be assigned to a team")
}
return PLUGIN_HANDLED
}
// Selected team is not blocked, so join the team
engclient_cmd(id, "jointeam", teamstring)
return PLUGIN_HANDLED
}
public unlockTeams(id) {
blockjoining[TERROR] = false
blockjoining[CT] = false
blockjoining[AUTO] = true
client_print(0, print_chat, "[Teamlocker] Terrorists and Counter-Terrorists unlocked")
return PLUGIN_HANDLED
}