Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Server Loop Help
#1
Ok, I'm not quite sure how to do this. I know what I WANT to do, I just haven't figured out how. So I'm trying to make a code in the server loop that every 10 seconds looks at all the players online, and updates a stat I created for them. I'm working on a fishing system, and I'm coding it up one piece at a time, to get all the error straight before hand.

[spoiler]So I found this in the ServerLoop
Code:
If Tick > LastUpdatePlayerVitals Then
            UpdatePlayerVitals
            LastUpdatePlayerVitals = GetTickCount + 5000
        End If

And added under it

Code:
If Tick > LastUpdatePlayerFishing Then
            UpdatePlayerFishing
            LastUpdatePlayerFishing = GetTickCount + 10000
        End If

This, code, Like the updateplayervitals, runs every so often. After that I added a sub down near the bottom

Code:
Private Sub UpdatePlayerFishing()
Dim i As Long, fishness As Byte

    For i = 1 To MAX_PLAYERS
        If IsPlaying(i) Then
            fishness = Int(GetPlayerStat(index, Stats.canfish))
                If fishness >= 1 then
                      Call SetPlayerStat(index, Stats.canfish, GetPlayerStat(index, Stats.canfish) - fishness)
                Else
                End If
        End If
    Next i
End Sub

I got an run time error 9, subscript out of range, upon hitting that 10 second mark on the code
Code:
Public Function GetPlayerStat(ByVal index As Long, ByVal Stat As Stats) As Long
    GetPlayerStat = Player(index).Char(TempPlayer(index).CharNum).Stat(Stat)
End Function

I'm figuring this has something to do with the specific player index, but I can't think of a way to make this work. Can anyone help out? Thank you.[/spoiler]
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)