Get Current Online user of the channel under the Radar?
#21


1 hour ago, Andrein95 said:




/index.php?/profile/14423-nicolasg/&do=hovercard" data-mentionid="14423" href="/index.php?/profile/14423-nicolasg/" rel="">@nicolasg

Sorry to bother you, but maybe I'm a little bit confusing, why we introduce the varaible:


int PlayersCounter;


inside CNetwork.h and then we use ServerSelect.h?

 




To store the value received from the server. To later, in each frame, obtain the total number of players online. You could do the same thing in different ways, I chose that one. As for "iPlayerNum" it is simple, when we enter the server or channel selection scene, the number of players is sent from the server side. then that variable is not updated anymore. I guess you could reuse iPlayerNum instead of defining a new variable. In short, redundancy on my part due to lack of knowledge at that time...

#22

/index.php?/profile/14423-nicolasg/&do=hovercard" data-mentionid="14423" href="/index.php?/profile/14423-nicolasg/" rel="">@nicolasg

In my opinion you did well, in SessionStateInfo we can not access directly ChannelInfo, only using cascade if with pointer and make a lot of exxternal inclusion (server select,server info ecc)

IMPLEMENT_MSG_UPDATE(OnlinePlayers) {
UpdateClient::OnlinePlayersInfo* pPack = reinterpret_cast<UpdateClient::OnlinePlayersInfo*>(istr->GetBuffer());
_pNetwork->PlayersCounter = (pPack->PlayersOnline);
}

Here instead we can access directly without make dirty this function.

To summarize:

The nice approach would not be to load players counter for the first time in some constructor of the radar using pChannelInfo and then on RadarUpdate Function to retrieve from pNetwork?

#23


1 hour ago, Andrein95 said:




/index.php?/profile/14423-nicolasg/&do=hovercard" data-mentionid="14423" href="/index.php?/profile/14423-nicolasg/" rel="">@nicolasg



In my opinion you did well, in SessionStateInfo we can not access directly ChannelInfo, only using cascade if with pointer and make a lot of exxternal inclusion (server select,server info ecc)


IMPLEMENT_MSG_UPDATE(OnlinePlayers) {
UpdateClient::OnlinePlayersInfo* pPack = reinterpret_cast<UpdateClient::OnlinePlayersInfo*>(istr->GetBuffer());
_pNetwork->PlayersCounter = (pPack->PlayersOnline);
}


Here instead we can access directly without make dirty this function.



To summarize:



The nice approach would not be to load players counter for the first time in some constructor of the radar using pChannelInfo and then on RadarUpdate Function to retrieve from pNetwork?




Yes, you could skip all check statements, and copy the value from iPlayerNum into PlayersCounter just once. It would be a cleaner code and you would consume less resources in each execution of the loop

#24

/index.php?/profile/14423-nicolasg/&do=hovercard" data-mentionid="14423" href="/index.php?/profile/14423-nicolasg/" rel="">@nicolasg

I finished implementing all code you posted but in my side don't work as expected:

When the user log in the game, (juno for example) the counter remain 0 even if 3 or more players are online. When another player log in or log off the counter correctly update.

Another thing:

Inside ProConnMsg.cpp of GS you put:

case MSG_CONN_ONLINE_PLAYERS_RES:
SendOnlinePlayersToClients(msg);
break;

The function SendOnlinePlayersToClients following your code is defined in Descriptor.cpp, at this point:


Or SendOnlinePlayersToClients must be defined in ProConnMsg.cpp and method firm in ProConnMsg.h


Or must be accessed with namespace CDescriptor::SendOnlinePlayersToClients(msg); but this does not work, at least for me (since is not static function).


sorry to bother again but I'm trying to understeand what I miss in the implementation, I followeed more than one time code posted. In that case maybe you forgot to paste a portion of code? Becouse in your video the system works perfectly.

Thanks in Advance.

#25

After a lot of debugging I can see that:

sServerInfo* pServerInfo = pServerData->ServerListAt(pServerData->GetRecentServer() - 1);

Return NULL to me.

If it's correct that at first login stage, juno for example, the data must be retrivied from pChanneInfo and not from pNetwork maybe I have some initialization problem in: UIServerSelect.cpp

#26

/index.php?/profile/14423-nicolasg/&do=hovercard" data-mentionid="14423" href="/index.php?/profile/14423-nicolasg/" rel="">@nicolasg

Maybe we have a different structure on UIServerSelect. I'm using a clean nov of /index.php?/profile/2167-dethunter12/&do=hovercard" data-mentionid="2167" href="/index.php?/profile/2167-dethunter12/" rel="">@dethunter12 release.

BTW I managed to solve in this way:

Inside UIServerSelect.cpp simply initialize value of pNetwork variable.

In this mode is initializated the var inside CNetwork class for the first time and then updated from server messages. No any nested if to get pchannelInfo anymore.

Thanks for sharing your code.

/index.php?/profile/267-sutwick/&do=hovercard" data-mentionid="267" href="/index.php?/profile/267-sutwick/" rel="">@SutWick We can close this thread. Thanks



Forum Jump:


Users browsing this thread: 1 Guest(s)