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 01-07-2010, 03:39 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
GANI scripts in attributes; updating

I'm having trouble with GANI scripts used in player attributes to show an HP bar. It works for the first display, but then doesn't always update.

This is the code (serverside):

PHP Code:
this.attr[3] = "era_hpbar.gani," @ (this.health this.initialHealth); 
and this is the GANI script:

PHP Code:
SCRIPT
function onCreated() {
  
showBar(params[0]);
}

function 
onPlayerEnters() {
  
onCreated();
}

function 
showBar(percent) {
  
with (findimg(200)) {
    
image "erai_hpbar.png";
    
    
this.0.25;
    
this.1.5;
    
layer 1;
    
    
attachtoowner true;
  }
  
  
changeImgPart(200004111);
  
  
with (findimg(201)) {
    
image "erai_hpbar.png";
    
    
this.0.25;
    
this.1.5;
    
    
layer 2;
    
    
attachtoowner true;
  }
  
  
changeImgPart(201012max(141 percent), 11);
}
SCRIPTEND 
The bar will always show correctly if I try to display it when the bar isn't already showing, but if it is already showing, it won't update.
__________________
Reply With Quote
  #2  
Old 01-07-2010, 03:49 PM
Fulg0reSama Fulg0reSama is offline
Extrinsical Anomaly
Fulg0reSama's Avatar
Join Date: Sep 2009
Location: Ohio
Posts: 3,049
Fulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant future
I was thinking about how to fix this because i face a similar problem.

i was thinking like a timeout to readd while a onplayerhurt function would remove the attribute setting for the duration than add back afterwords Though im not sure if that could even work. Because i have a smaller project that requires a image to stay up at all times. Hope this gives you a lead onto a fix perhaps. If so give me the method and maybe i can work my own way around my problem :P

But of course im talking about how mine works... Good luck to your problem
__________________

Careful, thoughts and opinions here scare people.
Reply With Quote
  #3  
Old 01-07-2010, 03:52 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
What I ended up doing is just rotating between two attributes (2 and 3) instead of sticking with one, which lets it always update, but it's still a pain in the ass, and I think there's a way to make it work anyway
__________________
Reply With Quote
  #4  
Old 01-07-2010, 03:59 PM
Fulg0reSama Fulg0reSama is offline
Extrinsical Anomaly
Fulg0reSama's Avatar
Join Date: Sep 2009
Location: Ohio
Posts: 3,049
Fulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant future
not a bad loophole for this problem. good job. Hopefully someone has an answer to fixing this without having to use 2 attributes.
__________________

Careful, thoughts and opinions here scare people.
Reply With Quote
  #5  
Old 01-07-2010, 04:00 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Sadly I've tried to force it to update, even by clearing the attr and setting it again, but to no avail. So I end up having to resort to using another attr to store the data, which sucks.

I've made a bug report on this update problem, but no response...
Reply With Quote
  #6  
Old 01-07-2010, 04:02 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by DustyPorViva View Post
Sadly I've tried to force it to update, even by clearing the attr and setting it again, but to no avail. So I end up having to resort to using another attr to store the data, which sucks.

I've made a bug report on this update problem, but no response...
Did you put a short sleep after clearing the attribute and before setting it again? As far as I remember, that did the trick before for me.
Reply With Quote
  #7  
Old 01-07-2010, 04:03 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Quote:
Originally Posted by Crow View Post
Did you put a short sleep after clearing the attribute and before setting it again? As far as I remember, that did the trick before for me.
Can't put a sleep in timeouts
Reply With Quote
  #8  
Old 01-07-2010, 04:15 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by DustyPorViva View Post
Can't put a sleep in timeouts
scheduleEvent()
Reply With Quote
  #9  
Old 01-07-2010, 04:16 PM
Fulg0reSama Fulg0reSama is offline
Extrinsical Anomaly
Fulg0reSama's Avatar
Join Date: Sep 2009
Location: Ohio
Posts: 3,049
Fulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant future
Interesting!

btw crow +rep just for your whole signature when I can do it again
__________________

Careful, thoughts and opinions here scare people.
Reply With Quote
  #10  
Old 01-07-2010, 04:27 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Quote:
Originally Posted by Crow View Post
scheduleEvent()
Keep forgetting about that! I really should utilize it more often... however I wish this bug was just crushed instead. Having a gani that's supposed to update constantly always running behind because we have to delay it before it updates isn't very ideal.
Reply With Quote
  #11  
