I know this post is old, but maybe helping this for another coder:
new g_sv_allplayers = 0
new g_sv_maxplayers = 0
new g_sv_imaxplayers = 0
register_event("TeamInfo", "event_jointeam", "a")
g_firstjoin[id] = true
new id = read_data(1)
if (g_firstjoin[id] == true)
if (g_sv_imaxplayers > g_sv_maxplayers) g_sv_maxplayers ++;
g_firstjoin[id] = false
g_sv_allplayer means all connected players
g_sv_allplayer means highest value of playernum on the map.
of course you can handle it per team as well.