Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-05-2007, 07:49 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
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
__________________
Reply With Quote
  #2  
Old 07-05-2007, 10:31 PM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
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.
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #3  
Old 07-05-2007, 11:10 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by coreys View Post
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.
__________________
Reply With Quote
  #4  
Old 07-05-2007, 11:15 PM
killerogue killerogue is offline
Registered Omega
killerogue's Avatar
Join Date: Apr 2006
Location: United States
Posts: 1,920
killerogue is on a distinguished road
Send a message via AIM to killerogue Send a message via MSN to killerogue
I'd bet a ice cream sandwich it's the array clearing.
__________________


REMEMBER, IF YOU REP ME, LEAVE A NAME!

Quote:
Originally Posted by haunter View Post
Graal admins don't die. They go to hell and regroup.
Quote:
Originally Posted by Inverness View Post
Without scripters, your graphics and levels wouldn't do anything but sit there and look pretty.
Reply With Quote
  #5  
Old 07-05-2007, 11:27 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by killerogue View Post
I'd bet a ice cream sandwich it's the array clearing.
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.
__________________
Reply With Quote
  #6  
Old 07-06-2007, 07:51 AM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
Quote:
Originally Posted by cbkbud View Post
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.
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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