Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #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
  #2  
Old 02-24-2007, 03:52 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
I think onDelMessage( dt) is bugged, should be changed to:

PHP Code:
  for (i=this.destroylist.size()-1i>=0i--)
    
this.msgs.delete(this.destroylist[i]); 
Otherwise you delete the wrong indices. In my opinion the whole deletion stuff should be made simplier though, e.g. remember in this.msgs the abolute time until the message should exist (timevar2 + time) and put the deletion stuff into onTimeout() or similar (if you don't want a timeout then use scheduleevent which is calling scheduleevent again until all messages are vanished)
Reply With Quote
  #3  
Old 02-25-2007, 04:09 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
Quote:
Originally Posted by Stefan View Post
...
Sorry but that did nothing "new". Anyone else, any idea?
Thanks tho, Stefan
__________________
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
  #4  
Old 02-25-2007, 04:24 PM
Chandler Chandler is offline
Banned
Join Date: Jan 2007
Posts: 656
Chandler will become famous soon enough
Do a check to see which images are being destroyed, and what time it's displaying for it to be destroyed. What does it report?
Reply With Quote
  #5  
Old 02-25-2007, 07:02 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
Quote:
Originally Posted by contiga View Post
Sorry but that did nothing "new".
Well it shows the bug in your script, I am wondering for what other reason you have posted your problem.
Reply With Quote
  #6  
Old 02-26-2007, 06:02 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
Quote:
Originally Posted by Stefan View Post
Well it shows the bug in your script, I am wondering for what other reason you have posted your problem.
It has to do with the timer I used (timevar stuff), the deleting function is fine, just the this.destroylist gets set wrong.. x-x

So yeah..?
__________________
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.

Last edited by contiga; 02-27-2007 at 03:06 PM..
Reply With Quote
  #7  
Old 03-05-2007, 02:03 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
*bump*
__________________
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
  #8  
Old 03-05-2007, 08:15 PM
Kristi Kristi is offline
Bowie's Deciple
Kristi's Avatar
Join Date: Dec 2003
Location: Boston, MA
Posts: 748
Kristi has a spectacular aura aboutKristi has a spectacular aura about
Send a message via AIM to Kristi Send a message via MSN to Kristi
What stefan says had merit. I do not know why you are shrugging him off.

Your delete system seems too complicated. I would just find out what message is supposed to be deleted next, and schedule an update event when its supposed to be deleted, saving the index thats supposed to be deleted next, and save the time to deletion. Then delete that message, and then the update would run, finding out when the shortest time is left again by subtracting how much time has passed since the last update, and schedule itsself to run an update again.
__________________
Reply With Quote
  #9  
Old 03-06-2007, 05:02 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
Quote:
Originally Posted by Kristi View Post
Your delete system seems too complicated. I would just find out what message is supposed to be deleted next, and schedule an update event when its supposed to be deleted, saving the index thats supposed to be deleted next, and save the time to deletion. Then delete that message, and then the update would run, finding out when the shortest time is left again by subtracting how much time has passed since the last update, and schedule itsself to run an update again.
That's what it is doing..
__________________
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
  #10  
Old 03-06-2007, 05:11 PM
zell12 zell12 is offline
Gone
zell12's Avatar
Join Date: Jun 2001
Location: Alberta, Canada
Posts: 8,541
zell12 has a spectacular aura about
Send a message via ICQ to zell12 Send a message via AIM to zell12 Send a message via MSN to zell12
Contiga, I think Stefan was on the right track, take more then ~10 minutes to utilize his advice.
__________________
Reply With Quote
  #11  
Old 03-06-2007, 05:48 PM
Kristi Kristi is offline
Bowie's Deciple
Kristi's Avatar
Join Date: Dec 2003
Location: Boston, MA
Posts: 748
Kristi has a spectacular aura aboutKristi has a spectacular aura about
Send a message via AIM to Kristi Send a message via MSN to Kristi
Quote:
Originally Posted by contiga View Post
That's what it is doing..
Then it is obviously doing it wrong! Just rewrite it.
__________________
Reply With Quote
Reply


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 07:14 PM.


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