Quote from Bass-Driver  : hi, 
While working on a simple(should be simple) adminchat script. i Discovered a annoying issue i cannot solve. 
 
The script stores the messages in a textfile. 
After typing a message or entering the adminchat it loads the messages from the file. This works as it should be.  
 
But the right sequence of those messages are totally lost. 
 
Example: When you write a message : "2".  and the next message is "1". That message will load above the previous message "2". And the message after that: "3". Load below "2". 
 
Could someone give me a helping hand? 
 
Here's the code i made so far. 
 
 CatchEvent OnMSO( $userName, $text ) # Player event     $idxOfFirtsSpace = indexOf( $text, " ");     IF( $idxOfFirtsSpace == -1 ) THEN       $command = $text;       $argv = "";     ELSE       $command = subStr( $text,0,$idxOfFirtsSpace );       $argv = trim( subStr( $text,$idxOfFirtsSpace ) );     ENDIF     SWITCH( $command )             CASE "!adminchat":             CASE "!adchat":                 AdminChatWindow(0,0);                BREAK;     ENDSWITCH EndCatchEvent Sub AdminChatWindow($keyflags,$id)     UserGroupFromFile( "AdminChat", "User/AdminLog/AdminChat.txt" ); # Load File     #Design     openPrivButton( "bgd",60,50,80,64,1,-1,16,"");     openPrivButton( "Title",61,51,78,5,1,-1,32,"^3AdminChat Interface");     openPrivButton( "Close",134,51,5,5,1,-1,128,"^1X",CloseAdminChat);     openPrivButton( "Chatbgd",61,56,75,50,1,-1,32,"");     openPrivButton( "Scroll",136,61,3,40,1,-1,16,"");     openPrivTextButton( "WriteMessage",61,106,78,7,1,32,"^0Write Message","^2Write Message",50,WriteAdminMessage);          LoadAdminChatFromFile(0,0);#Load messages from file. EndSub Sub WriteAdminMessage( $KeyFlags,$argv  )     $ListAdminChat = GetListOfUsersGroup(AdminChat);         MoveUserToGroup( "AdminChat", getLapperVar( "ShortDate" )."-".getLapperVar( "ShortTime" ) ."|". GetCurrentPlayerVar( "UserName" )."|".$argv);     UserGroupToFile( "AdminChat", "User/AdminLog/AdminChat.txt" );          LoadAdminChatFromFile(0,0); #Load messages from file. EndSub Sub CloseAdminChat($keyflags,$id)     closePrivButton("bgd&Title&Close&Chatbgd&WriteMessage&ScrollUp&Scroll&ScrollDown");     closePrivButton($CloseAdminChat); EndSub Sub LoadAdminChatFromFile($keyflags,$id)     $ListAdminChat = GetListOfUsersGroup(AdminChat);     $MaxOfMessages= arrayCount($ListAdminChat);      $CloseAdminChat = "&Close";     $HT = 57; #Height of first message          #$Record[0] = Date/Time;     #$Record[1] = Username;     #$Record[2] = Message;          FOR ($ShowMessage=$MaxOfMessages-13;$ShowMessage<=$MaxOfMessages;$ShowMessage=$ShowMessage+1) #Last Message on bottomline.              $Record = SplitToArray($ListAdminChat[$ShowMessage], "|");              openPrivButton( "aploglist_".$ShowMessage,62,$HT,74,4,4,-1,64,"^6".$Record[0].": ^7".$Record[1]." >>> ^6".$Record[2]); #Show Message             $HT = $HT+4; #ButtonHeight+4             $CloseAdminChat = $CloseAdminChat ."&aploglist_".$ShowMessage;     ENDFOR EndSub
 
Fun fact: I have created a AdminLog system and i cannot solve this LOL. 
 
Edit: Fixed something in the code. Same result.