Raised This Month: $32 Target: $400
 8% 

Run time error 4: index out of bounds


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Unzy
Junior Member
Join Date: Apr 2017
Old 11-18-2021 , 13:08   Run time error 4: index out of bounds
Reply With Quote #1

Hi all,

I get the following amxx error :

[AMXX] Displaying debug trace (plugin "adminmodx.amxx", version "0.9h")
[AMXX] Run time error 4: index out of bounds
[AMXX] [0] textRXNyAz.sma::eDeath (line 2584)

Can someone have a quick look at the corresponding code and maybe spot something?
I've also attached the complete sma in case that should be needed
thx so much! and apologies if that's handled already/posted in wrong section

2578 ///////////////////////////////////////////////////////////////////////////////////////
2579 //
2580 // Will reset the things upon death
2581 //
2582 public eDeath()
2583 {
2584 g_buried[read_data(2)] = 0
2585
2586 if(task_exists((read_data(2)+1000)))
2587 {
2588 remove_task((read_data(2)+1000))
2589 }
2590 }
2591
2592 ///////////////////////////////////////////////////////////////////////////////////////
2593 //
Attached Files
File Type: sma Get Plugin or Get Source (adminmodx.sma - 102 views - 83.1 KB)
__________________
Unzy is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-18-2021 , 20:51   Re: Run time error 4: index out of bounds
Reply With Quote #2

I'm not sure that's even possible because this message is only for when a player dies (i.e. the victim, read_data(2), should always be in the rang 1 to 32). You'll probably need to add some debugging code to see what value it actually being retrieved from read_data(2).

Replace the eDeath() function with this one:

Code:
public eDeath()
{
	log_amx("DeathMsg Debug %d %d", read_data(1), read_data(2))
	g_buried[read_data(2)] = 0

	if(task_exists((read_data(2)+1000)))
	{
		remove_task((read_data(2)+1000))
	}
}
Then, when the error occurs again, look in your AMX Mod X logs for the timestamp of the error. Post several of the "DeathMsg Debug" before and after the timestamp of the error.
__________________
fysiks is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-18-2021 , 21:29   Re: Run time error 4: index out of bounds
Reply With Quote #3

You can call remove_task() without first checking task_exists(). task_exists() is really to be used if you need to know if a task exists, here you just want it removed.
PHP Code:
public eDeath()
{
    new 
iKiller read_data)
    new 
iVictim read_data);
    
    
log_amx("DeathMsg Debug %d %d"iKilleriVictim)
    
    
g_buried[iVictim] = 0
    remove_task
((iVictim+1000))

__________________

Last edited by Bugsy; 11-18-2021 at 21:31.
Bugsy is offline
Unzy
Junior Member
Join Date: Apr 2017
Old 11-19-2021 , 13:31   Re: Run time error 4: index out of bounds
Reply With Quote #4

Thank you Fysiks and Bugsy

I used the code given by bugsy , the following error was picked up (copypasted before and after)

Quote:
L 11/19/2021 - 12:50:57: [AMXX] [0] textDqTnDV.sma::eDeath (line 2584)
L 11/19/2021 - 12:53:08: [AMXX] Displaying debug trace (plugin "adminmodx.amxx", version "0.9h")
L 11/19/2021 - 12:53:08: [AMXX] Run time error 4: index out of bounds
L 11/19/2021 - 12:53:08: [AMXX] [0] textDqTnDV.sma::eDeath (line 2584)
L 11/19/2021 - 12:535: [AMXX] Displaying debug trace (plugin "adminmodx.amxx", version "0.9h")
L 11/19/2021 - 12:535: [AMXX] Run time error 4: index out of bounds
L 11/19/2021 - 12:535: [AMXX] [0] textDqTnDV.sma::eDeath (line 2584)
L 11/19/2021 - 12:562: Start of error session.
L 11/19/2021 - 12:562: Info (map "smallfort") (file "addons/amxmodx/logs/error_20211119.log")
L 11/19/2021 - 12:562: [AMXX] Displaying debug trace (plugin "adminmodx.amxx", version "0.9h")
L 11/19/2021 - 12:562: [AMXX] Run time error 4: index out of bounds
L 11/19/2021 - 12:562: [AMXX] [0] textucScDj.sma::eDeath (line 2585)
L 11/19/2021 - 12:56:44: [AMXX] Displaying debug trace (plugin "adminmodx.amxx", version "0.9h")
L 11/19/2021 - 12:56:44: [AMXX] Run time error 4: index out of bounds
L 11/19/2021 - 12:56:44: [AMXX] [0] textucScDj.sma::eDeath (line 2585)
L 11/19/2021 - 12:56:59: [AMXX] Displaying debug trace (plugin "adminmodx.amxx", version "0.9h")
The error doesnt really bother me that much, the plugin works fine. Just curious for a solution and its using a few MB's of error log every day

