How to limit the number of posts a user can publish based on user type

I found this plugin Bainternet Posts Creation Limits witch let you add how meny post a user, role or group can create. The plugin description says:

Main Feature:

  • Limit number of any post type creation.
  • Select Post Status to count. (NEW)
  • Limit number of any post type creation by user Role. (NEW)
  • Limit number of any post type creation by user ID. (NEW)
  • New Limit Rule System (faster and stable).
  • Custom blocked message For each Rule. (NEW)
  • MultiSite Support. (Fixed and works better then before)
  • ADD NEW Links are removed when limit is reached (NEW)
  • 0 Now means ZERO so Its actually blocks the user from creating at
    all.
  • Shortcode to limit front end post creation (NEW).

It looks like you have a function that matches your question: Limit number of any post type creation by user Role.

error code: 523