XNA Creators Club Online
Page 1 of 1 (4 items)
Sort Posts: Previous Next

[2.0] How do I get the gamer picture of a local System Link gamer?

Last post 27/11/2007 17:42 by Shawn Hargreaves. 3 replies.
  • 27/11/2007 16:29

    [2.0] How do I get the gamer picture of a local System Link gamer?

    I'm in the NetRumble starter kit using System Link and local profiles to connect two PCs together. I would like to modify the code to display the gamer's picture along side their name (name was retreived via networkGamer.Gamertag). I tried using a line like: Texture2D tagTexture = networkGamer.GetProfile().GamerPicture; but this throws an exception and seems to be trying to get the Live profile and not the local profile.  Is there anyway to get at a local gamer's picture?

  • 27/11/2007 16:52 In reply to

    Re: [2.0] How do I get the gamer picture of a local System Link gamer?

    It's the same method for both local profiles and remote profiles. What exception was thrown? Have you initialized the GamerServicesComponent?
  • 27/11/2007 17:38 In reply to

    Re: [2.0] How do I get the gamer picture of a local System Link gamer?

    The exception thrown from the line networkGamer.GetProfile().GamerPicture is a GamerPrivilegeException. The description from VC# is: A signed in gamer profile is required to perform this operation. A Live profile may also be required. There are no profiles currently signed in, or the profile is not signed in to Live.

    I'm fairly certain that GamerServicesComponent is initialized since everything works great without this one line added in. Curiously I see in the debugger that when this exception is thrown networkGamer.IsLocal is set to false but I would expect it to be true since I'm using local profiles. Perhaps I'm not understanding the local vs. Live profile.

     

    Here are the steps to reproduce:

    1.) Create a new project with the Net Rumble Windows Starter kit.

    2.) Modify the method DrawPlayerData in World.cs to include this block of code after you draw the player's gamerTag (line 1143):

    Texture2D tagTexture = networkGamer.GetProfile().GamerPicture;

    float tagTextureScale = 0.9f * playerStringSize.Y / (float)tagTexture.Height;
    Vector2 tagTexturePosition = new Vector2(playerStringPosition.X -
    1.2f * playerStringSize.X / 2f -
    1.1f * tagTextureScale * (float)tagTexture.Width / 2f,
    playerStringPosition.Y);
    spriteBatch.Draw(tagTexture, tagTexturePosition, null,
    Color.White, 0f, new Vector2((float)tagTexture.Width / 2f,
    (float)tagTexture.Height / 2f), tagTextureScale,
    SpriteEffects.None, 0f);

     

    3.) Build and run with two PCs. Create local profiles on each machine (that is, don't sign in to Live). One computer selects "Create System Link Session," the other computer selects: "Join System Link Session."

    4.) When the second computer has joined the session the program crashes with an unhandled GamerPrivilegeException.

    Thanks.

  • 27/11/2007 17:42 In reply to

    Re: [2.0] How do I get the gamer picture of a local System Link gamer?

    Answer
    Reply Quote
    Reading gamer profile data for non-local profiles is a Live function, implemented by querying information for that gamer from the Live service. This will work even in system link sessions as long as the profile is Live (and the person reading the data is signed into Live so as to be able to make the query) but there is no way to look up this data for remote non-Live profiles.
    XNA Framework Developer - blog - homepage
Page 1 of 1 (4 items) Previous Next