mob/Stat()
if(PrevHP != HP)
PrevHP = HP
winset(src, "health", "value = [round((HP / MaxHP) * 100)]")
..()
There's my Health bar code, can someone please explain why it's not working?
I have looked through guide after guide about this and still cannot get it to work. I have tried coding it atleast 3 different ways but it's always the same; There are no errors, but it still never updates.Code:
mob/Stat() There's my Health bar code, can someone please explain why it's not working? |
pss you could do this create a proc and when you put the player enters the game
mob Login() src.loc=locate(1,1,1) Barras() ..() mob proc Barras() set background=1 var/percent=round((src:HP/src:MaxHP)*100,10) if(percent>100)percent=100 if(percent<0)percent=0 winset(src,"Ventana.Vida","value='[percent]'") spawn(10) Barras() |
Mallonee wrote:
I have looked through guide after guide about this and still cannot get it to work. I have tried coding it atleast 3 different ways but it's always the same; There are no errors, but it still never updates.Code: mob/Stat() There's my Health bar code, can someone please explain why it's not working? The syntax this person provided you is wrong. Do not listen to him. winset(client, "window.control", "property") That is your syntax. So, do it like this: mob/Stat() Don't forget to encase the property in single quotes (' '). |
The code that you gave is working fine for me, so check that the bar is actually named "health" and that you don't have any other controls using the same name.
Also, just a heads-up: Specifying the window in the control id is optional. You only need to do it if there are multiple controls with the same name in different windows. The bar's value parameter doesn't need a percent symbol at the end, although it doesn't appear to break it. You should avoid spaces in the parameter string, and surround all parameter values in quotes (either ' or \") |
In response to DarkCampainger
|
|
DarkCampainger wrote:
Specifying the window in the control id is optional. You only need to do it if there are multiple controls with the same name in different windows. I knew this, but... The bar's value parameter doesn't need a percent symbol at the end, although it doesn't appear to break it. This was my bad. I totally wasn't thinking about this being set to the value property. I was thinking about a label, I guess. Sorry. Although it is interesting that it doesn't break it. |
you have it so
Winset (src, "health", "value = [round ((HP / MHP) * 100)]")
and should be so
Winset (src, "the name of the main window goes here, health", "value = [round ((HP / MHP) * 100)]")
first put the name of the window where you have health bars and then separated by a comma and then the name of your bars