I'm learning C++ and I've tried making an unordered_map of PlayerInfo, this being because I can use this as dynamic memory. I've gotten to this stage and I'm trying to further my knowledge and use it within my actual project.
To do this I want a function which says GetPlayerPointer(int playerid); and what I want this to do is return the position in the list so a piece of code to make this... well clearer.
??? GetPlayerPointer(int playerid)
{
auto point = BasicPlayerInfo.find(playerid);
return point->second;
}
This then will allow me to do something like
Player = GetPlayerPointer(playerid);
Player.Score = 10;
I'm atleast aiming for something along these lines.
I'm really sorry for asking, and thanks for your help.
Actual Code:
struct pBasicInfo
{
bool IsLoggedIn = false;
bool Spawned = false;
int AdminLevel = 0;
std::string PlayerName;
};
extern std::unordered_map<int, pBasicInfo> BasicPlayerInfo;
//CreatePlayer
pBasicInfo SetupPlayer;
SetupPlayer.IsLoggedIn = true;
SetupPlayer.Spawned = false;
SetupPlayer.PlayerName = GetName(playerid);
BasicPlayerInfo.insert(std::pair<int, pBasicInfo>(playerid, SetupPlayer));