View Single Post
  #1  
Old 02-24-2007, 02:05 PM
contiga contiga is offline
Graal2001 Administration
contiga's Avatar
Join Date: Jul 2004
Location: Netherlands
Posts: 419
contiga is an unknown quantity at this point
Send a message via ICQ to contiga Send a message via AIM to contiga Send a message via MSN to contiga Send a message via Yahoo to contiga
Problem with messages

NOTE: First of all, I'd like to say that no one is allowed to use this script for his/her own server, or a server he/she works on. I'm just showing this because I can't find a problem in it, but there is.

The problem: The first time I add a few messages, everything works perfect, but as soon as I use my (tempory) commands like; /msg <msg>, /adm <msg> and/or /sys <msg>, things go wrong.

What goes wrong?

The 5 between params[ 0] and params[ 1] in the serverside part (i.triggerClient ... line) stands for the seconds the message should show.
The first time I do a message, after all the other messages, which I added at onCreated() ..., are hidden (using '/msg' or any of the other commands) it still works fine. But when I wait one second after the first time, and then add another message, it SHOULD be like, the first message has 4 seconds left of showing, and the new message 5 seconds. But what happens? They both hide after 4 seconds. So yeah.. that pretty much "sucks" xD Especially if I wait 4 seconds and then add a new message, because then, they'll both hide after 1 second.

I hope anyone gets what I mean, and is able to help me.

PHP Code:
function onActionServerSide() {
  for ( 
iallplayers)
    
i.triggerClient"gui""*Messages"params0], 5params1]);
}

//#CLIENTSIDE
function onCreated() {

  
newMessage"System"10"Welcome to Bomy Islands!");
  
newMessage"contiga"6"*test 123 test*");
  
newMessage"Stefan"9"I'll come to G2k1 immediately, to script you guys a better bomypet!!!");
  
newMessage"Konidias"14"Lalaaalaaa :D");
  
newMessage"Admin"14"Testmsgg");
  
newMessage"contiga"15"Test");

  
this.lastdeltime this.shortesttime NULL;
  
this.laststart timevar2;
  
this.maxlines 16;
}

function 
onPlayerChats() { // just temp, to test
  
if ( player.chat.starts"/msg"))
    
triggerServer"gui"nameplayer.accountplayer.chat.substring5));
  if ( 
player.chat.starts"/sys"))
    
triggerServer"gui"name"System"player.chat.substring5));
  if ( 
player.chat.starts"/adm"))
    
triggerServer"gui"name"Admin"player.chat.substring5));
}

function 
onActionClientSide()
  
newMessageparams0], params1], params2]);

function 
updateList() {
  
hideImgs200400);
  
cancelEvents"delmessage");
  
  if ( 
this.msgs.size() == NULL) {
    
this.lastdeltime NULL;
    return 
"";
  }
  
  
this.linestaken NULL;
  
this.shortesttime 50;
  
this.destroylist "";
  
this.laststart timevar2;
  
  for ( 
ind 0ind this.msgs.size(); ind ++) {
    
this.msgsind][ 1] = this.msgsind][ 1] - this.lastdeltime;
    
this.linestakenbefore this.linestaken;
    
this.cmsgt this.msgsind][ 1];
    
    if ( 
this.cmsgt this.shortesttime) {
      
this.shortesttime this.cmsgt;
      
this.destroylist ind ",";
    }
    else if ( 
this.cmsgt == this.shortesttime)
      
this.destroylist @= ind ",";
      
    
this.cmsg this.msgsind][ 2];
    
this.cmsgp 0;
    
    for ( 
ithis.cmsg) {
    
      
with findImg201 this.linestaken)) {
        
text i;
        
32 + ( ( thiso.cmsg.indexi) < thiso.cmsg.size() - 1) ? 16 0);
        
screenheight 56 - ( thiso.linestaken 18);
        
shadowoffset = { - 1, + 1};
        
shadowcolor = { 000};
        
textshadow true;
        
font "Arial";
        
style "b";
        
zoom 0.8;
        
layer 6;
      }
      
      
this.linestaken ++;
      
this.cmsgp ++;
    }
    
    
this.poly_x 28;
    
this.poly_y screenheight 37 - ( ( this.linestakenbefore this.cmsgp) * 18);
    
this.poly_w 324;
    
this.poly_h thiso.cmsgp 18;
    
this.poly_a = { this.poly_xthis.poly_ythis.poly_x this.poly_wthis.poly_ythis.poly_x this.poly_wthis.poly_y this.poly_hthis.poly_xthis.poly_y this.poly_h};

    if ( 
this.msgsind][ 0] == "System"
      
this.poly_c = { 10.80};
    else if ( 
this.msgsind][ 0] == "Admin"
      
this.poly_c = { 100};
    else
      
this.poly_c = { 0.210.2};
      
    
with findImg300 ind)) {
      
polygon thiso.poly_a;
      
alpha = ( ind == 1) ? 0.5 0.6;
      
green thiso.poly_c1];
      
blue thiso.poly_c2];
      
red thiso.poly_c0]; 
      
layer 5;
      
mode 1;
    }
  }
  
  
this.poly_x 28;
  
this.poly_y screenheight 37 - ( ( this.linestakenbefore this.cmsgp) * 18);
  
this.poly_w 324;
  
this.poly_h this.linestaken 18;
  
this.poly_a = { this.poly_xthis.poly_ythis.poly_x this.poly_wthis.poly_ythis.poly_x this.poly_wthis.poly_y this.poly_hthis.poly_xthis.poly_y this.poly_h};
  
with findImg200)) {
    
polygon thiso.poly_a;
    
alpha 0.8;
    
red green blue 0
    
layer 4;
    
mode 1;
  }
  
scheduleEventthis.shortesttime"DelMessage"this.shortesttime);
}

function 
onDelMessagedt) {
  for ( 
dmsgthis.destroylist)
    
this.msgs.deletedmsg this.destroylist.indexdmsg));
  
  if ( 
this.msgs.size() == NULLthis.lastdeltime NULL;
  else 
this.lastdeltime dt;
  
  
updateList();
}

public function 
newMessagesendertimemsg) {
  
this.lastdeltime inttimevar2 this.laststart);
  
  if ( 
this.lastdeltime 50this.msgs NULL;
  if ( 
this.msgs.size() == NULLthis.lastdeltime NULL;
  
  
position this.msgs.size() + 1;
  
this.msgs.insert0, { sendertimeturnAroundwraptext23000.8" ""@Arial@b@*" sender ": " msg))});
  
  
updateList();
}

function 
turnAroundcmsg) {
  
temp.msg "";
  for ( 
temp.ccmsg)
    
temp.msg.insert0temp.c);
  return 
temp.msg;

Ps. I didn't style this script like I should style it yet, I just kept a lot of space to keep the script well-organized because of the errors in it.
__________________
AIM: Contiga122
MSN: [email protected]
Status:
Quote:
Originally Posted by unixmad View Post
I am also awake 3AM to help correct problems.
Quote:
Originally Posted by Bomy Island RC people
Daniel: HoudiniMan is a bad guy =p
*Bell: rofl. I first read that as houdini is a bad man. like the little kid that wants his mommy to keep her away from that boogie man
Daniel: xD
*Rufus: I wouldn't want my kids around him.
Reply With Quote