Raised This Month: $ Target: $400
 0% 

Index out of bounds


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
andrzN
Senior Member
Join Date: Jan 2010
Location: Bodø / Norway
Old 01-08-2013 , 12:20   Index out of bounds
Reply With Quote #1

Okey, so suddenly I got this error in my error log:

PHP Code:
L 01/08/2013 17:08:34: [AMXXRun time error 4index out of bounds 
L 01
/08/2013 17:08:34: [AMXX]    [0colorchat.inc::ColorChat (line 74)
L 01/08/2013 17:08:34: [AMXX]    [1Connect.sma::Print (line 78)
L 01/08/2013 17:08:34: [AMXX]    [2Connect.sma::client_disconnect (line 68
And here is the full code

PHP Code:
//                          _______________
//_________________________/ Plugin Info() \________________________________________
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/
//   AdminMenu.sma           Version 1.2           Updated: FEBRUARY/19/2012
//
//   Plugin:        Connection Messages
//   Author:         anderseN
//     Version:         1.0
//   
//   Publicity:     Private
//   Contact:         [email protected]
//     Website:         www.Gamepark.se
//
//____________________________________________________________________________________
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~/

#include <amxmodx>
#include <nvault>
#include <colorchat>

#define VAULT_NAME    "Connect"
#define VAULT_KEY    "NUM"

new const Prefix[] = "[GP]";

new 
gConnectVault

new name[33][32]
new 
authid[33][32]

public 
plugin_init() 
{
    
register_plugin("Connection Messages" "1.2" "anderseN");
    
    
gConnectVault nvault_open("ConnectVault")
    
    if(
gConnectVault == INVALID_HANDLE)
    
set_fail_state("nVault failed to open")
}

public 
plugin_end()
{
    
nvault_closegConnectVault );
}

public 
client_putinserver(id)
{
    static 
szTemp] , iConnections;
    
    
get_user_name(id,name[id],31)
    
get_user_authid(id,authid[id],31)

    
iConnections nvault_getgConnectVault authid[id] );
    
    
num_to_str( ++iConnections szTemp charsmaxszTemp ) );
    
nvault_setgConnectVault authid[id] , szTemp );
    
    Print(
0"%s ^01(%s)^03 has connected.^04 [Connections: %d]"name[id], authid[id], iConnections);
    
    return 
PLUGIN_HANDLED;


public 
client_disconnect(id)
{
    
get_user_name(id,name[id],31)
    
get_user_authid(id,authid[id],31)

    Print(
0"%s ^01(%s)^04 has disconnected."name[id], authid[id]);
    
    return 
PLUGIN_HANDLED;


Print(
id, const szMessage[], any:...) 

    static 
szBuffer[192]; 
    
vformat(szBuffercharsmax(szBuffer), szMessage3); 

    
ColorChat(idGREY"^04%s^03 %s"PrefixszBuffer); 

}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1044\\ f0\\ fs16 \n\\ par }
*/ 
What could be the problem? I have never seen this error before.
Attached Files
File Type: inc colorchat.inc (2.5 KB, 99 views)

Last edited by andrzN; 01-08-2013 at 12:22.
andrzN is offline
Send a message via MSN to andrzN
rx1983
Senior Member
Join Date: Jan 2009
Location: BRASIL
Old 01-08-2013 , 12:44   Re: Index out of bounds
Reply With Quote #2

no errors for me.
Code:
//AMXXPC compile.exe
// by the AMX Mod X Dev Team


//// cm.sma
// Header size:            584 bytes
// Code size:             3040 bytes
// Data size:            10336 bytes
// Stack/heap size:      16384 bytes; max. usage is unknown, due to recursion
// Total requirements:   30344 bytes
// Done.
__________________
rx1983 is offline
Send a message via MSN to rx1983
micapat
Veteran Member
Join Date: Feb 2010
Location: Nyuu, nyuu (France).
Old 01-08-2013 , 13:04   Re: Index out of bounds
Reply With Quote #3

Upload your colorchat.inc / .sma.
__________________

Last edited by micapat; 01-08-2013 at 13:04.
micapat is offline
AngeIII
Senior Member
Join Date: Sep 2007
Location: Latvia
Old 01-08-2013 , 13:10   Re: Index out of bounds
Reply With Quote #4

