Raised This Month: $51 Target: $400
 12% 

Invalid index with array checked by timer


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
JLmelenchon
Senior Member
Join Date: Mar 2019
Old 11-24-2021 , 16:33   Invalid index with array checked by timer
Reply With Quote #1

How to fix this error ? Wrong section, if you can move in scripting please.

Code:
 
L 11/21/2021 - 17:35:50: [SM] Exception reported: Invalid index 2 (count: 2)
L 11/21/2021 - 17:35:50: [SM] Blaming: autorep_matchleft.smx
L 11/21/2021 - 17:35:50: [SM] Call stack trace:
L 11/21/2021 - 17:35:50: [SM]   [0] GetArrayCell
L 11/21/2021 - 17:35:50: [SM]   [1] Line 109, plugin.sp::Timer_Checker
L 11/21/2021 - 17:38:44: [SM] Exception reported: Invalid index 1 (count: 1)
L 11/21/2021 - 17:38:44: [SM] Blaming: autorep_matchleft.smx
L 11/21/2021 - 17:38:44: [SM] Call stack trace:
L 11/21/2021 - 17:38:44: [SM]   [0] GetArrayCell
L 11/21/2021 - 17:38:44: [SM]   [1] Line 109, plugin.sp::Timer_Checker
L 11/21/2021 - 17:39:57: [SM] Exception reported: Invalid index 1 (count: 1)
L 11/21/2021 - 17:39:57: [SM] Blaming: autorep_matchleft.smx
L 11/21/2021 - 17:39:57: [SM] Call stack trace:
L 11/21/2021 - 17:39:57: [SM]   [0] GetArrayCell
L 11/21/2021 - 17:39:57: [SM]   [1] Line 109, plugin.sp::Timer_Checker

Code:
public Action Timer_Checker(Handle timer)
{
	if(!cv_enable.BoolValue)
		return;
		
	int size = GetArraySize(array_players_time);
	
	if (size == 0) 
	    return;
	
	if (L4D_IsMissionFinalMap() == true)
	    return; 
	
	char steamid[64], sName[128];
	
	for (int i = 0; i < size; i++)
	{
		if(GetTime() > GetArrayCell(array_players_time, i)+cv_time.IntValue)
		{
			GetArrayString(array_players_ids, i, steamid, sizeof(steamid));
			GetArrayString(array_players_name, i, sName, sizeof(sName));
			
			CPrintToChatAll("%t", "leave_match", sName);
			LogToFile(path, "%s (%s) abandoned the match", sName, steamid);
			

			RemoveFromArray(array_players_time, i);
			RemoveFromArray(array_players_ids, i);
			RemoveFromArray(array_players_name, i);
		}
	}
}

Last edited by JLmelenchon; 11-24-2021 at 16:36.
JLmelenchon is offline
sorallll
Senior Member
Join Date: Oct 2018
Old 11-24-2021 , 20:36   Re: Invalid index with array checked by timer
Reply With Quote #2

PHP Code:
public Action Timer_Checker(Handle timer)
{
    if(!
cv_enable.BoolValue)
        return;
        
    
int size GetArraySize(array_players_time);
    
    if (
size == 0
        return;
    
    if (
L4D_IsMissionFinalMap() == true)
        return; 
    
    
char steamid[64], sName[128];
    
    
int i ;
        while (
size)
    {
        if(
GetTime() > GetArrayCell(array_players_timei)+cv_time.IntValue)
        {
            
GetArrayString(array_players_idsisteamidsizeof(steamid));
            
GetArrayString(array_players_nameisNamesizeof(sName));
            
            
CPrintToChatAll("%t""leave_match"sName);
            
LogToFile(path"%s (%s) abandoned the match"sNamesteamid);
            

            
RemoveFromArray(array_players_timei);
            
RemoveFromArray(array_players_idsi);
            
RemoveFromArray(array_players_namei);
                        
size--;
        }else
                       
i++;
    }

sorallll is offline
micapat
Veteran Member
Join Date: Feb 2010
Location: Nyuu, nyuu (France).
Old 11-25-2021 , 17:40   Re: Invalid index with array checked by timer
Reply With Quote #3

Dirty but should work:

PHP Code:
public Action Timer_Checker(Handle timer)
{
    if(!
cv_enable.BoolValue)
        return;
        
    
int size GetArraySize(array_players_time);
    
    if (
size == 0
        return;
    
    if (
L4D_IsMissionFinalMap() == true)
        return; 
    
    
char steamid[64], sName[128];
    
    for (
int i 0sizei++)
    {
        if(
GetTime() > GetArrayCell(array_players_timei)+cv_time.IntValue)
        {
            
GetArrayString(array_players_idsisteamidsizeof(steamid));
            
GetArrayString(array_players_nameisNamesizeof(sName));
            
            
CPrintToChatAll("%t""leave_match"sName);
            
LogToFile(path"%s (%s) abandoned the match"sNamesteamid);
            
            
RemoveFromArray(array_players_timei);
            
RemoveFromArray(array_players_idsi);
            
RemoveFromArray(array_players_namei);

            
size--:
            
i--;
        }
    }

__________________
micapat is offline
JLmelenchon
Senior Member
Join Date: Mar 2019
Old 11-26-2021 , 14:04   Re: Invalid index with array checked by timer
Reply With Quote #4

Used code from second post, no more errors nice thank you.
JLmelenchon 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 16:16.


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