Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Problems with message system (https://forums.graalonline.com/forums/showthread.php?t=75119)

cbk1994 07-05-2007 07:49 PM

Problems with message system
 
Hello 'o great scripting community.

I haven't scripted for a while, and I'm starting again. I am having trouble with this message system, and it is very odd--noone can seem to find any bug in it.

PHP Code:

//#CLIENTSIDE
function onCreated()
{
  
this.color_staff "#FF3333";
  
this.color_global "#FFFFFF";
  
this.color_battleground "#3300FF";
  
this.color_team "#00FF00";
  
this.color_pm "#FFFF00";
  
client.messages.clear();
  
client.messages.add( { "Welcome to" SPC servername "," SPC player.nick "!""global" } );
  
sleep.11 );
  
setTimer0.05 );
}
function 
onTimeOut()
{
  if ( 
this.textArray.size() > 15 )
  {
    
this.textArray.delete);
  }
  if ( 
client.messages.size() > )
  {
    for ( 
0client.messages.size(); ++ )
    {
      
client.messages[i];
      
this.textArray.add"<font color=\"" this.( "color_" a[1] ) @ "\">" a[0] @ "</font>" );
    }
    
client.messages.clear();
    for ( 
ithis.textArray )
    {
      if ( 
this.textArray.index) != )
      {
        
nText interfaceMessages.text "\n" i;
      }
      else
      {
        
nText i;
      }
    }
    
interfaceMessages.text nText;
    
interfaceScroll.scrollto010000 );
    
client.messages.clear();
  }
  
setTimer0.05 );


The bugs seem to happen once you hit 15 messages, it should delete the oldest--right? No, it deletes them all. Either that, or it doesn't delete any. Really weird ... please help!

Thanks for all the help,
Chris Zakuto

coreys 07-05-2007 10:31 PM

client.messages.clear();
Perhaps that has something to do with it? I just took a quick look, so I don't really know for sure.

cbk1994 07-05-2007 11:10 PM

Quote:

Originally Posted by coreys (Post 1325902)
client.messages.clear();
Perhaps that has something to do with it? I just took a quick look, so I don't really know for sure.

Thank you for your help, however this cannot be the problem ...

Everytime there is a new message, it adds it to this.textArray and then clears client.messages, so it is cleaner.

killerogue 07-05-2007 11:15 PM

I'd bet a ice cream sandwich it's the array clearing. :D

cbk1994 07-05-2007 11:27 PM

Quote:

Originally Posted by killerogue (Post 1325956)
I'd bet a ice cream sandwich it's the array clearing. :D

Where is the clear though? It adds to the textArray fine, the problem is that instead of clearing the last entry, it clears them all.

Tolnaftate2004 07-06-2007 07:51 AM

Quote:

Originally Posted by cbkbud (Post 1325835)
I haven't scripted for a while, and I'm starting again. I am having trouble with this message system, and it is very odd--noone can seem to find any bug in it.

PHP Code:

code 

The bugs seem to happen once you hit 15 messages, it should delete the oldest--right? No, it deletes them all. Either that, or it doesn't delete any. Really weird ... please help!

PHP Code:

...
function 
onTimeOut()
{
  if ( 
client.messages.size() > )
  {
    for ( 
0client.messages.size(); ++ )
    {
      
client.messages[i];
      
this.textArray.add"<font color=\"" this.( "color_" a[1] ) @ "\">" a[0] @ "</font>" );
    }
    while ( 
this.textArray.size() > 15 )
    {
      
this.textArray.delete);
    }
    
// client.messages.clear();
    // ^ not needed because you clear it below.
 
...
  }
  
setTimer0.05 );


*Note: "..." means I took out some code but didn't change it.

I didn't test it, but I think that should take care of the problem.


All times are GMT +2. The time now is 05:06 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.