Raised This Month: $ Target: $400
 0% 

Run time error 4: index out of bounds


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 02-11-2017 , 19:27   Re: Run time error 4: index out of bounds
Reply With Quote #4

The problem is not that "Skin_Info[ item ][ SKIN_KNIFE ]" is -1. It is that "item", id, the value of Player[] or Skin_Info[] is negative or larger than the array size.

How to debug your code in 5 minutes:
Print everything.
Code:
public menuitem_callbackc( id, menu, item ) { server_print("menuitem_callbackc(%d, %d, %d) called", id, menu, item);
If that doesn't reveal a problem, you add more messages.
Code:
server_print("Player[id][PLAYER_SKIN]: %d", Player[ id ][ PLAYER_SKIN ]) server_print("g_PlayerSkins[id][...]: %d", g_PlayerSkins[id][ Player[ id ][ PLAYER_SKIN ] ]) server_print("Skin_Info[item][SKIN_KNIFE]: %d", Skin_Info[ item ][ SKIN_KNIFE ]) server_print("g_PlayerKnives[id][...]: %d", g_PlayerKnives[id][Skin_Info[ item ][ SKIN_KNIFE ]])
One of these messages will show an obvious error which you will be able to correct.

If you are still unsure, post the result of those messages here.
__________________

Last edited by Black Rose; 02-11-2017 at 19:28.
Black Rose is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 20:44.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode