uid = 0 for all kinds of users
Because you need to login from external script...  Your external script is always anonymous to Drupal since no session has been created for external script user....

If you are trying to load all online users in an external script you can check who's online block implementation in user module..