AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Help] This code runtime errors (https://forums.alliedmods.net/showthread.php?t=275131)

happy_2012 11-22-2015 15:50

[Help] This code runtime errors
 
1 Attachment(s)
Log errors
PHP Code:

L 11/22/2015 21:26:51Info (map "surf_ski_2") (file "addons/amxmodx/logs/error_20151122.log")
L 11/22/2015 21:26:51: [AMXXDisplaying debug trace (plugin "extreme_surf.amxx")
L 11/22/2015 21:26:51: [AMXXRun time error 4index out of bounds 
L 11
/22/2015 21:26:51: [AMXX]    [0extreme_surf.sma::Item_KnifeAssassin (line 959)
L 11/22/2015 21:28:10: [AMXXDisplaying debug trace (plugin "extreme_surf.amxx")
L 11/22/2015 21:28:10: [AMXXRun time error 4index out of bounds 
L 11
/22/2015 21:28:10: [AMXX]    [0extreme_surf.sma::Item_KnifeButcher (line 971

I could not fix them for some reason, can somebody please help me?

I have attached the plugin in attachments, I hope someone will be able to find or fix the problem for me, or at least guide me to fix it...

fysiks 11-22-2015 16:53

Re: [Help] This code runtime errors
 
What are the values of the Index and Item being passed to the function? Once you find out which one is causing the error, you need to trace that value back to see where it is getting set and why it's getting set to a non-valid value.

Also, according to amxmodx.inc, you should be using get_func_id() for getting the IDs to be using with callfunc_begin_i(). This is probably unrelated but it's better to use functions how they were intended.

happy_2012 11-22-2015 17:14

Re: [Help] This code runtime errors
 
I tried using this
if( Item < 0 || Item >= sizeof g_szKnifeData ) return;

It could buy the item, but when the player attempt to choose his knife from the ClientCommand_Knife function, he/she will not be able to select the item from the menu...

fysiks 11-22-2015 17:22

Re: [Help] This code runtime errors
 
I think I see it. You are sending a g_szShopData index to be used in an array that is sized by g_szKnifeData (these sizes are not the same nor are they related).

happy_2012 11-22-2015 17:41

Re: [Help] This code runtime errors
 
Quote:

Originally Posted by fysiks (Post 2365541)
I think I see it. You are sending a g_szShopData index to be used in an array that is sized by g_szKnifeData (these sizes are not the same nor are they related).

If you say so, where is that exactly?

I have also noticed that when someone buy the knife it say:
[ES] You have just bought: Butcher Knife

but it doesn't say:
[ES] Type /knife to choose your new knife

I am really confused with this, other items work smoothly, but knives do not.

fysiks 11-22-2015 18:06

Re: [Help] This code runtime errors
 
It took me a while to find it because I didn't write the code and the fact that you abstracted so much code made it harder. So, since you wrote the code and understand the logic you were using, you should be able to find it much quicker than I did.

Did you do what I told you to do originally? Find the value that was causing the out of bounds error (I'm sure it's Item) and track that value backward through the code to see where it comes from. You should find that the value of Item is coming from the shop data and not the knife data array.

If I feel generous when I get home later, I might try and explain it if possible.

happy_2012 11-22-2015 18:24

Re: [Help] This code runtime errors
 
I double checked the code, but there seems to be nothing wrong, this problem occurs only when buying a knife from the shop...

fysiks 11-22-2015 19:22

Re: [Help] This code runtime errors
 
For the third time . . . what is the value of the index that is causing the out of bounds error? (I'm quite sure that the variable in question is Item)


I bet the value is 16 for Assassin Knife, 17 for Light Knife, 18 for Butcher Knife, and 19 for Katana Knife. None of these values are valid indices for the second dimension of g_bKnifePurchased. In fact, if you work your way backwards (find where these functions are called), you'll notice that you are giving it a shop data index (and not a knife data index).

happy_2012 11-23-2015 15:04

Re: [Help] This code runtime errors
 
Quote:

Originally Posted by fysiks (Post 2365579)
For the third time . . . what is the value of the index that is causing the out of bounds error? (I'm quite sure that the variable in question is Item)


I bet the value is 16 for Assassin Knife, 17 for Light Knife, 18 for Butcher Knife, and 19 for Katana Knife. None of these values are valid indices for the second dimension of g_bKnifePurchased. In fact, if you work your way backwards (find where these functions are called), you'll notice that you are giving it a shop data index (and not a knife data index).

So if you are right, why I couldn't find anything like that? I checked every line over and over again, but found nothing? Perhaps I am too bad at finding errors, and correct them, can you help further? Like trying to fix the code if you are sure about your claim?

fysiks 11-23-2015 20:00

Re: [Help] This code runtime errors
 
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.


All times are GMT -4. The time now is 01:48.

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