Skip to content

Instantly share code, notes, and snippets.

@Hoikas
Forked from ChristopherS/GetAllOnlinePlayers
Created February 7, 2013 20:54
Show Gist options
  • Save Hoikas/4734071 to your computer and use it in GitHub Desktop.
Save Hoikas/4734071 to your computer and use it in GitHub Desktop.
PyObject* pyVault::GetAllOnlinePlayers()
{
VaultPlayerInfoNode *playerNode;
PyObject *playerList = PyList_New(0);
playerNode->SetOnline(1);
ARRAY(unsigned) nodeIds;
VaultFindNodesAndWait(playerNode, &nodeIds); //<- here is the problem
if (nodeIds.Count())
{
// Only fetch the first matching node since this function returns a single node
for(int i=0; i<nodeIds.Count(); i++)
{
VaultFetchNodesAndWait(&nodeIds[i], 1);
playerNode = (VaultPlayerInfoNode *)VaultGetNodeIncRef(nodeIds[i]);
if(playerNode)
{
plString playerName = plString::FromWchar(playerNode->GetPlayerName());
PyObject *player = pyPlayer::New(playerName.c_str(), playerNode->GetPlayerId());
PyList_Append(playerList, player);
}
}
}
return playerList;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment