CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2001
    Posts
    5

    Arrays? Collection?

    I am making an online version of a board game and I need some suggestions on handling the logins. PURPOSE: assigning turn order.

    Currently they log in and are assigned a connection using a winsock array.

    Lets assume they are assigned wsS(1)


    1) Their client rolls a die and sends result to server. I need a way for server to store the persons login name and their roll. I am trying to figure out how to store the itms something like this player(name,roll). Is this possible? Is there a better way?

    I looked at some info on arrays and collections but didn't really see examples of what I want. It looks like I can't do this:

    players(1,1) = player,roll

    If I were to use a collection would this work:

    dim myPlayers as New Collection
    myPlayers.Add Player, Roll

    If I did that how would I keep track of player index? How do I call them back out of a collection?

    __________________________________________________

    2) If someone is disconnected I need to figure out how to get them reconnected and retain all the possessions that their character had. I thought about having the server assign the players a "session password" and send it to the client which would save it to a txt file. When they try to connect again it would match their password with the servers for that player. Is this a good or bad idea?


  2. #2
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: Arrays? Collection?

    You can use an array of a userdefined type for something like this. In the type, you can add any data you want. You could give the array index the same number as the winsock index, so player(1) has wsS(1)

    ' this is the player type
    private Type PlayerType
    Name as string
    Roll as Integer
    Score as Long
    End Type
    Dim Players() as PlayerType




    Tom Cannaerts
    [email protected]

    Programming today is a race between software engineers striving to build bigger and better idot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  3. #3
    Join Date
    May 2001
    Posts
    5

    Re: Arrays? Collection?

    This answer is very helpful. I saw a vote on it... how do I show support for an answer?


  4. #4
    Join Date
    Jul 2000
    Location
    Baton Rouge, Louisiana, USA
    Posts
    51

    Re: Arrays? Collection?

    You select his answer. Under it, near the bottom of the screen on the right, is a list box where you can rate his answer.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured