bool CloseNewMenus(CPlayer *pPlayer) { // If the stupid handler keeps drawing menus, // We need to keep cancelling them. But we put in a quick infinite loop // counter to prevent this from going nuts. int loops = 0; Menu *pMenu; while ((pMenu = get_menu_by_id(pPlayer->newmenu))) { pMenu->Close(pPlayer->index); if (++loops >= 10) { return false; } } return true; }
void CPlayer::Disconnect() { ingame = false; initialized = false; authorized = false; teamIdsInitialized = false; if (Menu *pMenu = get_menu_by_id(newmenu)) pMenu->Close(index); List<ClientCvarQuery_Info *>::iterator iter, end=queries.end(); for (iter=queries.begin(); iter!=end; iter++) { unregisterSPForward((*iter)->resultFwd); delete [] (*iter)->params; delete (*iter); } queries.clear(); menu = 0; newmenu = -1; }
static cell AMX_NATIVE_CALL menu_cancel(AMX *amx, cell *params) { int index = params[1]; if (index < 1 || index > gpGlobals->maxClients) { LogError(amx, AMX_ERR_NATIVE, "Player %d is not valid", index); return 0; } CPlayer *player = GET_PLAYER_POINTER_I(index); if (!player->ingame) { LogError(amx, AMX_ERR_NATIVE, "Player %d is not in game", index); return 0; } if (Menu *pMenu = get_menu_by_id(player->newmenu)) { pMenu->Close(player->index); return 1; } return 0; }