Click to See Complete Forum and Search --> : Arrays? Collection?


cnjmorris
May 8th, 2001, 04:15 PM
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?

Cakkie
May 9th, 2001, 02:03 AM
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
slisse@planetinternet.be

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

cnjmorris
May 9th, 2001, 02:35 PM
This answer is very helpful. I saw a vote on it... how do I show support for an answer?

W P Hames
May 9th, 2001, 03:26 PM
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.