![]() |
Health bar
Well I´m trying to make a health bar in a gani. I was looking around the forums for help and my result was this:
PHP Code:
How can I fix it? |
Quote:
First, you cannot read clientr. variables of other players on your own client. This is where health would need to be stored as part of an attribute. So essentially this is attempting to show a bar with 0 width, which actually shows the entire bar and makes it look as if it's 100% full. The second problem is that even if you had HP working properly you don't seem to have a mechanism for updating the display upon HP being changed, unless you're just re-initialising the gani as part of the attribute upon players being damaged? On a side note it is pointless to be doing pl = findplayer(player.account); as you already have the player object. You also do not need to be referring to pl.id as part of the display index as these displays are on the gani attribute of each player and cannot collide. This also means you do not need to be doing hideimgs(200, 3000); . |
Try reading this thread:
http://forums.graalonline.com/forums...hp?t=134264542 I made a post in there that should help you out. |
Quote:
Quote:
|
Quote:
Well what is better to use: A gani scripted one or in a waepon? Like it´s said above it should only pop up for a time when the player is being damaged. |
Depending on how your damage is handled you could just do something like this with showani and scheduleevent.
PHP Code:
|
Well I´m adding the gani to the players attributes whenever the player is hit (also changes the health than). And I made something like this in the gani
PHP Code:
|
Quote:
|
Quote:
|
Quote:
Should I just start the 2nd image starting with an index of like 3000 or what? |
This also works:
PHP Code:
|
Ahh didnt think of that ^^
|
Well I played around with that and got this:
PHP Code:
My problem is that it won´t update the progress and it´s only shown on one player. How can I fix that? |
Maybe increase an index variable, say for instance.
PHP Code:
The problem is your using one image to display everyones health, I think you need some sort of index so that you can show dynamic text. |
You're looping through each player and only using the element 1 in the array. I believe there was an error in my code unfortunately I can't go back and edit it now.
In your drawing function record the following in an array: this.drawing.add({temp.p, 200 + temp.i}); In your updating function loop through your drawing array: PHP Code:
1. Store the width and height of your bar graphics in a variable outside the loop. Calling getimgwidth and getimgheight repeatedly isn't needed. 2. Use partx, party, partw, and parth instead of changeimgpart since you're already using findimg in a with statement. PHP Code:
|
| All times are GMT +2. The time now is 07:53 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.