Raised This Month: $ Target: $400
 0% 

[Help] This code runtime errors


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-23-2015 , 20:00   Re: [Help] This code runtime errors
Reply With Quote #1

For the fourth time . . . what is the value of the index that is causing the out of bounds error?

Tell me the actual value when the error occurs. To make it easier for you, tell me both the value of "Index" and "Item" in the function when the error occurs.

I am 98% sure that I'm correct but without the information that I've asked for, 4 times now, I can't be 100% sure.
__________________
fysiks is offline
happy_2012
Senior Member
Join Date: Aug 2012
Old 11-24-2015 , 02:31   Re: [Help] This code runtime errors
Reply With Quote #2

Quote:
Originally Posted by fysiks View Post
For the fourth time . . . what is the value of the index that is causing the out of bounds error?

Tell me the actual value when the error occurs. To make it easier for you, tell me both the value of "Index" and "Item" in the function when the error occurs.

I am 98% sure that I'm correct but without the information that I've asked for, 4 times now, I can't be 100% sure.
I copied the whole error, it doesnt show values ��

[Edit]
I updated the plugin, I moved the knives up to the top of g_szShopData[ ][ ] constant, moved CATEGORY_KNIVES to the top of it's enumeration, and category name "Knives", to the top, and all worked fine. So I suppose you were right about that it was Item variable was causing the problem, but I think there would be another fix for this problem?
__________________
Discord contacts:
I rarely look at private messages here, but I am very active on Discord!

Last edited by happy_2012; 11-24-2015 at 09:29.
happy_2012 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-24-2015 , 19:58   Re: [Help] This code runtime errors
Reply With Quote #3

Quote:
Originally Posted by happy_2012 View Post
I copied the whole error, it doesnt show values ******************
It's called debugging. This is a critical skill that EVERY programmer should have. Getting the values of variables when the error occurs is probably the most common debugging first step. In AMX Mod X plugins, this is usually achieved by adding a server_print(), log_to_file(), or log_amx() containing the information that is relevant.

I didn't think I had to explain this much because I assumed you had reasonable experience considering how complex your code logic is.

Quote:
Originally Posted by happy_2012 View Post
I updated the plugin, I moved the knives up to the top of g_szShopData[ ][ ] constant, moved CATEGORY_KNIVES to the top of it's enumeration, and category name "Knives", to the top, and all worked fine. So I suppose you were right about that it was Item variable was causing the problem, but I think there would be another fix for this problem?
You are correct. Moving them in the shop data didn't actually fix the issue. Think about this:

Your function (that had the error) is given an index that relates to the shop data. However, your function doesn't need a shop data index, it needs a knife index. There is a relationship between the two and what you need to do is find out how to translate between them so that you can get the proper index for your purchased knives array.
__________________
fysiks is offline
happy_2012
Senior Member
Join Date: Aug 2012
Old 11-25-2015 , 15:39   Re: [Help] This code runtime errors
Reply With Quote #4

Quote:
Originally Posted by fysiks View Post
It's called debugging. This is a critical skill that EVERY programmer should have. Getting the values of variables when the error occurs is probably the most common debugging first step. In AMX Mod X plugins, this is usually achieved by adding a server_print(), log_to_file(), or log_amx() containing the information that is relevant.

I didn't think I had to explain this much because I assumed you had reasonable experience considering how complex your code logic is.



You are correct. Moving them in the shop data didn't actually fix the issue. Think about this:

Your function (that had the error) is given an index that relates to the shop data. However, your function doesn't need a shop data index, it needs a knife index. There is a relationship between the two and what you need to do is find out how to translate between them so that you can get the proper index for your purchased knives array.
Then it is in the confirmation menu, because when using the plugin actually, the confirmation menu shows up, but when you choose "Purchase" option from the menu, it does not buy the knife, yet it throw an error in the logs, the out of bounds error. You are right, the fix is in the Handle_ConfirmationMenu function, but I honestly do not know have any idea how to fix it.

I study medical science in the university, I learned PAWN from reading plugins, and trying, and this plugin was actual one complex plugin after many failure plugins or rip offs, but I think it would work out well if someone can guide me correctly in fixing the issues exists in it
__________________
Discord contacts:
I rarely look at private messages here, but I am very active on Discord!

Last edited by happy_2012; 11-25-2015 at 15:42.
happy_2012 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-25-2015 , 17:27   Re: [Help] This code runtime errors
Reply With Quote #5

I essentially told you what you need to do in my last paragraph. In fact, you already have code that does this for getting the shop data index (i.e. FindItemIndex). You just need to do that same thing for the knife data index.

None of this "fix" will go into Handle_ConfirmationMenu(). It should go into the function which uses the array based on the knife data. So, you still pass a shop data index into the function and then use that shop data index to get the appropriate knife data index. Then, when you have the knife data index, you use that instead of "Item".

P.S. It doesn't matter what you are studying. If you are going to program, in any form, you need to get familiar with debugging techniques (it will make your life easier and allow you to solve many problems without needing to ask for help). In fact, I've never taken any formal classes for any text-based programming languages. I've learned most everything on my own. The more you do it, the easier it gets (debugging).
__________________

Last edited by fysiks; 11-25-2015 at 17:31.
fysiks is offline
happy_2012
Senior Member
Join Date: Aug 2012
Old 11-25-2015 , 18:34   Re: [Help] This code runtime errors
Reply With Quote #6

Quote:
Originally Posted by fysiks View Post
I essentially told you what you need to do in my last paragraph. In fact, you already have code that does this for getting the shop data index (i.e. FindItemIndex). You just need to do that same thing for the knife data index.

None of this "fix" will go into Handle_ConfirmationMenu(). It should go into the function which uses the array based on the knife data. So, you still pass a shop data index into the function and then use that shop data index to get the appropriate knife data index. Then, when you have the knife data index, you use that instead of "Item".
Got it, but where specifically

Since now you know the problem, can you post a fixed version of the code?
__________________
Discord contacts:
I rarely look at private messages here, but I am very active on Discord!

Last edited by happy_2012; 11-25-2015 at 18:35.
happy_2012 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-25-2015 , 22:25   Re: [Help] This code runtime errors
Reply With Quote #7

Quote:
Originally Posted by happy_2012 View Post
Got it, but where specifically
Quote:
Originally Posted by fysiks View Post
It should go into the function which uses the array based on the knife data.
I.e. The function where the error occurs. But more generally, anywhere you need to use a knife data index instead of a shop data index.

Quote:
Originally Posted by happy_2012 View Post
Since now you know the problem, can you post a fixed version of the code?
Absolutely not. This is a forum for learning, not for just having things given to you. This is your plugin and I know that you are perfectly capable of doing this on your own.

So, now that you know what to do and where to put it, try it out and see what happens. If after trying it and you are still having issues, attach the new version of your plugin with your code changes (aka "the fix") and I will help you from there.
__________________

Last edited by fysiks; 11-25-2015 at 22:27.
fysiks is offline
Reply



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 18:12.


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