if you got this error constantly you can just add this:
PHP Code:
public client_disconnect(id

    
log_amx("ID:%d",id);
    
get_user_name(id,name[id],31
    
get_user_authid(id,authid[id],31
    
log_amx("Name: %s AUTH: %s",name[id],authid[id]);
    Print(
0"%s ^01(%s)^04 has disconnected."name[id], authid[id]); 
    
log_amx("%s ^01(%s)^04 has disconnected."name[id], authid[id]);  
    return 
PLUGIN_HANDLED

and in standart logs you will see the problem. i think problem is with formatting:
get_user_name(id,name[id],31)
get_user_authid(id,authid[id],31)
__________________
skype: pavle_ivanof
-=ThQ=-
PRIVATE SUPPORT = PAID SUPPORT
AngeIII is offline
Send a message via Skype™ to AngeIII
Neeeeeeeeeel.-
Some Guy Yellin'
Join Date: Jul 2010
Location: Argentina
Old 01-08-2013 , 21:04   Re: Index out of bounds
Reply With Quote #5

Quote:
Originally Posted by rx1983 View Post
no errors for me.
Code:
//AMXXPC compile.exe
// by the AMX Mod X Dev Team


//// cm.sma
// Header size:            584 bytes
// Code size:             3040 bytes
// Data size:            10336 bytes
// Stack/heap size:      16384 bytes; max. usage is unknown, due to recursion
// Total requirements:   30344 bytes
// Done.
He is talking about log error messages...
__________________
Neeeeeeeeeel.- is offline
Send a message via Skype™ to Neeeeeeeeeel.-
andrzN
Senior Member
Join Date: Jan 2010
Location: Bodø / Norway
Old 01-10-2013 , 21:48   Re: Index out of bounds
Reply With Quote #6

Quote:
Originally Posted by AngeIII View Post
if you got this error constantly you can just add this:
PHP Code:
public client_disconnect(id

    
log_amx("ID:%d",id);
    
get_user_name(id,name[id],31
    
get_user_authid(id,authid[id],31
    
log_amx("Name: %s AUTH: %s",name[id],authid[id]);
    Print(
0"%s ^01(%s)^04 has disconnected."name[id], authid[id]); 
    
log_amx("%s ^01(%s)^04 has disconnected."name[id], authid[id]);  
    return 
PLUGIN_HANDLED

and in standart logs you will see the problem. i think problem is with formatting:
get_user_name(id,name[id],31)
get_user_authid(id,authid[id],31)
The error doesn't come constantly, it comes just now and then, everything from 5min to 2 hours apart. So thats the weird part, why would it just give this error some times when this acton is used like all the time (each time a player disconnects).

But thanks, I will try that and come back with the results of the log.

Last edited by andrzN; 01-10-2013 at 21:55.
andrzN is offline
Send a message via MSN to andrzN
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-10-2013 , 22:31   Re: Index out of bounds
Reply With Quote #7

Looks to me like you should just remove the arrays entirely since they are never used other than immediately after they are populated.
__________________
fysiks is offline
andrzN
Senior Member
Join Date: Jan 2010
Location: Bodø / Norway
Old 01-11-2013 , 03:17   Re: Index out of bounds
Reply With Quote #8

Quote:
Originally Posted by fysiks View Post
Looks to me like you should just remove the arrays entirely since they are never used other than immediately after they are populated.
If I remove get_user_name and get_user_authid in client_disconnect (if thats what you meant) then how will I get the disconnected players name and steamid?
__________________
Owner of Gamepark.se - Scandinavian Community

#1 - HideNSeek [Easyblocks] IP: eb.gamepark.se
#2 - HideNSeek [Noblocks] IP: nb.gamepark.se
#3 - HideNSeek [HNS Training Blocks] IP: training.gamepark.se
andrzN is offline
Send a message via MSN to andrzN
AngeIII
Senior Member
Join Date: Sep 2007
Location: Latvia
Old 01-11-2013 , 09:32   Re: Index out of bounds
Reply With Quote #9

cache it when user connecting. (steamid doesn't change on connected-disconnected interval ...)

and cache name also if user is changing name.
__________________
skype: pavle_ivanof
-=ThQ=-
PRIVATE SUPPORT = PAID SUPPORT

Last edited by AngeIII; 01-11-2013 at 09:32.
AngeIII is offline
Send a message via Skype™ to AngeIII
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-11-2013 , 14:05   Re: Index out of bounds
Reply With Quote #10

Quote:
Originally Posted by andrzN View Post
If I remove get_user_name and get_user_authid in client_disconnect (if thats what you meant) then how will I get the disconnected players name and steamid?
I didn't say remove those functions. I said to remove the array of strings and just use a local string for name and Steam ID.
__________________
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 13:29.


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