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

Run Time Error 9 - Subscript Out Of Range


Santini
 Share

Recommended Posts

Hello,

First of all I am using Eclipse 3.0 (Nightly Release).

I created a new vital called hunger by going through the code and following how the hp and mp worked.
and the new vital (hunger) worked perfectly. So I tried to create another vital called thirst following the exact same method as before but this time when I press start it come up with this error:

Run-Time error '9':

Subscript out of range

When I press debug it highlights this line  of code:

HandleDataSub(SPlayerThirst) = GetAddress(AddressOf HandlePlayerThirst)

Thanks for taking the time to read this post.

Santini
Link to comment
Share on other sites

Yes and Yes.

Here is the HandlePlayerThirst sub:

>! Private Sub HandlePlayerThirst(ByVal Index As Long, ByRef data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
Dim Buffer As clsBuffer
>!     ' If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo errorhandler

    Set Buffer = New clsBuffer
    Buffer.WriteBytes data()
    Player(MyIndex).MaxVital(Vitals.Thirst) = Buffer.ReadLong
    Call SetPlayerVital(MyIndex, Vitals.Thirst, Buffer.ReadLong)
>!     If GetPlayerMaxVital(MyIndex, Vitals.Thirst) > 0 Then
        'frmMain.lblHP.Caption = Int(GetPlayerVital(MyIndex, Vitals.HP) / GetPlayerMaxVital(MyIndex, Vitals.HP) * 100) & "%"
        frmMain.lblThirst.Caption = GetPlayerVital(MyIndex, Vitals.Thirst) & "/" & GetPlayerMaxVital(MyIndex, Vitals.Thirst)
        ' hp bar
        frmMain.imgThirstBar.Width = ((GetPlayerVital(MyIndex, Vitals.Thirst) / ThirstBar_Width) / (GetPlayerMaxVital(MyIndex, Vitals.Thirst) / ThirstBar_Width)) * ThirstBar_Width
    End If
>!     ' Error handler
    Exit Sub
errorhandler:
    HandleError "HandlePlayerThirst", "modHandleData", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub

I have been trying to fix this error for ages. so hopefully someone will be able too.
Link to comment
Share on other sites

Here it is:

>! Public Enum ServerPackets
    SAlertMsg = 1
    SLoginOk
    SNewCharClasses
    SClassesData
    SInGame
    SPlayerInv
    SPlayerInvUpdate
    SPlayerWornEq
    SPlayerHp
    SPlayerMp
    SPlayerStats
    SPlayerData
    SPlayerMove
    SNpcMove
    SPlayerDir
    SNpcDir
    SPlayerXY
    SPlayerXYMap
    SAttack
    SNpcAttack
    SCheckForMap
    SMapData
    SMapItemData
    SMapNpcData
    SMapDone
    SGlobalMsg
    SAdminMsg
    SPlayerMsg
    SMapMsg
    SSpawnItem
    SItemEditor
    SUpdateItem
    SREditor
    SSpawnNpc
    SNpcDead
    SNpcEditor
    SUpdateNpc
    SMapKey
    SEditMap
    SShopEditor
    SUpdateShop
    SSpellEditor
    SUpdateSpell
    SSpells
    SLeft
    SResourceCache
    SResourceEditor
    SUpdateResource
    SSendPing
    SDoorAnimation
    SActionMsg
    SPlayerEXP
    SBlood
    SAnimationEditor
    SUpdateAnimation
    SAnimation
    SMapNpcVitals
    SCooldown
    SClearSpellBuffer
    SSayMsg
    SOpenShop
    SResetShopAction
    SStunned
    SMapWornEq
    SBank
    STrade
    SCloseTrade
    STradeUpdate
    STradeStatus
    STarget
    SHotbar
    SHighIndex
    SSound
    STradeRequest
    SPartyInvite
    SPartyUpdate
    SPartyVitals
    SQuestEditor
    SUpdateQuest
    SPlayerQuest
    SQuestMessage
    SSpawnEvent
    SEventMove
    SEventDir
    SEventChat
    SEventStart
    SEventEnd
    SPlayBGM
    SPlaySound
    SFadeoutBGM
    SStopSound
    SSwitchesAndVariables
    SMapEventData
    SChatBubble
    SSpecialEffect
    SPlayerHunger
    SPlayerThirst
    ' Make sure SMSG_COUNT is below everything else
    SMSG_COUNT
End Enum

The error happens during Initializing TCP settings when loading the client.

Thanks for trying to help. :)
Link to comment
Share on other sites

The only thing corresponding to SPlayerThirst on the server side is this:

>! Sub SendVital(ByVal Index As Long, ByVal Vital As Vitals)
    Dim packet As String
    Dim Buffer As clsBuffer
    Set Buffer = New clsBuffer
>!     Select Case Vital
        Case HP
            Buffer.WriteLong SPlayerHp
            Buffer.WriteLong GetPlayerMaxVital(Index, Vitals.HP)
            Buffer.WriteLong GetPlayerVital(Index, Vitals.HP)
        Case MP
            Buffer.WriteLong SPlayerMp
            Buffer.WriteLong GetPlayerMaxVital(Index, Vitals.MP)
            Buffer.WriteLong GetPlayerVital(Index, Vitals.MP)
        Case Hunger
            Buffer.WriteLong SPlayerHunger
            Buffer.WriteLong GetPlayerMaxVital(Index, Vitals.Hunger)
            Buffer.WriteLong GetPlayerVital(Index, Vitals.Hunger)
        Case Thirst
            Buffer.WriteLong SPlayerThirst
            Buffer.WriteLong GetPlayerMaxVital(Index, Vitals.Thirst)
            Buffer.WriteLong GetPlayerVital(Index, Vitals.Thirst)
    End Select
>!     SendDataTo Index, Buffer.ToArray()

    Set Buffer = Nothing
End Sub
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...