Stats Bug

I have no idea why this happens. I can’t explain it, i do not change the stats but this happens:

PLEASE HELP :(

I use EO 3.0.

Can we see the code for the labels?

Can we see the code for the labels?


Private Sub HandlePlayerStats(ByVal Index As Long, ByRef data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)

Dim buffer As clsBuffer

Dim i As Long

    ' If debug mode, handle error then exit out

    If Options.Debug = 1 Then On Error GoTo errorhandler

    Set buffer = New clsBuffer

    buffer.WriteBytes data()

    For i = 1 To Stats.Stat_Count - 1

	    SetPlayerStat Index, i, buffer.ReadLong

	    frmMain.lblCharStat(i).Caption = GetPlayerStat(MyIndex, i)

    Next

    ' Error handler

    Exit Sub

errorhandler:

    HandleError "HandlePlayerStats", "modHandleData", Err.Number, Err.Description, Err.Source, Err.HelpContext

    Err.Clear

    Exit Sub

End Sub

And this in HandlePlayer Data


	    For x = 1 To Stats.Stat_Count - 1

		    frmMain.lblCharStat(x).Caption = GetPlayerStat(MyIndex, x)

	    Next

:(

You might have to wait until someone more familiar with EO 3.0 gets on, I’m afraid.

In the enumeration, how are your stats ordered? If strength is first, it is number 1. Everything below it has a value equal to its position. So… The For-Loop has to mock this. Please post your Enum and I will fix your Loop.


	    Select Case PointType

		    Case Stats.Strength

			    Call SetPlayerStat(index, Stats.Strength, GetPlayerRawStat(index, Stats.Strength) + 1)

			    sMes = "Strength"

		    Case Stats.Endurance

			    Call SetPlayerStat(index, Stats.Endurance, GetPlayerRawStat(index, Stats.Endurance) + 1)

			    sMes = "Endurance"

		    Case Stats.Intelligence

			    Call SetPlayerStat(index, Stats.Intelligence, GetPlayerRawStat(index, Stats.Intelligence) + 1)

			    sMes = "Intelligence"

		    Case Stats.Agility

			    Call SetPlayerStat(index, Stats.Agility, GetPlayerRawStat(index, Stats.Agility) + 1)

			    sMes = "Agility"

		    Case Stats.Willpower

			    Call SetPlayerStat(index, Stats.Willpower, GetPlayerRawStat(index, Stats.Willpower) + 1)

			    sMes = "Willpower"

	    End Select

Default Numeration

STR 1

DEX 2

INT 3

AGI 4

WILL 5

Alright, now check your label index’s. Making sure the label for strength has an index of 1 and so on and so forth. I’m guessing your strength is 0. Which the bug you described means all of the index’s are screwed up by one value.

STR Index 1

DEX Index 2

INT Index 3

AGI Index 4

WILL Index 5 :(

Are their names lblCharStat(Index)?

lblCharStat(1), lblCharStat(2), lblCharStat(3), lblCharStat(4), lblCharStat(5) :( is Index, name from labels is lblCharStat

The code you posted, is that the only code that includes lblCharStat.

Yes :S :(, no is a problem from server?

Add a break to

[background=rgb(248, 248, 248)]SetPlayerStat Index, i, buffer.ReadLong[/background]

[background=rgb(248, 248, 248)]frmMain.lblCharStat(i).Caption = GetPlayerStat(MyIndex, i)[/background]

Run your project and see what happens when you add a value. See what values are coming through.

If you want to make it easier, change those two lines to this

[background=rgb(248, 248, 248)]Dim Value as Long[/background]

[background=rgb(248, 248, 248)]SetPlayerStat Index, i, buffer.ReadLong[/background]

[background=rgb(248, 248, 248)]Value = [/background][background=rgb(248, 248, 248)]GetPlayerStat(MyIndex, i)[/background]

[background=rgb(248, 248, 248)]frmMain.lblCharStat(i).Caption = Value[/background]

And only put a break on [background=rgb(248, 248, 248)]frmMain.lblCharStat(i).Caption = Value[/background]

Then hover over ‘Value’ each time it breaks, making sure the values are coming through properly.

If they don’t come through properly, it’s a problem in the server. I’ll be back in a bit, going to grab a bite to eat.

No runtimes, Nothing happened D:, the problem is same :(

In the enumeration, how are your stats ordered? If strength is first, it is number 1. Everything below it has a value equal to its position. So… The For-Loop has to mock this. Please post your Enum and I will fix your Loop.

I’m still thinking this is what’s up. I’d be surprised if an enumeration offset is caused by anything else.

DarkDino, please post your version of this:```

’ Stats used by Players, Npcs and Classes

Public Enum Stats

Strength = 1

Endurance

Intelligence

Agility

Willpower

Skills

' Make sure Stat_Count is below everything else

Stat_Count

End Enum

for **both** client and server-side. You can find it in Mod Enumerations. So that we can better help, please don't simple state what it is - actually show the code.

Client


' Stats used by Players, Npcs and Classes

Public Enum Stats

    Strength = 1

    Endurance

    Intelligence

    Agility

    Willpower

    ' Make sure Stat_Count is below everything else

    Stat_Count

End Enum

and Server 😧


' Stats used by Players, Npcs and Classes

Public Enum Stats

    Strength = 1

    Endurance

    Intelligence

    Agility

    Willpower

    ' Make sure Stat_Count is below everything else

    Stat_Count

End Enum

Hmm… yeah everything seems good. May I see the stats part of the serverside code for Function PlayerData, and the full Sub SendStats?


Function PlayerData(ByVal index As Long) As Byte()

    Dim Buffer As clsBuffer, i As Long

    If index > MAX_PLAYERS Then Exit Function

    Set Buffer = New clsBuffer

    Buffer.WriteLong SPlayerData

    Buffer.WriteLong index

    Buffer.WriteString GetPlayerName(index)

    Buffer.WriteLong GetPlayerLevel(index)

    Buffer.WriteLong GetPlayerPOINTS(index)

    Buffer.WriteLong GetPlayerSprite(index)

    Buffer.WriteLong GetPlayerMap(index)

    Buffer.WriteLong GetPlayerX(index)

    Buffer.WriteLong GetPlayerY(index)

    Buffer.WriteLong GetPlayerDir(index)

    Buffer.WriteLong GetPlayerAccess(index)

    Buffer.WriteLong GetPlayerPK(index)

    Buffer.WriteLong GetPlayerClass(index)

    For i = 1 To Stats.Stat_Count - 1

	    Buffer.WriteLong GetPlayerStat(index, i)

    Next

    If Player(index).GuildFileId > 0 Then

    If TempPlayer(index).TmpGuildSlot > 0 Then

    Buffer.WriteByte 1

    Buffer.WriteString GuildData(TempPlayer(index).TmpGuildSlot).Guild_Name

    Buffer.WriteLong GuildData(TempPlayer(index).TmpGuildSlot).Guild_Logo

    End If

    Else

    Buffer.WriteByte 0

    Buffer.WriteLong 0

    End If

    PlayerData = Buffer.ToArray()

    Set Buffer = Nothing

End Function


Sub SendStats(ByVal index As Long)

Dim i As Long

Dim packet As String

Dim Buffer As clsBuffer

    Set Buffer = New clsBuffer

    Buffer.WriteLong SPlayerStats

    For i = 1 To Stats.Stat_Count - 1

	    Buffer.WriteLong GetPlayerStat(index, i)

    Next

    SendDataTo index, Buffer.ToArray()

    Set Buffer = Nothing

End Sub

😧

Hmm… everything looks perfect. It must be some simple little thing.

In handleplayerstats, try using index instead of myindex when setting the caption. Edit: I guess too in handleplayerdata.

Oh, and if you’re of these in HandlePlayerData that could also cause it.```

    Buffer.WriteLong GetPlayerLevel(index)

    Buffer.WriteLong GetPlayerPOINTS(index)

    Buffer.WriteLong GetPlayerSprite(index)

    Buffer.WriteLong GetPlayerMap(index)

    Buffer.WriteLong GetPlayerX(index)

    Buffer.WriteLong GetPlayerY(index)

    Buffer.WriteLong GetPlayerDir(index)

    Buffer.WriteLong GetPlayerAccess(index)

    Buffer.WriteLong GetPlayerPK(index)

    Buffer.WriteLong GetPlayerClass(index)

same error 😕

Log in to reply