0

I was wondering if there's any way to know if the "player" is signed in or not?

Something like this:

if (GamePad.GetState(PlayerIndex.Two).IsConnected && !Gamer.PlayerTwo.IsSignedIn)

Edit:

This way the controller is connected (the player can use the controller), but it's not signed in to any account, something like a guess.

Rotary Heart
  • 1,899
  • 3
  • 29
  • 44
  • I have flagged this for migration to our Game Development community where you will likely get more useful answers. – John McDonald Jul 05 '13 at 00:03
  • Ooo thanks, I didn't know there was a Game Development community. – Rotary Heart Jul 05 '13 at 00:05
  • 1
    Looking at my past flags for migration, not all have made it. I think most people prefer if you don't cross-post, but if you get impatient, the website is gamedev.stackexchange.com – John McDonald Jul 05 '13 at 00:51
  • @JohnMcDonald Uh... this is a programming question, not a gamedev question... though I admit it's worded weirdly enough to see how you misinterpreted it as that... at least I think. I read this as "How to check if Player2's controller is plugged in [and accepted in whatever weird way XBox handles that]" (IE, what's the function or variable to check this safely?) – mcmonkey4eva Jul 05 '13 at 02:00
  • I edited the question, I hope is clear enough now. – Rotary Heart Jul 05 '13 at 02:14
  • @mcmonkey4eva, That's exactly what gamedev.SE is all about: questions related to making games, and nearly all of those are about programming. Detecting if an XBox player is connected fits right in. – John McDonald Jul 05 '13 at 03:38
  • @JohnMcDonald gamedev.SE is intended more for vague questions, game design, etc. (And for really nooby sounding game-programming questions, which I admit this might count as) SO is for general programming including game programming. The #XNA tag is one of the many SO tags made exclusively for game programming questions. The two sites generally have a lot of overlap, but the general rule is leave the questions where they are unless there's a very clear reason to move them. (EG, a game design theory question here in SO would need to be moved) as programming is welcome in both, it should stayhere – mcmonkey4eva Jul 05 '13 at 04:24
  • @mcmonkey4eva Vague questions and huge percentage of "nooby sounding" questions are closed on GD.SE, and we close a *lot* of questions compared to other sites on the network. Please stop sending us the vague questions. TBH, I'm not sure where the line between SO and GD.SE lies, but that shouldn't be it. I'll start something in GD meta soon. – John McDonald Jul 05 '13 at 05:15
  • @John McDonald I got my answer from the page you gave me, thank you very much. – Rotary Heart Jul 05 '13 at 05:20
  • Cross posted: http://gamedev.stackexchange.com/questions/58616/how-to-know-if-the-player-is-signed-in – Flexo Jul 06 '13 at 16:12

1 Answers1

1

I'm answering this to mark it as answered, but please don't vote me up since I didn't answer it, go to: https://gamedev.stackexchange.com/questions/58616/how-to-know-if-the-player-is-signed-in/58618?noredirect=1#58618 and vote ToddersLegrande answer up.

In XNA there is a SignedInGamer class with a SignedInGamer.PlayerIndex member that should tell you just that if you can get a hold of the SignedInGamer object.

To do that, there is the Gamer.SignedInGamers static property which contains a collection of SignedInGamer objects based on the current state of the system. This is from the Microsoft.Xna.Framework.GamerServices namespace.

With this information you could do something like the following:

//If player 2 is connected
if (GamePad.GetState(PlayerIndex.Two).IsConnected)
{
    //If we can't find a signed in gamer with a PlayerIndex of two
    if (!Gamer.SignedInGamers.Cast<SignedInGamer>().Any(x => x.PlayerIndex == PlayerIndex.Two))
    {
        //Your handling code here
    }
}
Community
  • 1
  • 1
Rotary Heart
  • 1,899
  • 3
  • 29
  • 44