View Single Post
  #1  
Old 12-03-2012, 01:47 AM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
Sorting through multiple arrays

I've got it sorted through like recommended above for the most part, but am now having issues sorting when showing "all" messages with timevar2. timevar2 is the [2] value in each client array for each message.

My logic is probably flawed on here, and/or I'm missing something really easy.

PHP Code:
this.categoryArr = {"mass", "tell", "system", "guild"}; 
PHP Code:
function showAllMessages()
{
  
//showMassMessages();
  //showSystemMessages();
  //showTellMessages();
  //showGuildMessages();
  
  // set size of all messages
  
temp.messageSize = client.mass.messages.size() + client.system.messages.size() + client.tell.messages.size() + client.guild.messages.size();
  
  
// set images to correlate with categoryArr
  
temp.messagesImg = {"pmbubble_mass.png", "pmbubble_normal.png", "pmbubble_admin.png", "pmbubble_guild.png"};
  
  
// random number for image id
  
temp.rdnID = random(1, 99999);
  
  
// sort through all messages set so far per size
  
for (temp.i = 0; i < messageSize - 1; i++)
  {
    
//this.categoryArr = {"mass", "tell", "system", "guild"}; for reference
    // sort through each category at the id set above
    
for (temp.j = 0; j < this.categoryArr.size() - 1; j++)
    {
      
// if the timevar is less than the next one, show
      
if (client.(@this.categoryArr[j]).messages[i][2] < client.(@this.categoryArr[j]).messages[i + 1][2])
      {
        
// since this timevar is smaller than next, check for message on hold that wasn't previously
        
if (holdMessage == null || holdMessage == 0 || holdMessage == "")
        {
          
// no messages on hold, show this message
          
ChatBox_WindowText.addtext("<img src=" @temp.messagesImg[j]@ " id=sendImg." @temp.rndID@ "/>"@client.(@this.categoryArr[j]).messages[i][0]@ ": " @client.(@this.categoryArr[j]).messages[i][1]@ "<br>", false);
          
//temp.holdMessage = client.(@this.categoryArr[j]).messages[i];
        
}else 
        {
          
// there is a message on hold, compare it to this one
          
if (client.(@this.categoryArr[j]).messages[i][2] < holdMessageTime)
          {
            
// this messages timevar is lower than the one on hold, show message
            
ChatBox_WindowText.addtext("<img src=" @temp.messagesImg[j]@ " id=sendImg." @temp.rndID@ "/>"@client.(@this.categoryArr[j]).messages[i][0]@ ": " @client.(@this.categoryArr[j]).messages[i][1]@ "<br>", false);
          }else
          {
            
// the message timevar is higher than the one on hold, show message on hold
            
ChatBox_WindowText.addtext("<img src=" @temp.messagesImg[holdMessageImg]@ " id=sendImg." @temp.rndID@ "/>"@holdMessage[0]@ ": " @holdMessage[1]@ "<br>", false);
            
            
// reset hold message values to null for next message to know
            
player.chat = holdMessage@ ", " @holdMessageTime@ ", " @holdMessageImg;
            
temp.holdMessage = null;
            
temp.holdMessageTime = null;
            
temp.holdMessageImg = null;
            
            
// show message after one on hold, since it was still less than the next
            
ChatBox_WindowText.addtext("<img src=" @temp.messagesImg[j]@ " id=sendImg." @temp.rndID@ "/>"@client.(@this.categoryArr[j]).messages[i][0]@ ": " @client.(@this.categoryArr[j]).messages[i][1]@ "<br>", false);
          }
        }
      }else 
      {
        
// set time and message hold to save and compare to next message
        
temp.holdMessageTime = client.(@this.categoryArr[j]).messages[i][2];
        
temp.holdMessage = client.(@this.categoryArr[j]).messages[i];
        
temp.holdMessageImg = j;
      }
    }
  }
  
ChatBox_WindowText.scrolltobottom();
} 
I have buttons and again, this is supposed to show all messages. I was reluctant to post this lol, but I'm not the first to do it I'm sure so all well.

It does show some things, and switching back and forth from a category to all makes things pop to the top instead of bottom, but it doesn't show "all" things like it's supposed to and I'm just plain stuck on it. Everything else works fine though...

P.S. I moved this because it really should have been in it's own thread. It didn't have much to do with where it was...
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...



Last edited by sssssssssss; 12-03-2012 at 02:31 AM..
Reply With Quote