LoadMoveDoors and LoadDynamicCCTV error (+rep)
#1

Hello i have a error with LoadMoveDoors and LoadDynamicCCTV, here are is my server log and the codes,

Код:
[02:27:39] [debug] Run time error 4: "Array index out of bounds"
[02:27:39] [debug]  Accessing element at index 1779 past array upper bound 1199
[02:27:39] [debug] AMX backtrace:
[02:27:39] [debug] #0 000fccc4 in public LoadMoveDoors () at C:\Users\Nick\Documents\SAMP S\INGENIOUS ROLEPLAY\gamemodes\igrp.pwn:16593
[02:27:39] [debug] Run time error 4: "Array index out of bounds"
[02:27:39] [debug]  Accessing element at index 1780 past array upper bound 1199
[02:27:39] [debug] AMX backtrace:
[02:27:39] [debug] #0 00100624 in public LoadDynamicCCTV () at C:\Users\Nick\Documents\SAMP S\INGENIOUS ROLEPLAY\gamemodes\igrp.pwn:16799
Код:
public LoadDynamicCCTV()
{
    new rows, fields;
 new total = 0;
 new object, id, faction, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, interior, world, name[256];
    cache_get_data(rows, fields);
    if(rows)
    {
  while(total < rows)
  {
   id = cache_get_row_int(total, 0);
   faction = cache_get_row_int(total, 1);
   x = cache_get_row_float(total, 2);
   y = cache_get_row_float(total, 3);
   z = cache_get_row_float(total, 4);
   rx = cache_get_row_float(total, 5);
   ry = cache_get_row_float(total, 6);
   rz = cache_get_row_float(total, 7);
   interior = cache_get_row_int(total, 8);
   world = cache_get_row_int(total, 9);
   cache_get_row(total, 10, name, dbHandle, 128);
   object = CreateDynamicObject(1886, x, y, z, rx, ry, rz, -1, -1, -1, 200.0);
   CCTVInfo[object][tvID] = id;
   CCTVInfo[object][tvFaction] = faction;
   CCTVInfo[object][tvPosX] = x;
   CCTVInfo[object][tvPosY] = y;
   CCTVInfo[object][tvPosZ] = z;
   CCTVInfo[object][tvPosRX] = rx;
   CCTVInfo[object][tvPosRY] = ry;
   CCTVInfo[object][tvPosRZ] = rz;
   CCTVInfo[object][tvInterior] = interior;
   CCTVInfo[object][tvVirtualWorld] = world;
   format(CCTVInfo[object][tvName], 256, "%s", name);
   CCTVInfo[object][tvObjectOn] = 1;
   CCTVInfo[object][tvObject] = object;
   total++;
  }
    }
 format(msg,sizeof(msg), "Loaded %d dynamic CCTV's from MySQL.", total);
 printf(msg);
    return 1;
}
Код:
public LoadMoveDoors()
{
    new rows, fields;
 new total = 0;
 new object, id, model, faction, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, Float:openspeed, Float:movex, Float:movey, Float:movez, interior, world, name[256];
    cache_get_data(rows, fields);
    if(rows)
    {
  while(total < rows)
  {
   id = cache_get_row_int(total, 0),
   model = cache_get_row_int(total, 1),
   faction = cache_get_row_int(total, 2),
   x = cache_get_row_float(total, 3),
   y = cache_get_row_float(total, 4),
   z = cache_get_row_float(total, 5),
   rx = cache_get_row_float(total, 6),
   ry = cache_get_row_float(total, 7),
   rz = cache_get_row_float(total, 8),
   interior = cache_get_row_int(total, 8),
   world = cache_get_row_int(total, 10),
   cache_get_row(total, 11, name, dbHandle, 128),
   openspeed = cache_get_row_float(total, 12),
   movex = cache_get_row_float(total, 13),
   movey = cache_get_row_float(total, 14),
   movez = cache_get_row_float(total, 15);
   object = CreateDynamicObject(model, x, y, z, rx, ry, rz, world, -1, -1, 200.0);
   Doors[object][doorID] = id;
   Doors[object][doorModel] = model;
   Doors[object][doorFaction] = faction;
   Doors[object][doorPosX] = x;
   Doors[object][doorPosY] = y;
   Doors[object][doorPosZ] = z;
   Doors[object][doorPosRX] = rx;
   Doors[object][doorPosRY] = ry;
   Doors[object][doorPosRZ] = rz;
   Doors[object][doorOpenSpeed] = openspeed;
   Doors[object][doorMoveX] = movex;
   Doors[object][doorMoveY] = movey;
   Doors[object][doorMoveZ] = movez;
   Doors[object][doorInterior] = interior;
   Doors[object][doorVirtualWorld] = world;
   format(Doors[object][doorName], 256, "%s", name);
   Doors[object][doorObjectOn] = 1;
   Doors[object][doorObject] = object;
   total++;
  }
    }
 format(msg,sizeof(msg), "Loaded %d dynamic movable doors from MySQL.", total);
 printf(msg);
    return 1;
}
Reply
#2

Bump.
Reply
#3

Код:
Run time error 4: "Array index out of bounds"
The array size is not enough
You refer to a non-existent index.

Example:
PHP код:
new array[1000]; // Your current array
// and
array[2000] = id// But save in a larger index than announced 
Reply
#4

Quote:
Originally Posted by Logofero
Посмотреть сообщение
Код:
Run time error 4: "Array index out of bounds"
The array size is not enough
You refer to a non-existent index.

Example:
PHP код:
new array[1000]; // Your current array
// and
array[2000] = id// But save in a larger index than announced 
I dont have any new arrays.
Reply
#5