Old 01-07-2010, 04:49 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by DustyPorViva View Post
Can't put a sleep in timeouts
You can use sleep() as long as you restart the event (timeout = #; || setTimer()) (Which you should usually do at the end of the timeout event)
__________________
Reply With Quote
  #12  
Old 01-07-2010, 04:53 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Quote:
Originally Posted by Chompy View Post
You can use sleep() as long as you restart the event (timeout = #; || setTimer()) (Which you should usually do at the end of the timeout event)
Not in a way that's healthy for the script, though. From my experience the sleep will function like a return, breaking everything after it, even if you reset the timeout.
Reply With Quote
  #13  
Old 01-07-2010, 05:48 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
http://forums.graalonline.com/forums...ad.php?t=72413
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #14  
Old 01-07-2010, 05:50 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Quote:
Originally Posted by xXziroXx View Post
Indeed, but it's a bit silly to have one piece of functionality, like a health bar, rely on two attr's to work. I mean it's really the only way for it to function right now, but this needs to be addressed because it makes attr gani parameters pretty useless.
Reply With Quote
  #15  
Old 01-07-2010, 05:53 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Quote:
Originally Posted by DustyPorViva View Post
Indeed, but it's a bit silly to have one piece of functionality, like a health bar, rely on two attr's to work. I mean it's really the only way for it to function right now, but this needs to be addressed because it makes attr gani parameters pretty useless.
I think I linked the wrong thing, meant to link a reply in the thread:

http://forums.graalonline.com/forums...66&postcount=5
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #16  
Old 01-07-2010, 07:18 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by DustyPorViva View Post
Not in a way that's healthy for the script, though. From my experience the sleep will function like a return, breaking everything after it, even if you reset the timeout.
Sleep() should not return and break everything after. Sleep() will freeze/pause the script for the given time, and then continue.


Also..
Quote:
Originally Posted by DustyPorViva View Post
Can't put a sleep in timeouts
that is like saying you can't put sleep() in any loops (timeout, scheduleevent, while, for) ;D

PHP Code:
function onCreated() {
  
this.var1 "This is echoed when timeout events occurs.";
  
this.var2 "This is echoed 5 seconds later";
  
setTimer(1);
}

function 
onTimeout() {
  echo(
this.var1);
  
sleep(5);
  echo(
this.var2);
  
setTimer(1);
}

// above functions identical to the script below:

function onCreated() {
  
this.var1 "This is echoed when timeout events occurs.";
  
this.var2 "This is echoed 5 seconds later";
  
scheduleEvent(1"Timeout2"0);
}

function 
onTimeout2() {
  echo(
this.var1);
  
sleep(5);
  echo(
this.var2);
  
scheduleEvent(5"Timeout2"0);
}

// above functions identical to the script below:

function onCreated() {
  
this.var1 "This is echoed when timeout events occurs.";
  
this.var2 "This is echoed 5 seconds later";
  
  
this.loop = function() {
    echo(
this.var1);
    
sleep(5);
    echo(
this.var2);
    
sleep(1);
    
this.loop();
  };
  
  
this.loop();
}

// above functions identical to the script below:

function onCreated() {
  
this.var1 "This is echoed when timeout events occurs.";
  
this.var2 "This is echoed 5 seconds later";
  
  while(!
waitfor(this"timeout"1)) {
    echo(
this.var1);
    
sleep(5);
    echo(
this.var2);
  }

__________________

Last edited by Chompy; 01-07-2010 at 07:53 PM..
Reply With Quote
  #17  
Old 01-07-2010, 07:44 PM
Immolate Immolate is offline
Indigo
Join Date: Dec 2009
Posts: 322
Immolate is on a distinguished road
Quote:
Originally Posted by Chompy View Post
Sleep() will not return and break everything after. Sleep() will freeze/pause the script for the given time, and then continue.


Also..


that is like saying you can't put sleep() in any loops (timeout, scheduleevent, while, for) ;D

PHP Code:
function onCreated() {
  
this.var1 "This is echoed when timeout events occurs.";
  
this.var2 "This is echoed 5 seconds later";
  
setTimer(1);
}

function 
onTimeout() {
  echo(
this.var1);
  
sleep(5);
  echo(
this.var2);
  
setTimer(1);
}

// above functions identical to the script below:

function onCreated() {
  
this.var1 "This is echoed when timeout events occurs.";
  
this.var2 "This is echoed 5 seconds later";
  
scheduleEvent(1"Timeout2"0);
}

function 
onTimeout2() {
  echo(
this.var1);
  
sleep(5);
  echo(
this.var2);
  
scheduleEvent(5"Timeout2"0);
}

// above functions identical to the script below:

function onCreated() {
  
this.var1 "This is echoed when timeout events occurs.";
  
this.var2 "This is echoed 5 seconds later";
  
  
this.loop = function() {
    echo(
this.var1);
    
sleep(5);
    echo(
this.var2);
    
sleep(1);
    
this.loop();
  };
  
  
this.loop();
}

// above functions identical to the script below:

function onCreated() {
  
this.var1 "This is echoed when timeout events occurs.";
  
this.var2 "This is echoed 5 seconds later";
  
  while(!
waitfor(this"timeout"1)) {
    echo(
this.var1);
    
sleep(5);
    echo(
this.var2);
  }

When I used sleep() in a while loop, it broke .
Reply With Quote
  #18  
Old 01-07-2010, 07:53 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by Immolate View Post
When I used sleep() in a while loop, it broke .
Got an example snippet/script?
__________________
Reply With Quote
  #19  
Old 01-07-2010, 07:57 PM
Immolate Immolate is offline
Indigo
Join Date: Dec 2009
Posts: 322
Immolate is on a distinguished road
Quote:
Originally Posted by Chompy View Post
Got an example snippet/script?
Not anymore. I used a different method and my RC has been revoked on that server. I remember it breaking when sleep() was used though. Not sure if it's totally relevent anymore though, since this was about 5 months ago.
Reply With Quote
  #20  
Old 01-07-2010, 10:52 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Quote:
Originally Posted by Chompy View Post
that is like saying you can't put sleep() in any loops (timeout, scheduleevent, while, for) ;D
Not really, for() and while() loops don't have to be constantly called like a timeout.
Reply With Quote
  #21  
Old 01-07-2010, 11:19 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by DustyPorViva View Post
Not really, for() and while() loops don't have to be constantly called like a timeout.
The timeout event doesn't have to be called constantly either

The point now though, is that sleep() shouldn't break the script like you guys are explaining it, if it does.
__________________
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 08:47 PM.


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