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

Subscript out of range


Growlith1223
 Share

Recommended Posts

ok so like, i've made everything perfect no errors until the npc wants to join…

it subscripts on this sub.

```

Sub HandleRequestJoin(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.WriteByte Data()

Index = Buffer.ReadLong

Set Buffer = Nothing

With frmMain

.picpokemonJoin.Visible = True

.lblInfo.Caption = Npc(Index).Name & " wants to join!"

End With

' Error handler

Exit Sub

errorhandler:

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

Err.Clear

Exit Sub

End Sub

```

it highlights the .lblInfo part

i highlight Index in that area and it says 0

Help is appreciated!
Link to comment
Share on other sites

```

Sub HandleRequestJoin(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.WriteByte Data()

I = Buffer.ReadLong

Set Buffer = Nothing

With frmMain

.picpokemonJoin.Visible = True

if Npc(I).Name <> Vbnullstring then

.lblInfo.Caption = Npc(I).Name & " wants to join!"

end if

End With

' Error handler

Exit Sub

errorhandler:

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

Err.Clear

Exit Sub

End Sub
```
Link to comment
Share on other sites

> ```
> [color]Sub[/color][color] [/color][color]HandleRequestJoin[/color][color]([/color][color]ByVal[/color][color] [/color][color]Index[/color][color] [/color][color]As[/color][color] [/color][color]Long[/color][color],[/color][color] [/color][color]ByRef[/color][color] [/color][color]Data[/color][color]()[/color][color] [/color][color]As[/color][color] [/color][color]Byte[/color][color],[/color][color] [/color][color]ByVal[/color][color] [/color][color]StartAddr[/color][color] [/color][color]As[/color][color] [/color][color]Long[/color][color],[/color][color] [/color][color]ByVal[/color][color] [/color][color]ExtraVar[/color][color] [/color][color]As[/color][color] [/color][color]Long[/color][color])[/color]
>
> [color]Dim[/color][color] [/color][color]Buffer[/color][color] [/color][color]As[/color][color] clsBuffer
>
> Dim i as long
>
> [/color][color]' If debug mode, handle error then exit out
>
> If Options.Debug = 1 Then On Error GoTo errorhandler
>
> Set Buffer = New clsBuffer
>
> Buffer.WriteByte Data()
>
> I = Buffer.ReadLong
>
> Set Buffer = Nothing
>
> With frmMain
>
> .picpokemonJoin.Visible = True
>
> .lblInfo.Caption = Npc(I).Name & " wants to join!"
>
> End With
>
> '[/color][color] [/color][color]Error[/color][color] handler
>
> [/color][color]Exit[/color][color] [/color][color]Sub[/color]
>
> [color]errorhandler[/color][color]:[/color]
>
> [color]HandleError[/color][color] [/color][color]"HandleData"[/color][color],[/color][color] [/color][color]"modHandleData"[/color][color],[/color][color] [/color][color]Err[/color][color].[/color][color]Number[/color][color],[/color][color] [/color][color]Err[/color][color].[/color][color]Description[/color][color],[/color][color] [/color][color]Err[/color][color].[/color][color]Source[/color][color],[/color][color] [/color][color]Err[/color][color].[/color][color]HelpContext[/color]
>
> [color]Err[/color][color].[/color][color]Clear[/color]
>
> [color]Exit[/color][color] [/color][color]Sub[/color]
>
> [color]End[/color][color] [/color][color]Sub[/color]
> ```

dafuq? that made me lol and couldnt help but reply
Link to comment
Share on other sites

Here we go:

```
Sub HandleRequestJoin(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)

Dim Buffer As clsBuffer

Dim nIndex As Long

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo errorhandler

Set Buffer = New clsBuffer

Buffer.WriteByte Data()

nIndex = Buffer.ReadLong

Set Buffer = Nothing

With frmMain

.picpokemonJoin.Visible = True

.lblInfo.Caption = Trim$(Npc(nIndex).Name) & " wants to join!"

End With

' Error handler

Exit Sub

errorhandler:

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

Err.Clear

Exit Sub

End Sub
```
Link to comment
Share on other sites

