Mirage Source
RTE 9 - Printable Version

+- Mirage Source (https://mirage-engine.uk/forums)
+-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61)
+--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18)
+---- Forum: General (https://mirage-engine.uk/forums/forumdisplay.php?fid=17)
+---- Thread: RTE 9 (/showthread.php?tid=874)



RTE 9 - Anthony - 13-04-2007

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.


- Matt - 13-04-2007

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.


- Anthony - 13-04-2007

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.


- Obsidian - 13-04-2007

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).


- Matt - 13-04-2007

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.


- Tony - 14-04-2007

RTE 9's are such badasses.


- William - 14-04-2007

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.