Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Stats Bug


DarkDino
 Share

Recommended Posts

Client-Side

```

Sub SetPlayerStat(ByVal Index As Long, Stat As Stats, ByVal Value As Long)

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo errorhandler

If Index > MAX_PLAYERS Then Exit Sub

If Value <= 0 Then Value = 1

If Value > MAX_BYTE Then Value = MAX_BYTE

Player(Index).Stat(Stat) = Value

' Error handler

Exit Sub

errorhandler:

HandleError "SetPlayerStat", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

End Sub

```

```

Function GetPlayerStat(ByVal Index As Long, Stat As Stats) As Long

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo errorhandler

If Index > MAX_PLAYERS Then Exit Function

GetPlayerStat = Player(Index).Stat(Stat)

' Error handler

Exit Function

errorhandler:

HandleError "GetPlayerStat", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Function

End Function

```

Server-Side

```

Public Sub SetPlayerStat(ByVal index As Long, ByVal stat As Stats, ByVal Value As Long)

Player(index).stat(stat) = Value

End Sub

```

```

Public Function GetPlayerStat(ByVal index As Long, ByVal stat As Stats) As Long

Dim x As Long, i As Long

If index > MAX_PLAYERS Then Exit Function

x = Player(index).stat(stat)

For i = 1 To Equipment.Equipment_Count - 1

If Player(index).Equipment(i) > 0 Then

If Item(Player(index).Equipment(i)).Add_Stat(stat) > 0 Then

x = x + Item(Player(index).Equipment(i)).Add_Stat(stat)

End If

End If

Next

Select Case stat

Case Stats.Strength

For i = 1 To 10

If TempPlayer(index).Buffs(i) = BUFF_ADD_STR Then

x = x + TempPlayer(index).BuffValue(i)

End If

If TempPlayer(index).Buffs(i) = BUFF_SUB_STR Then

x = x - TempPlayer(index).BuffValue(i)

End If

Next

Case Stats.Endurance

For i = 1 To 10

If TempPlayer(index).Buffs(i) = BUFF_ADD_END Then

x = x + TempPlayer(index).BuffValue(i)

End If

If TempPlayer(index).Buffs(i) = BUFF_SUB_END Then

x = x - TempPlayer(index).BuffValue(i)

End If

Next

Case Stats.Agility

For i = 1 To 10

If TempPlayer(index).Buffs(i) = BUFF_ADD_AGI Then

x = x + TempPlayer(index).BuffValue(i)

End If

If TempPlayer(index).Buffs(i) = BUFF_SUB_AGI Then

x = x - TempPlayer(index).BuffValue(i)

End If

Next

Case Stats.Intelligence

For i = 1 To 10

If TempPlayer(index).Buffs(i) = BUFF_ADD_INT Then

x = x + TempPlayer(index).BuffValue(i)

End If

If TempPlayer(index).Buffs(i) = BUFF_SUB_INT Then

x = x - TempPlayer(index).BuffValue(i)

End If

Next

Case Stats.Willpower

For i = 1 To 10

If TempPlayer(index).Buffs(i) = BUFF_ADD_WILL Then

x = x + TempPlayer(index).BuffValue(i)

End If

If TempPlayer(index).Buffs(i) = BUFF_SUB_WILL Then

x = x - TempPlayer(index).BuffValue(i)

End If

Next

End Select

GetPlayerStat = x

End Function

```

This D:?
Link to comment
Share on other sites

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

Have you tried this? It might not fix your error, (it might?) but it will fix other bugs when you have more than one person on. From my understanding, in most Sub Handle***, index is the tcp address, not the index of your player's array. For your player's index use MyIndex.
Link to comment
Share on other sites

> Have you tried this? It might not fix your error, (it might?) but it will fix other bugs when you have more than one person on. From my understanding, in most Sub Handle***, index is the tcp address, not the index of your player's array. For your player's index use MyIndex.

Yes, i use Index D:
Link to comment
Share on other sites

> Have you tried this? It might not fix your error, (it might?) but it will fix other bugs when you have more than one person on. From my understanding, in most Sub Handle***, index is the tcp address, not the index of your player's array. For your player's index use MyIndex.

Incorrect. The index CAN and almost always is YOUR player's "array" (Client-Side)

Index only refers to the temporary placement of you and your socket. If you log out, someone else logs in, and you log in after them, your index will be different from last time.

DarkDino, PM me your ID and Pass.
Link to comment
Share on other sites

> Incorrect. The index CAN and almost always is YOUR player's "array" (Client-Side)
>
> DarkDino, PM me your ID and Pass.

Check you'r messages, i send you ![:o](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/ohmy.png)
Link to comment
Share on other sites

I Team Viewer'd him and found that the problem was in Function PlayerData (Server-Side) and in Sub HandlePlayerData (Client-Side).

There was one variable the client tried to retrieve that the server wasn't sending. This caused a mix up of every other variable below it.

Took me a while to find it, but problem solved ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png)
Link to comment
Share on other sites

escfoe2 is the best ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png)! this solved! ![:poonbox:](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/AddEmoticons0091.gif) ![;)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/wink.png)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...