Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Live/Visual Stats
#5
That would work. The only thing is the stats will only be updated whenever you do something that calls the SendStats procedure on the server. So on the server, on frmServer, make a new timer and put this code in it:

Code:
Dim i As Byte

    For i = 1 To MAX_PLAYERS
        If IsPlaying(i) And IsConnected(i) Then
            Call SendStats(i)
        End If
    Next i

Interval: 1000
Enabled: True

This will update every players stats every second.

EDIT: I also think you may have the code a little messed up.

Open the Server source code and change the following things. I'm just going to post the code for what I think you're trying to do.

in modServerTCP, find:

Code:
Sub SendStats(ByVal Index As Long)
Dim Packet As String
    
    Packet = "PLAYERSTATS" & SEP_CHAR & GetPlayerSTR(Index) & SEP_CHAR & GetPlayerDEF(Index) & SEP_CHAR & GetPlayerSPEED(Index) & SEP_CHAR & GetPlayerMAGI(Index) & SEP_CHAR & END_CHAR
    Call SendDataTo(Index, Packet)
End Sub

Replace it with this:
Code:
Sub SendStats(ByVal Index As Long)
Dim Packet As String
    
    Packet = "PLAYERSTATS" & SEP_CHAR & GetPlayerSTR(Index) & SEP_CHAR & GetPlayerDEF(Index) & SEP_CHAR & GetPlayerSPEED(Index) & SEP_CHAR & GetPlayerMAGI(Index) & SEP_CHAR & GetPlayerLevel(Index) & SEP_CHAR & GetPlayerExp(Index) & SEP_CHAR & END_CHAR
    Call SendDataTo(Index, Packet)
End Sub

Now right here I'll explain a little something, just because it doesn't seem you understand how parsing works Smile.

We send data to the client in a certain order. That order determines how we will later pick up the data on the client side. If you read it wrong on the client side, you could be displaying magi on your strength label, or displaying the players experience on the speed label... which we don't want. Lol.

So here's how the serve ris going to send that above data to the client:

0. "PLAYERSTATS"
1. GetPlayerSTR(Index)
2. GetPlayerDEF(Index)
3. GetPlayerSPEED(Index)
4. GetPlayerMAGI(Index)
5. GetPlayerLevel(Index)
6. GetPlayerExp(Index)

Now... open up the client source code and in modHandleData find the following:

Code:
' :::::::::::::::::::::::::
    ' :: Player stats packet ::
    ' :::::::::::::::::::::::::
    If LCase(Parse(0)) = "playerstats" Then
        Call SetPlayerSTR(MyIndex, Val(Parse(1)))
        Call SetPlayerDEF(MyIndex, Val(Parse(2)))
        Call SetPlayerSPEED(MyIndex, Val(Parse(3)))
        Call SetPlayerMAGI(MyIndex, Val(Parse(4)))
        Exit Sub
    End If

Replace it with this:

Code:
' :::::::::::::::::::::::::
    ' :: Player stats packet ::
    ' :::::::::::::::::::::::::
    If LCase(Parse(0)) = "playerstats" Then
        Call SetPlayerSTR(MyIndex, Val(Parse(1)))
        Call SetPlayerDEF(MyIndex, Val(Parse(2)))
        Call SetPlayerSPEED(MyIndex, Val(Parse(3)))
        Call SetPlayerMAGI(MyIndex, Val(Parse(4)))
        Call SetPlayerLevel(MyIndex, Val(Parse(5)))
        Call SetPlayerExp(MyIndex, Val(Parse(6)))
        Exit Sub
    End If

Notice how we read it on the client in the same order as we sent it from the server? This not only makes the code cleaner and easy to find bugs, but it also makes sure we know exactly which variable we are setting each stat too. The way your code looks, judging that your server side code sends the stats in the same order I have, you woudl be setting the players strength level to whatever the value of their experience was. Which isn't good, obviously.

Now, let's add the stuff to display that. Make sure you edit the following code to suit your labels.

Code:
' :::::::::::::::::::::::::
    ' :: Player stats packet ::
    ' :::::::::::::::::::::::::
    If LCase(Parse(0)) = "playerstats" Then
        Call SetPlayerSTR(MyIndex, Val(Parse(1)))
        Call SetPlayerDEF(MyIndex, Val(Parse(2)))
        Call SetPlayerSPEED(MyIndex, Val(Parse(3)))
        Call SetPlayerMAGI(MyIndex, Val(Parse(4)))
        Call SetPlayerLevel(MyIndex, Val(Parse(5)))
        Call SetPlayerExp(MyIndex, Val(Parse(6)))
        
        frmMirage.LblStrength = GetPlayerSTR(MyIndex)
        frmMirage.LblDefense = GetPlayerDEF(MyIndex)
        frmMirage.LblSpeed = GetPlayerSPEED(MyIndex)
        frmMirage.LblMagic = GetPlayerMAGI(MyIndex)
        frmMirage.LblLevel = GetPlayerLevel(MyIndex)
        frmMirage.LblExp = GetPlayerExp(MyIndex)
        Exit Sub
    End If

This will now send the stats, experience, and level of each player connected to your server every second and display it on the labels you make on frmMirage. If you ahve any problems just post.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)