I'm making a server/client program.
Right now I'm trying to make a list box on the server that lists the user names of logged in clients.
I've got a structure containing each logged in users' name and ID, and a vector to store them:
struct Player {
PlayerID ID;
char Name[32];
};
vector<Player> PlayerList;
When someone logs in the following is executed:
Player newuser;
newuser.ID = p->playerId;
for(int j = 0; j < 32; j++)
newuser.Name[j] = login[j];
PlayerList.push_back(newuser);
On logout I execute this:
for(int i=0;i < PlayerList.size(); i++)
{
if(p->playerId == PlayerList.at(i).ID)
{
PlayerList.erase(PlayerList.begin()+i);
i = PlayerList.size() + 5;
}
}
And when someone opens up the window with the listbox and clicks the populate button:
SendDlgItemMessage(listh, IDC_LST_PLAYER, LB_RESETCONTENT, (WPARAM) NULL, (LPARAM)NULL);
for(int i = 0; i < PlayerList.size(); i++)
SendDlgItemMessage(listh, IDC_LST_PLAYER, LB_ADDSTRING, (WPARAM) NULL, (LPARAM)PlayerList.at(i).Name);
}
Thing is my list always remains blank. Anyone see what I missed?
I'm doing this so that you can kick users...
If additional code is required just ask.
Last edited on
No one has said anything...
Did I word my question poorly?
Did I not provide enough information or code?
Last edited on