Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Feature] HP/MP/SP bars (for players)
#1
[SERVERSIDE]
change the SendVital sub to this

Code:
Public Sub SendVital(ByVal Index As Long, ByVal Vital As Vitals)
Dim Packet As String
    
    Select Case Vital
        Case HP
            Packet = SPlayerHp & SEP_CHAR & Index & SEP_CHAR & GetPlayerMaxVital(Index, Vitals.HP) & SEP_CHAR & GetPlayerVital(Index, Vitals.HP) & END_CHAR
        Case MP
            Packet = SPlayerMp & SEP_CHAR & Index & SEP_CHAR & GetPlayerMaxVital(Index, Vitals.MP) & SEP_CHAR & GetPlayerVital(Index, Vitals.MP) & END_CHAR
        Case SP
            Packet = SPlayerSp & SEP_CHAR & Index & SEP_CHAR & GetPlayerMaxVital(Index, Vitals.SP) & SEP_CHAR & GetPlayerVital(Index, Vitals.SP) & END_CHAR
    End Select
    
    Call SendDataToMap(GetPlayerMap(Index), Index, Packet)
End Sub
This sends the vitals to everyone, and also says who they are for.

[CLIENTSIDE]
change sub HandlePlayerHp to
Code:
Private Sub HandlePlayerHp(ByRef Parse() As String)
     Dim Index As Long
     Index = CLng(Parse(1))
     Player(Index).MaxHP = CLng(Parse(2))
     Call SetPlayerVital(Index, Vitals.HP, CLng(Parse(3)))
     If Index = MyIndex Then
        If GetPlayerMaxVital(Index, Vitals.HP) > 0 Then
            frmMirage.lblHP.Caption = Int(GetPlayerVital(Index, Vitals.HP) / GetPlayerMaxVital(Index, Vitals.HP) * 100) & "%"
        End If
     End If
End Sub

change sub HandlePlayerMp to
Code:
Private Sub HandlePlayerMp(ByRef Parse() As String)
     Dim Index As Long
     Index = CLng(Parse(1))
     Player(Index).MaxMP = CLng(Parse(2))
     Call SetPlayerVital(Index, Vitals.MP, CLng(Parse(3)))
     If Index = MyIndex Then
        If GetPlayerMaxVital(Index, Vitals.MP) > 0 Then
            frmMirage.lblMP.Caption = Int(GetPlayerVital(Index, Vitals.MP) / GetPlayerMaxVital(Index, Vitals.MP) * 100) & "%"
        End If
     End If
End Sub

change sub HandlePlayerSp to
Code:
Private Sub HandlePlayerSp(ByRef Parse() As String)
     Dim Index As Long
     Index = CLng(Parse(1))
     Player(Index).MaxSP = CLng(Parse(2))
     Call SetPlayerVital(Index, Vitals.SP, CLng(Parse(3)))
     If Index = MyIndex Then
        If GetPlayerMaxVital(Index, Vitals.SP) > 0 Then
            frmMirage.lblSP.Caption = Int(GetPlayerVital(Index, Vitals.SP) / GetPlayerMaxVital(Index, Vitals.SP) * 100) & "%"
        End If
     End If
End Sub


Now to actually draw out the bars for everyone Big Grin.

in sub BltPlayer, right before end sub put
Code:
If Player(Index).Vital(HP) = 0 Then Exit Sub
        
        Call DDS_BackBuffer.SetFillColor(RGB(255, 0, 0))
        Call DDS_BackBuffer.DrawBox(X, Y + 32, X + 32, Y + 36)
        
        Call DDS_BackBuffer.SetFillColor(RGB(0, 255, 0))
        Call DDS_BackBuffer.DrawBox(X, Y + 32, X + ((Player(Index).Vital(HP) / 100) / (Player(Index).MaxHP / 100) * 32), Y + 36)
        
        Call DDS_BackBuffer.SetFillColor(RGB(255, 0, 0))
        Call DDS_BackBuffer.DrawBox(X, Y + 35, X + 32, Y + 39)
        
        Call DDS_BackBuffer.SetFillColor(RGB(0, 0, 255))
        Call DDS_BackBuffer.DrawBox(X, Y + 35, X + ((Player(MyIndex).Vital(MP) / 100) / (Player(MyIndex).MaxMP / 100) * 32), Y + 39)

