PHP Code:
/* Mod Template generated by Pawn Studio */
#include <amxmodx>
#include <amxmisc>
#define PLUGIN "New Plugin"
#define VERSION "1.0"
#define AUTHOR "Unknown"
/* Initialization */
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("chooseteam", "chooseteam");
// Register commands, cvars and forwards here
}
public client_putinserver(id)
{
set_task(0.1, "selectteam", id);
return PLUGIN_CONTINUE;
}
public selectteam(id)
{
client_cmd(id, "chooseteam");
}
public chooseteam(id)
{
new ts[32];
new cts[32];
new tnum;
new ctnum;
// Get teams
get_players(ts, tnum, "e", "TERRORIST");
get_players(cts, ctnum, "e", "CT");
//select T
if (ctnum >= 2)
{
engclient_cmd(id, "menuselect", "1");
engclient_cmd(id, "menuselect", "5");
client_cmd(id, "slot1");
}
//select CT
else if (ctnum < 2)
{
engclient_cmd(id, "menuselect", "2");
engclient_cmd(id, "menuselect", "5");
client_cmd(id, "slot1");
}
return PLUGIN_HANDLED;
}
And i have problem in 80% it is working good.
But sometimes, i dont know why person is transfered to CT but there are 2 people. o_o
Or maybe it could be write better? In all forum is how to block team totally, but theres no information how to limit team for 2 persons only :d
And my code should work, but not always :/
Maybe thats problem with ID when client is putted in server?
sometimes it is loosing ?
__________________