It's already coded to show a menu on event player_team, but it doesn't open a new menu if the previous menu has been called manually by the !models command for some reason.
This is how
Event_PlayerTeam calls the menu:
PHP Code:
public Event_PlayerTeam(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
new team = GetEventInt(event, "team");
if((team == 2 || team == 3) && IsValidClient(client) && !IsFakeClient(client))
{
Command_Model(client, 0);
}
return;
}
This works fine and if you switch teams, the old menu is closed and a new menu is opened.
But if you just do !models and call Command_Model
(RegConsoleCmd("sm_models", Command_Model);), the old menu is not closed on team switch:
PHP Code:
public Action:Command_Model(client,args)
{
mainmenu = BuildMainMenu(client);
if (mainmenu == INVALID_HANDLE)
{
return Plugin_Handled;
}
if(GetConVarInt(g_enabled) == 1 && !IsFakeClient(client))
{
mainmenu = BuildMainMenu(client);
DisplayMenu(mainmenu, client, GetConVarInt(g_CloseMenuTimer));
}
return Plugin_Handled;
}
The only difference that I see is that
client is set when Command_Model is called by Event_PlayerTeam, but not when you directly call it. I don't understand why the menu would close in the first case, but not the second