If you happen to also be using sp, you could put this.
Code:
Call DDS_BackBuffer.SetFillColor(RGB(255, 0, 0))
        Call DDS_BackBuffer.DrawBox(X, Y + 38, X + 32, Y +42)

        Call DDS_BackBuffer.SetFillColor(RGB(255, 255, 0))
        Call DDS_BackBuffer.DrawBox(X, Y + 38, X + ((Player(MyIndex).Vital(MP) / 100) / (Player(MyIndex).MaxMP / 100) * 32), Y + 42)

And you are done Big Grin.
Reply
#2
is this the HP MP SP bars for below/above the player or...... off to the side were the the current hp #%'s are
Reply
#3
if im right its above
Reply
#4
No its below.
Reply
#5
If you want a player HP/MP bar just for your own player, you can solely put this in, inside your bltplayer sub

Code:
If Player(Index).Vital(HP) = 0 Then Exit Sub
      
        Call DDS_BackBuffer.SetFillColor(RGB(255, 0, 0))
        Call DDS_BackBuffer.DrawBox(X, Y + 32, X + 32, Y + 36)
      
        Call DDS_BackBuffer.SetFillColor(RGB(0, 255, 0))
        Call DDS_BackBuffer.DrawBox(X, Y + 32, X + ((Player(Index).Vital(HP) / 100) / (Player(Index).MaxHP / 100) * 32), Y + 36)
      
        Call DDS_BackBuffer.SetFillColor(RGB(255, 0, 0))
        Call DDS_BackBuffer.DrawBox(X, Y + 35, X + 32, Y + 39)
      
        Call DDS_BackBuffer.SetFillColor(RGB(0, 0, 255))
        Call DDS_BackBuffer.DrawBox(X, Y + 35, X + ((Player(MyIndex).Vital(MP) / 100) / (Player(MyIndex).MaxMP / 100) * 32), Y + 39)

It still works perfectly fine in MS4 the latest version I as just using it.
Reply
#6
I tried to do this, it seems to work for a few people but I am new and I did everything correctly and I got a shit load of errors that I tried to fix myself but all I got was more errors, I get Compile Error ' Variable Not Defined' and I don't know what to do because there's only one Sub SendVital and usually Variable Not defined errors mean I am putting the code in the wrong section.
Reply
#7
Ciao Wrote:I tried to do this, it seems to work for a few people but I am new and I did everything correctly and I got a shit load of errors that I tried to fix myself but all I got was more errors, I get Compile Error ' Variable Not Defined' and I don't know what to do because there's only one Sub SendVital and usually Variable Not defined errors mean I am putting the code in the wrong section.

All these tutorials need to be converted to work with the byte array packets system. You might wanna learn the difference between the two systems. These tutorials use string packets, but the source has byte array packets now.
Reply
#8
Thank you for letting me know, is there going to be a whole fix by the way ?
Reply
#9
Ciao Wrote:Thank you for letting me know, is there going to be a whole fix by the way ?

No, but sooner or later, prolly this weekend, I will post a few examples of how to convert the packets and what not.
Reply
#10
I'll be waiiting 4 it, i 've seen many tutorials and things that i wnna to Add but never colud do it because allways give error in SEP_CHAR and END_CHAR.(Supose that they are Strings packets rigth?)
Reply
#11
The newest version of mirage uses byte packets, this uses string packets.
Reply
#12
I Thougt so, so Why they changed? are better byte than String Packets?
Cold anyone tell me the diference?

Well anyways i think i will find out later how to make the bars ^^ i hve other problems first ^^...
Reply
#13
Byte array packets are much smaller.
Reply
#14
Labmonkey Wrote:Byte array packets are much smaller.
What? I fail to understand why a byte array would help make the packets smaller. The byte array is equatable to a string if the array contents correspond to a character set like ASCII.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)