Quote:
Originally Posted by Matical
Посмотреть сообщение
I dont have any new arrays.
This is just an example. I showed how you can refer to a cell array on the compiler encountered an error
Reply
#6

Quote:
Originally Posted by Logofero
Посмотреть сообщение
This is just an example. I showed how you can refer to a cell array on the compiler encountered an error
So i should add a new array you're saying?
Reply
#7

Quote:
Originally Posted by Matical
Посмотреть сообщение
So i should add a new array you're saying?
Up array index.

Do you have an array of:
PHP код:
// Before
new Doors[1000][?];
// After
new Doors[2000][?]; // <- Up index of 1000 to 2000 
Reply
#8

bump.
Reply
#9

bump.
Reply
#10

Optimization and fix:
PHP код:
enum MOVEABLE_DOORS
{
    
doorID,
    
doorModel,
    
doorObject,
    
doorName[256],
    
doorInterior,
    
doorVirtualWorld,
    
doorFaction,
    
doorOpened,
    
Float:doorPosX,
    
Float:doorPosY,
    
Float:doorPosZ,
    
Float:doorPosRX,
    
Float:doorPosRY,
    
Float:doorPosRZ,
    
Float:doorOpenSpeed,
    
Float:doorMoveX,
    
Float:doorMoveY,
    
Float:doorMoveZ,
    
doorObjectOn
}
new 
Doors[MAX_OBJECTS][MOVEABLE_DOORS];
public 
LoadDynamicCCTV()
{
    new 
        
rows
        
fields,
        
total 0,
        
object,
        
world,
        
Float:xFloat:yFloat:z
        
Float:rxFloat:ryFloat:rz
    
;    
    
cache_get_data(rowsfields);
    if(
rows) {
        while(
total rows) {      
           
cache_get_row_float(total2);
           
cache_get_row_float(total3);
           
cache_get_row_float(total4);
           
rx cache_get_row_float(total5);
           
ry cache_get_row_float(total6);
           
rz cache_get_row_float(total7);
           
world cache_get_row_int(total9);  
    
           
object CreateDynamicObject(1886xyzrxryrz, -1, -1, -1200.0);
           
CCTVInfo[object][tvPosX] = x;
           
CCTVInfo[object][tvPosY] = y;
           
CCTVInfo[object][tvPosZ] = z;
           
CCTVInfo[object][tvPosRX] = rx;
           
CCTVInfo[object][tvPosRY] = ry;
           
CCTVInfo[object][tvPosRZ] = rz;
           
CCTVInfo[object][tvVirtualWorld] = world;
           
CCTVInfo[object][tvID] = cache_get_row_int(total0);
           
CCTVInfo[object][tvFaction] = cache_get_row_int(total1);
           
CCTVInfo[object][tvInterior] = cache_get_row_int(total8);             
           
cache_get_row(total10CCTVInfo[object][tvName], dbHandle256);
           
CCTVInfo[object][tvObjectOn] = 1;
           
CCTVInfo[object][tvObject] = object;
           
total++;
        }
    }
    
format(msg,sizeof(msg), "Loaded %d dynamic CCTV's from MySQL."total);
    
printf(msg);
    return 
1;
}
public 
LoadMoveDoors()
{
    new 
        
rows
        
fields,
        
total 0,
        
object,
        
world,
        
Float:xFloat:yFloat:z
        
Float:rxFloat:ryFloat:rz
    
;
    
cache_get_data(rowsfields);
    if(
rows) {
        while(
total rows) {    
           
cache_get_row_float(total3);
           
cache_get_row_float(total4);
           
cache_get_row_float(total5);
           
rx cache_get_row_float(total6);
           
ry cache_get_row_float(total7);
           
rz cache_get_row_float(total8);
           
world cache_get_row_int(total10);
      
           
object CreateDynamicObject(modelxyzrxryrzworld, -1, -1200.0);
           
Doors[object][doorPosX] = x;
           
Doors[object][doorPosY] = y;
           
Doors[object][doorPosZ] = z;
           
Doors[object][doorPosRX] = rx;
           
Doors[object][doorPosRY] = ry;
           
Doors[object][doorPosRZ] = rz;
           
Doors[object][doorVirtualWorld] = world;
           
Doors[object][doorID] = cache_get_row_int(total0);
           
Doors[object][doorModel] = cache_get_row_int(total1);
           
Doors[object][doorFaction] = cache_get_row_int(total2);
           
Doors[object][doorPosX] = cache_get_row_float(total3);
           
Doors[object][doorPosY] = cache_get_row_float(total4);
           
Doors[object][doorPosZ] = cache_get_row_float(total5);
           
Doors[object][doorPosRX] = cache_get_row_float(total6);
           
Doors[object][doorPosRY] = cache_get_row_float(total7);
           
Doors[object][doorPosRZ] = cache_get_row_float(total8);
           
Doors[object][doorInterior] = cache_get_row_int(total9); // Why ID 8? Fixed.       
           
cache_get_row(total11Doors[object][doorName], dbHandle256),
           
Doors[object][doorOpenSpeed] = cache_get_row_float(total12);
           
Doors[object][doorMoveX] = cache_get_row_float(total13);
           
Doors[object][doorMoveY] = cache_get_row_float(total14);
           
Doors[object][doorMoveZ] = cache_get_row_float(total15);
           
Doors[object][doorObjectOn] = 1;
           
Doors[object][doorObject] = object;
           
total++;
        }
     }
     
format(msg,sizeof(msg), "Loaded %d dynamic movable doors from MySQL."total);
     
printf(msg);
     return 
1;

Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)