29-11-2007, 02:14 AM
OK. This tutorial is to teach you all how to make an HP bar in frmMirage. When the player looses hp, the picture will resize, and another picture underneath will be a different (I used a grayed-out) color. Also, I have added a label that tells you how much HP you have (12 / 62).
Difficulty (1/5) C & P
This is all Client side
First place two picture bars of the same size, but differing colors in frmMirage and label them picFull and picOut. Choose whatever HP bar pictures you want now (make sure they are the same size).
Inside each of those picture boxes add a label (lblFull and lblOut respectively). Set the captions of both to " 0 / 0"
Now
In modHandleData find:
replace that packet with:
(I made it so that the default HP label doesn't show anymore)
make sure that you change hpbwidth to the width of you HP bar (in pixels, not twips)
Analysis:
To resize the full HP bar we must get the current percentage of the players HP. such as .1, .92, or 1; then we multiply it by the width of the maxed out bar in order to make sure that the bar is resized properly.
Next, we update both labels because once your full HP bar goes past a certain point, you wont see it anymore, so we added the bottom one in order to keep it visible (make sure that they are in the same place on both HP bars).
Your Challenge:
Add an MP, SP, and/or EXP bar(s).
Difficulty (1/5) C & P
This is all Client side
First place two picture bars of the same size, but differing colors in frmMirage and label them picFull and picOut. Choose whatever HP bar pictures you want now (make sure they are the same size).
Inside each of those picture boxes add a label (lblFull and lblOut respectively). Set the captions of both to " 0 / 0"
Now
In modHandleData find:
Code:
' ::::::::::::::::::::::
' :: Player hp packet ::
' ::::::::::::::::::::::
replace that packet with:
Code:
' ::::::::::::::::::::::
' :: Player hp packet ::
' ::::::::::::::::::::::
If LCase(Parse(0)) = "playerhp" Then
Dim hpbWidth As Integer
hpbWidth = 154
Player(MyIndex).MaxHP = Val(Parse(1))
Call SetPlayerHP(MyIndex, Val(Parse(2)))
If GetPlayerMaxHP(MyIndex) > 0 Then
'frmMirage.lblHP.Caption = Int(GetPlayerHP(MyIndex) / GetPlayerMaxHP(MyIndex) * 100) & "%"
frmMirage.picFull.Width = Int(GetPlayerHP(MyIndex) / GetPlayerMaxHP(MyIndex) * hpbWidth)
frmMirage.lblFull.Caption = GetPlayerHP(MyIndex) & " / " & GetPlayerMaxHP(MyIndex)
frmMirage.lblOut.Caption = GetPlayerHP(MyIndex) & " / " & GetPlayerMaxHP(MyIndex)
End If
Exit Sub
make sure that you change hpbwidth to the width of you HP bar (in pixels, not twips)
Analysis:
To resize the full HP bar we must get the current percentage of the players HP. such as .1, .92, or 1; then we multiply it by the width of the maxed out bar in order to make sure that the bar is resized properly.
Next, we update both labels because once your full HP bar goes past a certain point, you wont see it anymore, so we added the bottom one in order to keep it visible (make sure that they are in the same place on both HP bars).
Your Challenge:
Add an MP, SP, and/or EXP bar(s).