Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
RTE 9
#1
I get a Runtime Error 9 Subscript out of Range on these lines right when the client is loading, does anybody know why? I can't seem to pinpoint it. The tricky thing is is that it only happens like, 1 in every 50 times I load the client :p.

Code:
Function GetPlayerInvItemNum(ByVal Index As Long, ByVal InvSlot As Long) As Long
    GetPlayerInvItemNum = Player(Index).Inv(InvSlot).Num
End Function

It highlights GetPlayerInvItemNum = Player ect. ect.
Reply
#2
Do you have it set differently on the client than the server? Could always be the problem. Maybe the player's max inv is set higher on the client than the server.
Reply
#3
Nope, all constants are the same on server and client. I don't know if you noticed me say it only happens once every 50 or so times the client loads :?. Maybe you did but I edited it so just checking haha.
Reply
#4
something may be incorrectly saved or loaded, and when it's sent to the client, it's out of range... check and make sure that everything that is stored in the players inventory is stored the way it should be (itemnum, val, etc).
Reply
#5
Nope, that wasn't there when I read it, or I would have suggested what Obsi did. =P

If you need further help with this, I'm on MSN.
Reply
#6
RTE 9's are such badasses.
Reply
#7
Replace:
Code:
Function GetPlayerInvItemNum(ByVal Index As Long, ByVal InvSlot As Long) As Long
    GetPlayerInvItemNum = Player(Index).Inv(InvSlot).Num
End Function
With:
Code:
Function GetPlayerInvItemNum(ByVal Index As Long, ByVal InvSlot As Long) As Long
    If Index < 1 or Index > MAX_PLAYERS or InvSlot < 1 or InvSlot > MAX_INV Then Exit Function
    GetPlayerInvItemNum = Player(Index).Inv(InvSlot).Num
End Function

That should fix it, although you should probably also try and find the line of code that causes it. Cause this will not report a error, but the line of code that calls it wont work.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)