How can I recognize the last iteration in a C++ while loop? -
How do I do that the last player's name is not ,
then it is:
Player Online: Jim, John, Tony
and not
Player Online: Jim, John, Tony,
My code is:
bool commands :: whoIsOnline (creature * c, const std :: string and cmd, const std :: string & ultimate ) {Player * player = dynamic_count & lt; Player * & gt; (C); If (player) {player-> SendTextMessage (MSG_STATUS_CONSOLE_BLUE, "player online:"); Autologist and lieutenant; Player & gt; :: Litterator IARR = Player :: listPlayer.list.begin (); Std :: String information; Int count = 0; While (IARR = Player :: listPlayer.list.end ()) {info + = (* iter) .second-> GetName () + "," ;; ++ ITER; ++ count; If (calculated% 10 == 0) {player-> SendTextMessage (MSG_STATUS_CONSOLE_BLUE, info.c_str ()); Info.clear (); }} If (Info.empty ()) player- & gt; Send Text Message (MSG_STATUS_CONSOLE_BLUE, info.c_str ()); } Back true; Instead of thinking it instead, player + ","
it
"," + player
, then you can do something like (psuedo-code):
But first name = true output = = "," output = = player name
if your language supports it (if it does C ++): if ONFSTNNAME: ONFERST_NAME = Incorrect Other: Output =):
If the player length & gt; 0: Output = Players [0] For players in players except [0]: Output + = "," + Player name Other: Output = ""
I like After all, I have to invent the language which actually works like this.
Comments
Post a Comment