Anyways, thx for having a look at it, dont worry too much about it!

U.
__________________
Unzy is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-19-2021 , 19:16   Re: Run time error 4: index out of bounds
Reply With Quote #5

It doesn't make any sense that you are getting an error on g_buried being its sized at 33. Did you modify anything?

And moved to scripting help
__________________

Last edited by Bugsy; 11-19-2021 at 19:23.
Bugsy is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-19-2021 , 23:44   Re: Run time error 4: index out of bounds
Reply With Quote #6

Quote:
Originally Posted by Unzy View Post
Thank you Fysiks and Bugsy

I used the code given by bugsy , the following error was picked up (copypasted before and after)



The error doesnt really bother me that much, the plugin works fine. Just curious for a solution and its using a few MB's of error log every day

Anyways, thx for having a look at it, dont worry too much about it!

U.
So, you've only provided the error log. The debug string that we added to that function will be in the normal AMX Mod X logs. You should remove all lines except those that contain "DeathMsg Debug" before posting. Ideally, we'd get the lines that correspond to the times of the errors. So, all the debug message lines around the 11/19/2021 - 12:56 timestamp.
__________________
fysiks is offline
Unzy
Junior Member
Join Date: Apr 2017
Old 11-20-2021 , 03:26   Re: Run time error 4: index out of bounds
Reply With Quote #7

Thx Bugsy and Fysics, for taking some time on this

Bugsy,

I did not modify anything, except of course for the php code u gave me.
I can perhaps give more info about my actions?

