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
lantz69
AMX Mod X Beta Tester
Join Date: Mar 2004
Location: Sweden, Skåne
Old 10-19-2006 , 14:23   Run time error 4: index out of bounds
Reply With Quote #1

This is from the amxbans plugin

The error happens when the server has 32 players
It only happens on a dod server
I have a cstrike myself server and can not trigger that error

Error message:
Run time error 4: index out of bounds

The error happens in this function
Code:
public client_connect(id)
{
 g_lastCustom[id][0] = '^0'
 g_inCustomReason[id] = 0
 g_player_flagged[id] = false // This is the line that triggers the error
 g_being_banned[id] = false
}
This is how it is declared
Code:
 
new bool:g_player_flagged[33]
Can anyone see what could be wrong?
Maybe change false to 0 instead might help.

// LAntz69
__________________
Using: Amxmodx 1.8.1.xxxx, cstrike
http://www.vanilla.se/
lantz69 is offline
Nostrodamous
BANNED
Join Date: Oct 2006
Old 10-19-2006 , 16:10   Re: Run time error 4: index out of bounds
Reply With Quote #2

i would try setting the index to [32] instead . cells start at 0 so your actaully declaring 34 . Just an idea . also you migt wanna see how many players DOD can hold on one server. like sounter strike source has 64 man servers now .
Nostrodamous is offline
lantz69
AMX Mod X Beta Tester
Join Date: Mar 2004
Location: Sweden, Skåne
Old 10-19-2006 , 16:41   Re: Run time error 4: index out of bounds
Reply With Quote #3

I had it like that before like i think it should be
new bool:g_player_flagged[32]

But changed it to 33 just to try if that fixed the error.
And the DOD server only has 32 as the admin who get the error said so
And I also saw the server in HLSW so I believe him.
__________________
Using: Amxmodx 1.8.1.xxxx, cstrike
http://www.vanilla.se/
lantz69 is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 10-19-2006 , 17:56   Re: Run time error 4: index out of bounds
Reply With Quote #4

Quote:
Originally Posted by Nostrodamous View Post
i would try setting the index to [32] instead . cells start at 0 so your actaully declaring 34 . Just an idea . also you migt wanna see how many players DOD can hold on one server. like sounter strike source has 64 man servers now .
You need to define the array size with 33 when dealing with players. You will get an index out of bound when you try to use 32 if you defined the array size with 32. Since index 0 will be the server and Players will be 1-32.

So ArraySize - 1. So your useable indexes will be 0 through (ArraySize - 1). The script below will prove too you that you will get the index out of bound if you do that.

Code:
#include <amxmodx> new OverFlow[32] = {1, ...}; public plugin_init() {     for(new i = 0; i <= 32; i++)     {         server_print("%i: %i", i, OverFlow[i]);     } }


@Lantz69

If that person who using 32 player server and using your beta release from this link http://amxbans.net/forums/viewtopic.php?t=521 . I just looked at your global_vars.inl and you have new g_player_flagged[32]. So changing it too 33 should fix it.
__________________
No private support via Instant Message
GunGame:SM Released

Last edited by teame06; 10-19-2006 at 19:08.
teame06 is offline
Send a message via AIM to teame06
lantz69
AMX Mod X Beta Tester
Join Date: Mar 2004
Location: Sweden, Skåne
Old 10-20-2006 , 02:43   Re: Run time error 4: index out of bounds
Reply With Quote #5

Quote:
Originally Posted by teame06 View Post
@Lantz69

If that person who using 32 player server and using your beta release from this link http://amxbans.net/forums/viewtopic.php?t=521 . I just looked at your global_vars.inl and you have new g_player_flagged[32]. So changing it too 33 should fix it.
I changed that and sent that to the admin that had the problem and still he gets the error.
So that is really the reason I'm posting here as I'm clueless now

MAybe you saw above that I changed the code from the beta release
new g_player_flagged[32] = false
to
new bool:g_player_flagged[33]

I was pretty sure that was the fix, but he stills get the error :S

Could it be something about that he is using DOD ?
__________________
Using: Amxmodx 1.8.1.xxxx, cstrike
http://www.vanilla.se/

Last edited by lantz69; 10-20-2006 at 02:50.
lantz69 is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 10-20-2006 , 03:30   Re: Run time error 4: index out of bounds
Reply With Quote #6

I would do some more logging. To see how far out of range it going. At the very top of the list in client_connect.

Code:
    if(id < 0 || id > 32)     {         log_amx("[AMXBANS] Overflow %i", id);     }
__________________
No private support via Instant Message
GunGame:SM Released

Last edited by teame06; 10-20-2006 at 03:59.
teame06 is offline
Send a message via AIM to teame06
lantz69
AMX Mod X Beta Tester
Join Date: Mar 2004
Location: Sweden, Skåne
Old 10-20-2006 , 04:18   Re: Run time error 4: index out of bounds
Reply With Quote #7

Thx gonna try that, but I assumed client_connect could not get invalid id's

Then maybe only allow valid id's
Code:
 
public client_connect(id)
{
 if(id > 0 || id < 32)
 {
  g_lastCustom[id][0] = '^0'
  g_inCustomReason[id] = 0
  g_player_flagged[id] = false
  g_being_banned[id] = false
 }
 
}
__________________
Using: Amxmodx 1.8.1.xxxx, cstrike
http://www.vanilla.se/
lantz69 is offline
Greenberet
AMX Mod X Beta Tester
Join Date: Apr 2004
Location: Vienna
Old 10-20-2006 , 04:30   Re: Run time error 4: index out of bounds
Reply With Quote #8

use client_putinserver and check is_user_connected
Greenberet is offline
Send a message via ICQ to Greenberet Send a message via MSN to Greenberet
lantz69
AMX Mod X Beta Tester
Join Date: Mar 2004
Location: Sweden, Skåne
Old 10-20-2006 , 04:37   Re: Run time error 4: index out of bounds
Reply With Quote #9

Yeah I was thinking of changing it to client_putinserver, but dont you have to choose a team for that?
is_user_connected is also a good thing to check

maybe something like this
Code:
public client_putinserver(id)
{
 if( (id > 0 || id < 32) && is_user_connected(id) )
 {
  g_lastCustom[id][0] = '^0'
  g_inCustomReason[id] = 0
  g_player_flagged[id] = false
  g_being_banned[id] = false
 }
 
}
Thx all for helping out.
__________________
Using: Amxmodx 1.8.1.xxxx, cstrike
http://www.vanilla.se/

Last edited by lantz69; 10-20-2006 at 04:40.
lantz69 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 09:01.


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