Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Display Player HP/MP Bars
#1
Author: GodSentDeath
Difficulty: 1/5

Note: This displays everybody's HP bars, but only you can see your own MP bar.

:: SERVER SIDE ::
In modHandleData, add:
Code:
' :::::::::::::::::::::::
' :: Get players stats ::
' :::::::::::::::::::::::
Dim Packet As String
If LCase(Parse(0)) = "playershpmp" Then
Packet = "playershpmp" & SEP_CHAR
For i = 1 To MAX_PLAYERS
Packet = Packet & GetPlayerHP(i) & SEP_CHAR & GetPlayerMaxHP(i) & SEP_CHAR
Next i
Packet = Packet & END_CHAR
Call SendDataTo(Index, Packet)
Exit Sub
End If

:: CLIENT SIDE ::
In modGameLogic, under:
Code:
' Blit out tile layer fringe
For y = 0 To MAX_MAPY
For x = 0 To MAX_MAPX
Call BltFringeTile(x, y)
Next x
Next y
Add:
Code:
' Blit players bar
Dim GSD As Long
If GetTickCount > GSD + 1000 Then
Call SendData("playershpmp" & SEP_CHAR & END_CHAR)
GSD = GetTickCount
End If


For i = 1 To MAX_PLAYERS
If IsPlaying(i) And GetPlayerMap(i) = GetPlayerMap(MyIndex) Then
Call BltPlayerBars(i)
End If
Next i
At the very bottom, add:
Code:
Sub BltPlayerBars(ByVal Index As Long)
Dim x As Long, y As Long
x = GetPlayerX(Index) * PIC_X + Player(Index).XOffset
y = GetPlayerY(Index) * PIC_Y + Player(Index).YOffset - 4
If Player(Index).HP = 0 Then Exit Sub

Call DD_BackBuffer.SetFillColor(RGB(255, 0, 0))
Call DD_BackBuffer.DrawBox(x, y + 32, x + 32, y + 36)

Call DD_BackBuffer.SetFillColor(RGB(0, 255, 0))
Call DD_BackBuffer.DrawBox(x, y + 32, x + ((Player(Index).HP / 100) / (Player(Index).MaxHP / 100) * 32), y + 36)

If Index = MyIndex Then
Call DD_BackBuffer.SetFillColor(RGB(255, 0, 0))
Call DD_BackBuffer.DrawBox(x, y + 35, x + 32, y + 39)

'draws MP for you
Call DD_BackBuffer.SetFillColor(RGB(0, 0, 255))
Call DD_BackBuffer.DrawBox(x, y + 35, x + ((Player(MyIndex).MP / 100) / (Player(MyIndex).MaxMP / 100) * 32), y + 39)
End If
End Sub

In modClientTCP, add: (anywhere)
Code:
' :::::::::::::::::::::::
' :: Get players stats ::
' :::::::::::::::::::::::
If LCase(Parse(0)) = "playershpmp" Then
n = 1

For i = 1 To MAX_PLAYERS
Player(i).HP = Val(Parse(n))
Player(i).MaxHP = Val(Parse(n + 1))

n = n + 2
Next i

Exit Sub
End If
That's all!
Reply
#2
modClientTCP on end or modHandleData??

im brazilian dont speak english Big Grin

Thx For all Big Grin
Reply
#3
It says modClientTCP. Unless I'm blind, then it should go there...
Reply
#4
Haha, me adiciona no msn que agente pode conversar...
Reply
#5
If your using Mirage 3.0.3 which this tutorial is for probably it goes in modClientTCP, if you are using MSE1 then it would go in the modHandleData.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)