I downloaded the sma from this post on your forum:
https://forums.alliedmods.net/showth...t=5412&page=52
(post #512, the final post)

Then ive compiled the sma via your online amxmodx webcompiler

Maybe i shudve used the original one from page 1?

Fysics,

Yes, ive looked at the normal amx log, but there were no errors in that one, just all the mapchanges and admins joining and of course all the deathmsgs debug lines.
Ive attached the log in its complete form, shud you happen to be interested

Thx you guys!

-X-
__________________
Unzy is offline
Unzy
Junior Member
Join Date: Apr 2017
Old 11-20-2021 , 03:29   Re: Run time error 4: index out of bounds
Reply With Quote #8

File didnt seem to be attached, apologies*

It goes on like this :

Quote:
L 11/19/2021 - 10:42:07: [adminmodx.amxx] DeathMsg Debug 13 16
L 11/19/2021 - 10:42:09: -------- Mapchange to well3 --------
L 11/19/2021 - 10:42:10: [admin.amxx] Login: "-X-<214><STEAM_0:1:126476526><>" became an admin (account "STEAM_0:1:126476526") (access "abcdefghijklmnopqrstuv") (address "94.227.82.174")
L 11/19/2021 - 11:11:26: -------- Mapchange to massive --------
L 11/19/2021 - 11:40:42: -------- Mapchange to enclave --------
L 11/19/2021 - 11:56:58: -------- Mapchange to pharaohs --------
L 11/19/2021 - 12:26:14: -------- Mapchange to well --------
L 11/19/2021 - 12:28:56: [admin.amxx] Login: "-X-<402><STEAM_0:1:126476526><>" became an admin (account "STEAM_0:1:126476526") (access "abcdefghijklmnopqrstuv") (address "94.227.82.174")
L 11/19/2021 - 12:552: -------- Mapchange to smallfort --------
L 11/19/2021 - 12:553: [admin.amxx] Login: "-X-<402><STEAM_0:1:126476526><>" became an admin (account "STEAM_0:1:126476526") (access "abcdefghijklmnopqrstuv") (address "94.227.82.174")
L 11/19/2021 - 12:56:00: [adminmodx.amxx] DeathMsg Debug 30 1
L 11/19/2021 - 12:56:05: [adminmodx.amxx] DeathMsg Debug 30 2
L 11/19/2021 - 12:56:07: [adminmodx.amxx] DeathMsg Debug 4 21
L 11/19/2021 - 12:56:08: [adminmodx.amxx] DeathMsg Debug 30 3
L 11/19/2021 - 12:56:14: [adminmodx.amxx] DeathMsg Debug 30 4
L 11/19/2021 - 12:56:15: [adminmodx.amxx] DeathMsg Debug 30 1
L 11/19/2021 - 12:56:16: [adminmodx.amxx] DeathMsg Debug 25 7
L 11/19/2021 - 12:56:16: [adminmodx.amxx] DeathMsg Debug 30 2
L 11/19/2021 - 12:56:17: [adminmodx.amxx] DeathMsg Debug 6 30
L 11/19/2021 - 12:56:19: [adminmodx.amxx] DeathMsg Debug 20 8
L 11/19/2021 - 12:56:20: [adminmodx.amxx] DeathMsg Debug 20 2
L 11/19/2021 - 12:56:22: [adminmodx.amxx] DeathMsg Debug 30 9
L 11/19/2021 - 12:56:22: [adminmodx.amxx] DeathMsg Debug 30 10
L 11/19/2021 - 12:56:23: [adminmodx.amxx] DeathMsg Debug 30 11
L 11/19/2021 - 12:56:23: [adminmodx.amxx] DeathMsg Debug 20 1
L 11/19/2021 - 12:56:23: [adminmodx.amxx] DeathMsg Debug 6 6
L 11/19/2021 - 12:56:24: [adminmodx.amxx] DeathMsg Debug 14 21
L 11/19/2021 - 12:560: [adminmodx.amxx] DeathMsg Debug 27 7
L 11/19/2021 - 12:560: [adminmodx.amxx] DeathMsg Debug 26 5
L 11/19/2021 - 12:560: [adminmodx.amxx] DeathMsg Debug 23 2
L 11/19/2021 - 12:562: [adminmodx.amxx] DeathMsg Debug 14 -1
L 11/19/2021 - 12:563: [adminmodx.amxx] DeathMsg Debug 23 14
L 11/19/2021 - 12:563: [adminmodx.amxx] DeathMsg Debug 5 25
L 11/19/2021 - 12:566: [adminmodx.amxx] DeathMsg Debug 20 1
L 11/19/2021 - 12:567: [adminmodx.amxx] DeathMsg Debug 20 9
L 11/19/2021 - 12:568: [adminmodx.amxx] DeathMsg Debug 5 26
L 11/19/2021 - 12:569: [adminmodx.amxx] DeathMsg Debug 14 21
L 11/19/2021 - 12:569: [adminmodx.amxx] DeathMsg Debug 8 30
L 11/19/2021 - 12:56:41: [adminmodx.amxx] DeathMsg Debug 27 12
L 11/19/2021 - 12:56:41: [adminmodx.amxx] DeathMsg Debug 27 15
L 11/19/2021 - 12:56:42: [adminmodx.amxx] DeathMsg Debug 30 6
L 11/19/2021 - 12:56:42: [adminmodx.amxx] DeathMsg Debug 30 8
L 11/19/2021 - 12:56:42: [adminmodx.amxx] DeathMsg Debug 30 11
L 11/19/2021 - 12:56:44: [adminmodx.amxx] DeathMsg Debug 8 -1
L 11/19/2021 - 12:56:45: [adminmodx.amxx] DeathMsg Debug 15 21
L 11/19/2021 - 12:56:47: [adminmodx.amxx] DeathMsg Debug 27 2
L 11/19/2021 - 12:56:49: [adminmodx.amxx] DeathMsg Debug 4 26
L 11/19/2021 - 12:56:51: [adminmodx.amxx] DeathMsg Debug 27 14
L 11/19/2021 - 12:56:52: [adminmodx.amxx] DeathMsg Debug 27 7
L 11/19/2021 - 12:56:54: [adminmodx.amxx] DeathMsg Debug 11 21
L 11/19/2021 - 12:56:55: [adminmodx.amxx] DeathMsg Debug 22 4
L 11/19/2021 - 12:56:55: [adminmodx.amxx] DeathMsg Debug 22 5
L 11/19/2021 - 12:56:56: [adminmodx.amxx] DeathMsg Debug 27 1
L 11/19/2021 - 12:56:57: [adminmodx.amxx] DeathMsg Debug 25 2
L 11/19/2021 - 12:56:58: [adminmodx.amxx] DeathMsg Debug 26 13
L 11/19/2021 - 12:56:58: [adminmodx.amxx] DeathMsg Debug 27 6
L 11/19/2021 - 12:56:58: [adminmodx.amxx] DeathMsg Debug 8 20
L 11/19/2021 - 12:56:58: [adminmodx.amxx] DeathMsg Debug 8 21
L 11/19/2021 - 12:56:58: [adminmodx.amxx] DeathMsg Debug 27 10
L 11/19/2021 - 12:56:59: [adminmodx.amxx] DeathMsg Debug 8 -1
L 11/19/2021 - 12:57:01: [adminmodx.amxx] DeathMsg Debug 8 25
L 11/19/2021 - 12:57:01: [adminmodx.amxx] DeathMsg Debug 10 26
L 11/19/2021 - 12:57:03: [adminmodx.amxx] DeathMsg Debug 22 8
L 11/19/2021 - 12:57:05: [adminmodx.amxx] DeathMsg Debug 27 9
L 11/19/2021 - 12:57:10: [adminmodx.amxx] DeathMsg Debug 20 2
L 11/19/2021 - 12:57:10: [adminmodx.amxx] DeathMsg Debug 23 1
L 11/19/2021 - 12:57:10: [adminmodx.amxx] DeathMsg Debug 22 12
L 11/19/2021 - 12:57:12: [adminmodx.amxx] DeathMsg Debug 20 8
L 11/19/2021 - 12:57:12: [adminmodx.amxx] DeathMsg Debug 20 7
L 11/19/2021 - 12:57:12: [adminmodx.amxx] DeathMsg Debug 20 13
L 11/19/2021 - 12:57:12: [adminmodx.amxx] DeathMsg Debug 20 14
L 11/19/2021 - 12:57:13: [adminmodx.amxx] DeathMsg Debug 9 21
L 11/19/2021 - 12:57:13: [adminmodx.amxx] DeathMsg Debug 27 5
L 11/19/2021 - 12:57:18: [adminmodx.amxx] DeathMsg Debug 25 4
L 11/19/2021 - 12:57:18: [adminmodx.amxx] DeathMsg Debug 25 8
L 11/19/2021 - 12:57:18: [adminmodx.amxx] DeathMsg Debug 25 13
L 11/19/2021 - 12:57:20: [adminmodx.amxx] DeathMsg Debug 22 9
L 11/19/2021 - 12:57:21: [adminmodx.amxx] DeathMsg Debug 27 11
L 11/19/2021 - 12:57:21: [adminmodx.amxx] DeathMsg Debug 23 1
L 11/19/2021 - 12:57:21: [adminmodx.amxx] DeathMsg Debug 23 2
L 11/19/2021 - 12:57:21: [adminmodx.amxx] DeathMsg Debug 23 10
L 11/19/2021 - 12:57:24: [adminmodx.amxx] DeathMsg Debug 26 14
L 11/19/2021 - 12:57:29: [adminmodx.amxx] DeathMsg Debug 26 6
L 11/19/2021 - 12:57:29: [adminmodx.amxx] DeathMsg Debug 22 7
L 11/19/2021 - 12:57:29: [adminmodx.amxx] DeathMsg Debug 6 26
L 11/19/2021 - 12:571: [adminmodx.amxx] DeathMsg Debug 16 21
L 11/19/2021 - 12:571: [adminmodx.amxx] DeathMsg Debug 27 1
L 11/19/2021 - 12:572: [adminmodx.amxx] DeathMsg Debug 27 13
-X-

Last edited by Unzy; 11-20-2021 at 03:33. Reason: added txt file
Unzy is offline
JusTGo
Veteran Member
Join Date: Mar 2013
Old 11-20-2021 , 04:01   Re: Run time error 4: index out of bounds
Reply With Quote #9

This should fix it:

PHP Code:
public eDeath()
{
    new 
iKiller read_data)
    new 
iVictim read_data);
    
    if(
iVictim || iVictim get_maxplayers())
        return
    
    
g_buried[iVictim] = 0
    remove_task
((iVictim+1000))

You can also cache get_maxplayers() in a variable in plugin_init()

PHP Code:
new g_iMaxPlayers

public plugin_init()
{
    
g_iMaxPlayers get_maxplayers();
}


public 
eDeath()
{
    new 
iKiller read_data)
    new 
iVictim read_data);
    
    if(
iVictim || iVictim g_iMaxPlayers)
        return
    
    
g_buried[iVictim] = 0
    remove_task
((iVictim+1000))

__________________
JusTGo is offline
Unzy
Junior Member
Join Date: Apr 2017
Old 11-20-2021 , 04:46   Re: Run time error 4: index out of bounds
Reply With Quote #10

JusTGo, that seemed to have done the trick! Tysm!

Also a thx to Bugsy and fysics for looking into this and bringing it to the correct section.

Ive tossed some $ in, to even the raised counter, pls dont put sponsor under my name

thx you guys!

-X-

Well it seemed paypal took $2 lmao, dumb me, now its not even gg
__________________

Last edited by Unzy; 11-20-2021 at 04:48. Reason: paypal remark*
Unzy is offline
Reply


Thread Tools
Display Modes

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 21:54.


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