Found some errors in server.log
#1

While running the new lumberjack job i scripted, I found the following error

[17:25:08] [debug] Run time error 4: "Array index out of bounds"
[17:25:08] [debug] Accessing element at index 10 past array upper bound 9

- The server sometimes lag because of this error ( im not sure ). I did not find any other ingame bugs because of this error.



PHP Code:
public OnGameModeInit()
{
    
// Lumberjack
    
loadtrees();
       return 
1;

PHP Code:
#define MAX_TREES 10
enum treeinfo
{
    
tID,
    
FloattX,
    
FloattY,
    
FloattZ,    
    
tHealth,
    
bool:tStatus,
    
bool:woodReady,
    
tObject,
    
Text3D:tLabel,
    
tWood,
    
Text3D:woodLabel,
    
tTimer
}
new 
treeData[MAX_TREES][treeinfo]; 
- Main functions i'm using:
PHP Code:
forward loadtrees();
public 
loadtrees()
{
    print(
"Loading trees");
    for(new 
0<= MAX_TREESg++)
    {
        new 
LoadString[256];
        
format(LoadStringsizeof(LoadString), "/Trees/%d.dini.save"g);
        if(
dini_Exists(LoadString))
        {
            
treeData[g][tID] = g;
            
treeData[g][tX] = dini_Float(LoadString,"tX");
            
treeData[g][tY] = dini_Float(LoadString,"tY");
            
treeData[g][tZ] = dini_Float(LoadString,"tZ");
            
treeData[g][tObject] = CreateObject(617treeData[g][tX], treeData[g][tY], treeData[g][tZ], 0.00000.00000.0000); // tree
            
treeData[g][woodReady] = false;
            
treeData[g][tHealth] = 100;
                new 
string2[80];
            
format(string2sizeof(string2), "{ffff00}Tree\n/cuttree\nHealth: %i"treeData[g][tHealth]);
                
treeData[g][tLabel] = Create3DTextLabel(string2COLOR_YELLOWtreeData[g][tX], treeData[g][tY], treeData[g][tZ] + (0.2  3.1117), 7.500);
                
treeData[g][tStatus] = true;
        }
    }
    return 
1;
}
GetNearestTree(playerid)
{
    new 
treeid = -1;
  
      new 
k=0;
    for(new 
i=0i<=MAX_TREES;i++)
    {
        if(
k==0)
        {
            if(
IsPlayerInRangeOfPoint(playerid2.0treeData[i][tX], treeData[i][tY], treeData[i][tZ] + 3.1117 ))
            {
                
treeData[i][tID] = i;
                
k++;
                
treeid i;
            }
        }
        else break;
    }
    return 
treeid;
}
forward destroytrees();
public 
destroytrees()
{
    print(
"unloading trees");
    for(new 
0<= MAX_TREESg++)
    {
        new 
UnloadString[256];
            
format(UnloadStringsizeof(UnloadString), "/Trees/%d.dini.save"g);
            if(
dini_Exists(UnloadString))
        {
            if(
treeData[g][tStatus])
            {
                
Delete3DTextLabeltreeData[g][tLabel] );
                
DestroyObjecttreeData[g][tObject] );
            }
            else
            {
                if(
treeData[g][woodReady])
                {
                    
Delete3DTextLabeltreeData[g][woodLabel] );
                    
DestroyObjecttreeData[g][tWood] );
                }
            }
        }
    }
}
stock freeTreeID()
{
        new 
Trees[64];
     for(new 
0<= MAX_TREESg++)
    {
        
format(Treessizeof(Trees), "/Trees/%d.dini.save"g);
        if(!
dini_Exists(Trees)) return g;
    }
    return 
1;

Thanks for helping
Reply
#2

Thanks so much. It has been fixed.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)