Plugin creation, restricting access to specific roles

WordPress previously had the concept of user levels before and you could check which level current user is. But it has been changed to Roles and Capabilities system. In this system, each task is defined as a capability and certain user Roles have that capability.

With this, you can create new capabilities. Say, you want to create a new user Roles(Apart from built in Super Admin, Administrator, Editor, Author, Contributor Subscriber Roles) who have new capabilities created by you. It gives great flexibility. You can also tweak the built in capabilities if needed.

If your only need is to check if a user has certain Role, say Administrator, you should check what capabilities an Administrator has that the next Role doesn’t have. By default, an Administrator has the following capabilities that an Editor doesn’t have

  • activate_plugins
  • create_users
  • delete_plugins
  • delete_themes
  • delete_users
  • edit_files
  • edit_plugins
  • edit_theme_options
  • edit_themes
  • edit_users
  • export
  • import
  • install_plugins
  • install_themes
  • list_users
  • manage_options
  • promote_users
  • remove_users
  • switch_themes
  • update_core
  • update_plugins
  • update_themes
  • edit_dashboard

You can see the full list in Capability vs Role table

The function that checks whether current user has an capability is current_user_can

So, to check if the current user is an Administration, you can do

if( current_user_can('activate_plugins) ){
    //do what only the admin user should do
}

OR

if( current_user_can('create_users') ){
    //do what only the admin user should do
}

OR

if( current_user_can('manage_options') ){
    //do what only the admin user should do
}

and so on

The same rule applies for other user Roles.

What capability to use is totally your choice, but what I prefer to do is to use capabilities related to the task that is being done. For instance, if I’m working on an option page(Admin menu panel) I prefer to check current_user_can('manage_options')

To answer second part of your question(if I understood correctly), if you want to create an Admin menu page, you should use add_menu_page

The third argument of this function is $capability. What capability you provide here determines what Role of user can access that page. If you provide 'manage_options', only an Administrator can access that page. If you provide 'delete_posts', Author, Editor and Administrator can access that page.