Tehdoug just gtfo…ur not helping.... ![-_-](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/sleep.png)

Anyways here's the sub for sending the packet.

```

Sub NpcRecruitmentRequest(ByVal index As Long, ByVal npcNum As Long)

Dim Buffer As clsBuffer

Set Buffer = New clsBuffer

Buffer.WriteLong SRequestJoin

Buffer.WriteLong npcNum

SendDataTo index, Buffer.ToArray()

Set Buffer = Nothing

Exit Sub

End Sub

```
Link to comment
Share on other sites

> Sub HandleRequestJoin(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()
>
> i = Buffer.ReadLong
>
> Set Buffer = Nothing
>
> Call RecruitableNpcKilled(i)
>
> ' Error handler
>
> Exit Sub
>
> errorhandler:
>
> HandleError "HandleHotbar", "modHandleData", Err.Number, Err.Description, Err.Source, Err.HelpContext
>
> Err.Clear
>
> Exit Sub
>
> End Sub

Now create a new mod called mod modRecruitment or something and in that mod add-

> Public Function RecruitableNpcKilled(ByVal NpcNum As Long)
>
> frmMain.picpokemonJoin.Visible = True
>
> frmMain.picRecruitFace.Picture = LoadPicture(App.Path & GFX_PATH & "\faces\" & Npc(NpcNum).Sprite & ".bmp") (Only if you have)
>
> RecruitNpcNum = NpcNum
>
> End Function
Link to comment
Share on other sites

How the duck does creating a new function fix the problem? Someone please enlighten me, I was using TeamViewer to help him out but nothing worked and now this ![:P](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/tongue.png)
Link to comment
Share on other sites

> There was no need for the <>nullstring in the first place.

It is good practice to make sure the string actually has a value, so why not have it?

Also, before you decide to act like you ducking solved the problem, please notice you just took what me and zesh posted, and made it call a unneeded function. You did the same damn thing.

> THANKYOU! Finally someone is not dumb enough to just add one line that will just end up doing that same thing!

You really have the idea to call someone a dumbass who attempted to help your sorry ass, fine. Don't expect any help from me anymore.
Link to comment
Share on other sites

One, I solved the problem I'm not acting and I don't remember pretending to be a smartass like you're doing right now I simply helped by applying what I knew…it's not my fault that was something you failed to do.

Two I didn't take anything from you or Zesh, I took what Zero posted and applied code to make it work I don't need you or zesh to do so, so don't go acting high and mighty oh and fyi I have my own system similar to what he's trying to make just more advanced so it's not that hard for me to know what to do it's simply trial and error until you get it right.

Don't be a ducking douchebag just move on and be glad that zero got the help that was needed I'm simply here answering questions.Nevertheless I'm being a bit immature as this isn't the place for negative comments.

Edit: btw I don't remember growlith directly calling anyone dumb, but if you have three people posting the same thing which isn't helping use sense that's just annoying that doesn't mean you should stop being helpful to someone.
Link to comment
Share on other sites

> One, I solved the problem I'm not acting and I don't remember pretending to be a smartass like you're doing right now I simply helped by applying what I knew…it's not my fault that was something you failed to do.
>
> Two I didn't take anything from you or Zesh, I took what Zero posted and applied code to make it work I don't need you or zesh to do so, so don't go acting high and mighty oh and fyi I have my own system similar to what he's trying to make just more advanced so it's not that hard for me to know what to do it's simply trial and error until you get it right.
>
> Don't be a ducking douchebag just move on and be glad that zero got the help that was needed I'm simply here answering questions.Nevertheless I'm being a bit immature as this isn't the place for negative comments.
>
> Edit: btw I don't remember growlith directly calling anyone dumb, but if you have three people posting the same thing which isn't helping use sense that's just annoying that doesn't mean you should stop being helpful to someone.

I apologize for coming off as a childish stick. Argument over.
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...