Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   HUD Doubles on Death (https://forums.graalonline.com/forums/showthread.php?t=134264504)

Ohk4y 09-08-2011 03:18 AM

HUD Doubles on Death
 
Hello again, I have been experiencing this issue since the hud script was created, the issue is that when you die, the gui doubles untill you come alive again, quite odd.. Well here's some images of the proof:
Normal:
http://img600.imageshack.us/img600/8809/normalb.png
Doubled:
http://img651.imageshack.us/img651/9826/doublee.png

Here's the script:
PHP Code:


//#CLIENTSIDE

function onCreated() onTimeOut(); 
function 
onTimeout() {

  
fileupdate("e_gui.png");
  if(
client.loggedin != null) {
    
this.hudx=5;
    
this.hudy=10;

with(findimg(1000)) {
  
image player.head;
  
this.hudx+35;
  
this.hudx+25;
  
changeimgpart(1000,0,63,33,32);
  
changeimgvis(1000,0);
  
layer 5;
}
  
with(findimg(900)) {
  
image "e_gui.png";
  
this.hudx-5;
  
this.hudy;
  
changeimgpart(900,this.hudx,this.hudy,182,92);
  
layer 5;
}

//hp bar
showimg(202,"e_gui.png",this.hudx+68,this.hudy+22);
changeimgpart(202,18,103,102,12);
changeimgvis(202,18);
changeimgpart(202,18,103,clientr.player.stats.curhp*102/clientr.player.stats.maxhp,12);

//energy bar
showimg(302,"e_gui.png",this.hudx+68,this.hudy+36);
changeimgpart(302,18,123,102,12);
changeimgvis(302,18);
changeimgpart(302,18,123,clientr.player.stats.energy*100/clientr.player.stats.energy,12);

//Exp Bar
showimg(402,"e_gui.png",this.hudx+58,this.hudy+51);
changeimgpart(402,23,145,91,6);
changeimgvis(402,18);
changeimgpart(402,23,145,clientr.exp*100/clientr.expneeded,6);

//level text
with (showText400this.hudx+4559.7"Impact""a",clientr.explevel))     
{
layer 21;zoom .71;alpha =.90;zoom =.5;}
changeimgcolors(400,0,0,0,.99);
with (showText401this.hudx+4559.7"Impact""a",clientr.explevel))    
{
layer 22;zoom .70;alpha =.90;zoom =.5;}
changeimgcolors(401,1,1,1,.99);


//Money
with (showText2000this.hudx+9071"Impact""a",player.rupees))     
{
layer 21;zoom .71;alpha =.90;}
changeimgcolors(2000,0,0,0,.99);
with (showText2001this.hudx+9071"Impact""a",player.rupees))    
{
layer 22;zoom .70;alpha =.90;}
changeimgcolors(2001,1,1,1,.99);


//Nickname
with (showText3000this.hudx+93.5this.hudy+3"Arial""ab",player.nick))     
{
layer 21;zoom .71;alpha =.90;zoom =.7;}
changeimgcolors(3000,0,0,0,.99);
with (showText3000this.hudx+93.5this.hudy+3"Arial""ab",player.nick))    
{
layer 22;zoom .70;alpha =.90;zoom =.7;}
changeimgcolors(3000,1,1,1,.99);

}
settimer(.05);


Thanks in advance!

cbk1994 09-08-2011 03:51 AM

Haven't looked at your code since I can't be bothered to try to decipher poorly formatted code right now, but I'd bet the problem is you're trying to use changeimgpart with a width or height of zero. Hide the HP/MP/whatever bars when they're at zero to fix it.

Please format your code prior to posting it. If nothing else, use this.

scriptless 09-08-2011 04:02 AM

ChangeImgPart does this alot when you use 0.. just hide if less then 1.. or force a minimum of 1.

fowlplay4 09-08-2011 04:05 AM

If you specify a 0 width in changeimgpart it uses the entire width. So you can easily fix it like this:

PHP Code:

// HP Bar
temp.bar_width max(clientr.player.stats.curhp*102/clientr.player.stats.maxhp1);
changeimgpart(202,18,103,temp.bar_width,12); 

max(a, b) - returns the higher number.

So in the case above if your calculated width is lower than 1 it'll pick 1 instead.

scriptless 09-08-2011 04:35 AM

Quote:

Originally Posted by fowlplay4 (Post 1667416)
If you specify a 0 width in changeimgpart it uses the entire width. So you can easily fix it like this:

PHP Code:

// HP Bar
temp.bar_width max(clientr.player.stats.curhp*102/clientr.player.stats.maxhp1);
changeimgpart(202,18,103,temp.bar_width,12); 

max(a, b) - returns the higher number.

So in the case above if your calculated width is lower than 1 it'll pick 1 instead.

I never knew about
PHP Code:

max(ab) - returns the higher number

But I find that very usefull.. :)

PHP Code:

You must spread some Reputation around before giving it to fowlplay4 again


Crow 09-08-2011 11:15 AM

Quote:

Originally Posted by scriptless (Post 1667419)
I never knew about
PHP Code:

max(ab) - returns the higher number


It also works well together with min() to "lock" a number to a certain range:
PHP Code:

max(0min(100temp.var)) 

Will return temp.var, 0 if it's below 0 and 100 if it's above 100.


All times are GMT +2. The time now is 11:47 PM.

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