Mirage Source
http://www.miragesource.net/forums/

[Feature] HP/MP/SP bars (for players)
http://www.miragesource.net/forums/viewtopic.php?f=183&t=5459
Page 1 of 51

Author:  Labmonkey [ Fri Apr 10, 2009 11:23 pm ]
Post subject:  [Feature] HP/MP/SP bars (for players)

[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 :D.

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 :D.

Author:  Tdiddy [ Sun Apr 12, 2009 4:25 am ]
Post subject:  Re: [Feature] HP/MP/SP bars (for players)

is this the HP MP SP bars for below/above the player or...... off to the side were the the current hp #%'s are

Author:  Doomy [ Sun Apr 12, 2009 4:32 am ]
Post subject:  Re: [Feature] HP/MP/SP bars (for players)

if im right its above

Author:  Labmonkey [ Sun Apr 12, 2009 1:29 pm ]
Post subject:  Re: [Feature] HP/MP/SP bars (for players)

No its below.

Author:  Clu [ Sun Jun 28, 2009 7:32 pm ]
Post subject:  Re: [Feature] HP/MP/SP bars (for players)

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.

Author:  Ciao [ Tue Aug 11, 2009 8:30 pm ]
Post subject:  Re: [Feature] HP/MP/SP bars (for players)

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.

Author:  Matt [ Tue Aug 11, 2009 9:25 pm ]
Post subject:  Re: [Feature] HP/MP/SP bars (for players)

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.

Author:  Ciao [ Wed Aug 12, 2009 4:58 am ]
Post subject:  Re: [Feature] HP/MP/SP bars (for players)

Thank you for letting me know, is there going to be a whole fix by the way ?

Author:  Matt [ Wed Aug 12, 2009 12:19 pm ]
Post subject:  Re: [Feature] HP/MP/SP bars (for players)

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.

Author:  Ellesar [ Thu Aug 13, 2009 5:09 pm ]
Post subject:  Re: [Feature] HP/MP/SP bars (for players)

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?)

Author:  Labmonkey [ Thu Aug 13, 2009 5:51 pm ]
Post subject:  Re: [Feature] HP/MP/SP bars (for players)

The newest version of mirage uses byte packets, this uses string packets.

Author:  Ellesar [ Thu Aug 13, 2009 6:44 pm ]
Post subject:  Re: [Feature] HP/MP/SP bars (for players)

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 ^^...

Author:  Labmonkey [ Fri Aug 14, 2009 2:27 pm ]
Post subject:  Re: [Feature] HP/MP/SP bars (for players)

Byte array packets are much smaller.

Author:  4ngel [ Fri Aug 14, 2009 6:08 pm ]
Post subject:  Re: [Feature] HP/MP/SP bars (for players)

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.

Author:  wanai [ Wed Dec 01, 2021 8:49 am ]
Post subject:  Re: [Feature] HP/MP/SP bars (for players)

инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинйоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфо
инфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоинфоsemiasphalticflux.ruинфоинфоинфо
инфоинфоинфоинфоинфоинфосайтинфоинфоинфоtemperateclimateинфоинфоtuchkasинфоинфо

Author:  wanai [ Mon Jan 03, 2022 10:55 pm ]
Post subject:  Re: [Feature] HP/MP/SP bars (for players)

Econ

Author:  wanai [ Mon Jan 03, 2022 10:56 pm ]
Post subject:  Re: [Feature] HP/MP/SP bars (for players)

92.67

Author:  wanai [ Mon Jan 03, 2022 10:57 pm ]
Post subject:  Re: [Feature] HP/MP/SP bars (for players)

Bett

Author:  wanai [ Mon Jan 03, 2022 10:58 pm ]
Post subject:  Re: [Feature] HP/MP/SP bars (for players)

Bett

Author:  wanai [ Mon Jan 03, 2022 10:59 pm ]
Post subject:  Re: [Feature] HP/MP/SP bars (for players)

Carl

Author:  wanai [ Mon Jan 03, 2022 11:00 pm ]
Post subject:  Re: [Feature] HP/MP/SP bars (for players)

Caba

Author:  wanai [ Mon Jan 03, 2022 11:01 pm ]
Post subject:  Re: [Feature] HP/MP/SP bars (for players)

Isaa

Author:  wanai [ Mon Jan 03, 2022 11:03 pm ]
Post subject:  Re: [Feature] HP/MP/SP bars (for players)

Anto

Author:  wanai [ Mon Jan 03, 2022 11:04 pm ]
Post subject:  Re: [Feature] HP/MP/SP bars (for players)

Erle

Author:  wanai [ Mon Jan 03, 2022 11:05 pm ]
Post subject:  Re: [Feature] HP/MP/SP bars (for players)

Whit

Page 1 of 51 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/