[debug] Run time error 4: "Array index out of bounds"
#1

PHP код:
[04:05:52] [debugRun time error 4"Array index out of bounds"
[04:05:52] [debug]  Accessing element at index 65535 past array upper bound 1999
[04:05:52] [debugAMX backtrace:
[
04:05:52] [debug#0 00113700 in LoadVehicles (storeid=9) at C:\Users\-\Desktop\voor reboot\unnamed roleplay\gamemodes\DL-RP.pwn:21373
[04:05:52] [debug#1 001fc2bc in InitVehicles () at C:\Users\-\Desktop\voor reboot\unnamed roleplay\gamemodes\DL-RP.pwn:28401
[04:05:52] [debug#2 000174b4 in public S@@_OnGameModeInit () at C:\Users\-\Desktop\voor reboot\unnamed roleplay\gamemodes\DL-RP.pwn:1774
[04:05:52] [debug#3 00006dc8 in public Itter_OnGameModeInit () at C:\Users\-\Desktop\voor reboot\unnamed roleplay\pawno\include\YSI\y_hooks/impl.inc:484
[04:05:52] [debug#4 native CallLocalFunction () [004743b0] from samp-server.exe
[04:05:52] [debug#5 00001dc4 in public ScriptInit_OnGameModeInit () at C:\Users\-\Desktop\voor reboot\unnamed roleplay\pawno\include\YSI\y_iterate.inc:791
[04:05:52] [debug#6 000009e4 in Debug_Print0 () at C:\Users\-\Desktop\voor reboot\unnamed roleplay\pawno\include\YSI\internal\..\y_scriptinit.inc:171
[04:05:52] [debug#7 native CallLocalFunction () [004743b0] from samp-server.exe
[04:05:52] [debug#8 000003b8 in Debug_Print0 () at C:\Users\-\Desktop\voor reboot\unnamed roleplay\pawno\include\zcmd.inc:68
[04:05:52]  
[
04:05:52]  
[
04:05:52] -----------------------GAMEMODE LOADING-----------------------
[
04:05:52] -----------------------Script has been loaded --------------------
[
04:05:52] -----------------------GAMEMODE LOADED------------------------
[
04:05:52]  
[
04:05:52]  
[
04:05:52Number of vehicle models2
[04:06:11] [connection192.168.178.20:58943 requests connection cookie.
[
04:06:12] [connectionincoming connection192.168.178.20:58943 id0
[04:06:12] [debugRun time error 20"Invalid index parameter (bad entry point)" 
21373
PHP код:
VehicleBattery[Vehicles[storeid][DLID]] = 100
28401
PHP код:
stock InitVehicles()
{
    for(new 
idid MAX_SERVERVEHICLESid++) // Goes through all the slots, looking for the data
    
{
         
LoadVehicles(id);
    } <<<< 
28401
    
return 1;

1774
PHP код:
InitBusinesses(); 
I don't understand the problem anymore, Its not loading the textdraws Objects and more....
Reply
#2

shoudn't this be:
pawn Код:
VehicleBattery[Vehicles[storeid][DLID]] = 100;
this?
pawn Код:
VehicleBattery[Vehicles[storeid]][DLID] = 100;
and show me loadvehicles function.
Reply
#3

Quote:
Originally Posted by Eth
Посмотреть сообщение
shoudn't this be:
pawn Код:
VehicleBattery[Vehicles[storeid][DLID]] = 100;
this?
pawn Код:
VehicleBattery[Vehicles[storeid]][DLID] = 100;
and show me loadvehicles function.
PHP код:
LoadVehicles(storeid)
{
    new 
Data[150],Field[258],idx;
    
mysql_queryS("SELECT * FROM `Vehicles` WHERE `VehicleID` = %d",storeid);
    
mysql_store_result();
    if(
mysql_num_rows() == 1){
        
mysql_fetch_rowEx(Data);
        
Field strtukDataidx'|' );
        for(new 
020s++)
        {
            switch(
s)
            {
                case 
0Vehicles[storeid][VehicleID] = strval(Field);
                case 
1Vehicles[storeid][ModelID] = strval(Field);
                case 
2Vehicles[storeid][Color1] = strval(Field);
                case 
3Vehicles[storeid][Color2] = strval(Field);
                case 
4Vehicles[storeid][VPosX] = floatstr(Field);
                case 
5Vehicles[storeid][VPosY] = floatstr(Field);
                case 
6Vehicles[storeid][VPosZ] = floatstr(Field);
                case 
7Vehicles[storeid][VPosAngle] = floatstr(Field);
                case 
8Vehicles[storeid][LockStatus] = strval(Field);
                case 
9Vehicles[storeid][FactionCar] = strval(Field);
                case 
10strmid(Vehicles[storeid][VOwner],Field,0,strlen(Field),255);
                case 
11strmid(Vehicles[storeid][VPlate],Field,0,strlen(Field),255);
                case 
12Vehicles[storeid][SpeedoColor] = strval(Field);
                case 
13Vehicles[storeid][FlashAble] = strval(Field);
                case 
14Vehicles[storeid][RDuty] = strval(Field);
                case 
15Vehicles[storeid][VehicleWorld] = strval(Field);
                case 
16Vehicles[storeid][VehicleInteriorID] = strval(Field);
                case 
17Vehicles[storeid][Impounded] = strval(Field);
                case 
18Vehicles[storeid][SavedVehicle] = strval(Field);
            }
            
Field strtukDataidx'|' );
        }
        if(
Vehicles[storeid][JustChangedColor] == 1)
        {
            
Vehicles[storeid][DLID] = CreateVehicle(Vehicles[storeid][ModelID], Vehicles[storeid][VPosX], Vehicles[storeid][VPosY], Vehicles[storeid][VPosZ], Vehicles[storeid][VPosAngle], Vehicles[storeid][Color1], Vehicles[storeid][Color2], -1);
             
SetVehicleVirtualWorld(Vehicles[storeid][DLID], 0);
            
LinkVehicleToInterior(Vehicles[storeid][DLID], 0);
            
Vehicles[storeid][JustChangedColor] = 0;
            new 
engine,lights,alarm,doors,bonnet,boot,objective;
            
GetVehicleParamsEx(Vehicles[storeid][DLID],engine,lights,alarm,doors,bonnet,boot,objective);
            
SetVehicleParamsEx(Vehicles[storeid][DLID],VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
        }
        else
        {
              
Vehicles[storeid][DLID] = CreateVehicle(Vehicles[storeid][ModelID], Vehicles[storeid][VPosX], Vehicles[storeid][VPosY], Vehicles[storeid][VPosZ], Vehicles[storeid][VPosAngle], Vehicles[storeid][Color1], Vehicles[storeid][Color2], -1);
              
SetVehicleVirtualWorld(Vehicles[storeid][DLID], Vehicles[storeid][VehicleWorld]);
            
LinkVehicleToInterior(Vehicles[storeid][DLID], Vehicles[storeid][VehicleInteriorID]);
            
VehicleFuel[Vehicles[storeid][DLID]] = 100;
            
VehicleBattery[Vehicles[storeid][DLID]] = 100;
        }
        
SetVehicleNumberPlate(Vehicles[storeid][DLID], Vehicles[storeid][VPlate]);
        
Vehicles[Vehicles[storeid][DLID]][SavedVehicle] = 1;
        
        if(
Vehicles[storeid][JustChanged] == 1)
        {
            for(new 
0MAX_PLAYERSi++)
            {
                if(
Player[i][JustChangedCar] == Vehicles[storeid][DLID])
                {
                    
PutPlayerInVehicle(iVehicles[storeid][DLID], 0);
                    
Vehicles[storeid][JustChanged] = 0;
                    
Player[i][JustChangedCar] = -1;
                }
            }
        }
        
printf("[System] Vehicle Slot: %d, Vehicle /dl: %d, has been successfully spawned!"storeidVehicles[storeid][DLID]);
        
ServerVehicle[Vehicles[storeid][DLID]] = 1;
        
SpawnedVehicles++;
        
mysql_free_result();
    }
}
LoadOwnedVehicle(storeidplayerid)
{
    new 
Data[150],Field[258],idx;
    
mysql_queryS("SELECT * FROM `OwnedVehicles` WHERE `vStoreID` = %d",storeid);
    
mysql_store_result();
    if(
mysql_num_rows() == 1){
        
mysql_fetch_rowEx(Data);
        
Field strtukDataidx'|' );
        for(new 
020s++)
        {
            switch(
s)
            {
                case 
0OwnedVehicles[storeid][vStoreID] = strval(Field);
                case 
1OwnedVehicles[storeid][vModelID] = strval(Field);
                case 
2OwnedVehicles[storeid][vColor1] = strval(Field);
                case 
3OwnedVehicles[storeid][vColor2] = strval(Field);
                case 
4OwnedVehicles[storeid][vPositionX] = floatstr(Field);
                case 
5OwnedVehicles[storeid][vPositionY] = floatstr(Field);
                case 
6OwnedVehicles[storeid][vPositionZ] = floatstr(Field);
                case 
7OwnedVehicles[storeid][vPositionAngle] = floatstr(Field);
                case 
8OwnedVehicles[storeid][vLockStatus] = strval(Field);
                case 
9strmid(OwnedVehicles[storeid][VehicleOwner],Field,0,strlen(Field),255);
                case 
10strmid(OwnedVehicles[storeid][VehiclePlate],Field,0,strlen(Field),255);
                case 
11OwnedVehicles[storeid][vSpeedoColor] = strval(Field);
                case 
12OwnedVehicles[storeid][vWorld] = strval(Field);
                case 
13OwnedVehicles[storeid][vInteriorID] = strval(Field);
                case 
14OwnedVehicles[storeid][vImpounded] = strval(Field);
                case 
15OwnedVehicles[storeid][vSavedVehicle] = strval(Field);
                case 
16OwnedVehicles[storeid][vFuel] = strval(Field);
                case 
17OwnedVehicles[storeid][vBattery] = strval(Field);
            }
            
Field strtukDataidx'|' );
        }
        if(
OwnedVehicles[storeid][vJustChangedColor] == 1)
        {
            
OwnedVehicles[storeid][vDLID] = CreateVehicle(OwnedVehicles[storeid][vModelID], OwnedVehicles[storeid][vPositionX], OwnedVehicles[storeid][vPositionY], OwnedVehicles[storeid][vPositionZ], OwnedVehicles[storeid][vPositionAngle], OwnedVehicles[storeid][vColor1], OwnedVehicles[storeid][vColor2], -1);
             
SetVehicleVirtualWorld(OwnedVehicles[storeid][vDLID], 0);
            
LinkVehicleToInterior(OwnedVehicles[storeid][vDLID], 0);
            
OwnedVehicles[storeid][vJustChangedColor] = 0;
            new 
engine,lights,alarm,doors,bonnet,boot,objective;
            
GetVehicleParamsEx(OwnedVehicles[storeid][vDLID],engine,lights,alarm,doors,bonnet,boot,objective);
            
SetVehicleParamsEx(OwnedVehicles[storeid][vDLID],VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
        }
        else
        {
              if(
OwnedVehicles[storeid][vImpounded] == 1)
            {
                
ImpoundCount++;
                if(
ImpoundCount >= 48)
                   {
                      new 
rand random(sizeof(RandomImpoundSpawn));
                    
OwnedVehicles[storeid][vDLID] = CreateVehicle(OwnedVehicles[storeid][vModelID], RandomImpoundSpawn[rand][0], RandomImpoundSpawn[rand][1], RandomImpoundSpawn[rand][2], RandomImpoundSpawn[rand][3], OwnedVehicles[storeid][vColor1], OwnedVehicles[storeid][vColor2], -1);
                    
SetVehicleVirtualWorld(OwnedVehicles[storeid][vDLID], OwnedVehicles[storeid][vDLID]);//set vw
                    
VehicleFuel[OwnedVehicles[storeid][vDLID]] = OwnedVehicles[storeid][vFuel];
                    
VehicleBattery[OwnedVehicles[storeid][vDLID]] = OwnedVehicles[storeid][vBattery];
                }else{
                    
OwnedVehicles[storeid][vDLID] = CreateVehicle(OwnedVehicles[storeid][vModelID], RandomImpoundSpawn[ImpoundCount][0], RandomImpoundSpawn[ImpoundCount][1], RandomImpoundSpawn[ImpoundCount][2], RandomImpoundSpawn[ImpoundCount][3], OwnedVehicles[storeid][vColor1], OwnedVehicles[storeid][vColor2], -1);
                    
SetVehicleVirtualWorld(OwnedVehicles[storeid][vDLID], 0);
                    
LinkVehicleToInterior(OwnedVehicles[storeid][vDLID], 0);
                    
VehicleFuel[OwnedVehicles[storeid][vDLID]] = OwnedVehicles[storeid][vFuel];
                    
VehicleBattery[OwnedVehicles[storeid][vDLID]] = OwnedVehicles[storeid][vBattery];
                    
VehicleJustImpounded[OwnedVehicles[storeid][vDLID]] = 0;
                }
            }
            else
            {
                
OwnedVehicles[storeid][vDLID] = CreateVehicle(OwnedVehicles[storeid][vModelID], OwnedVehicles[storeid][vPositionX], OwnedVehicles[storeid][vPositionY], OwnedVehicles[storeid][vPositionZ], OwnedVehicles[storeid][vPositionAngle], OwnedVehicles[storeid][vColor1], OwnedVehicles[storeid][vColor2], -1);
                 
SetVehicleVirtualWorld(OwnedVehicles[storeid][vDLID], OwnedVehicles[storeid][vWorld]);//set vw
                
LinkVehicleToInterior(OwnedVehicles[storeid][vDLID], OwnedVehicles[storeid][vInteriorID]);//set int
                
VehicleFuel[OwnedVehicles[storeid][vDLID]] = OwnedVehicles[storeid][vFuel];
                
VehicleBattery[OwnedVehicles[storeid][vDLID]]= OwnedVehicles[storeid][vBattery];
            }
        }
        
SetVehicleNumberPlate(OwnedVehicles[storeid][vDLID], OwnedVehicles[storeid][VehiclePlate]);
        
OwnedVehicles[storeid][vSavedVehicle] = 1;
        
OwnedVehicles[storeid][vSpawned] = 1;
        new 
engine,lights,alarm,doors,bonnet,boot,objective;
        
GetVehicleParamsEx(OwnedVehicles[storeid][vDLID],engine,lights,alarm,doors,bonnet,boot,objective);
        
SetVehicleParamsEx(OwnedVehicles[storeid][vDLID],engine,lights,alarm,VEHICLE_PARAMS_ON,bonnet,boot,objective);
        if(
OwnedVehicles[storeid][vJustChanged] == 1)
        {
            for(new 
0MAX_PLAYERSi++)
            {
                if(
Player[i][JustChangedCar] == OwnedVehicles[storeid][vDLID])
                {
                    
PutPlayerInVehicle(iOwnedVehicles[storeid][vDLID], 0);
                    
OwnedVehicles[storeid][vJustChanged] = 0;
                    
Player[i][JustChangedCar] = -1;
                }
            }
        }
        
        if(
playerid != -1)
        {
            
fSendClientMessage(playeridGRAYLOGIN"> Your Vehicle: %s with Plate: %s, has been spawned!"GetVehicleName(OwnedVehicles[storeid][vModelID]), OwnedVehicles[storeid][VehiclePlate]);
            
fSendClientMessage(playeridGRAYLOGIN"> It is located in %s!",GetVehicleZone(OwnedVehicles[storeid][vDLID]));
            
Player[playerid][SpawnedPersonalCar] = OwnedVehicles[storeid][vDLID];
            
//SetPlayerCheckpoint(playerid, OwnedVehicles[storeid][vPositionX], OwnedVehicles[storeid][vPositionY], OwnedVehicles[storeid][vPositionZ], 5.0);
            //Player[playerid][Checkpoint] = 1;
        
}
        
        
ServerVehicle[OwnedVehicles[storeid][vDLID]] = 0;
        
SpawnedVehicles++;
        
mysql_free_result();
    }
}
AssignOwnedVehicles(playerid)
{
    new 
Data[1000],Field[258],idx;
    new 
MyCarStoreID;
    
mysql_queryM("SELECT `vStoreID` FROM `OwnedVehicles` WHERE `VehicleOwner` = '%s' LIMIT 10",GetName(playerid));
    
mysql_store_result();
    if(
mysql_num_rows() >= 0){
        for(new 
i=0mysql_num_rows(); i++){
             
mysql_fetch_rowEx(Data);
            
idx 0;
            
Field strtukDataidx'|' );
            for(new 
04s++)
            {
                switch(
s)
                {
                    case 
0MyCarStoreID strval(Field);
                }
                
Field strtukDataidx'|' );
            }
            if(
PlayerVehicleSlot[playerid][i] == -1){PlayerVehicleSlot[playerid][i] = MyCarStoreID;}
        }
    }
    return 
1;

Reply
#4

okay just change

[pawn]
ServerVehicle[Vehicles[storeid][DLID]] = 1;
[/pwn]
to
pawn Код:
ServerVehicle[Vehicles[storeid]][DLID] = 1;
Like I told you and the other problems will be fixed.
Reply
#5

Quote:
Originally Posted by Eth
Посмотреть сообщение
okay just change

[pawn]
ServerVehicle[Vehicles[storeid][DLID]] = 1;
[/pwn]
to
pawn Код:
ServerVehicle[Vehicles[storeid]][DLID] = 1;
Like I told you and the other problems will be fixed.
PHP код:
C:\Users\-\Desktop\voor reboot\unnamed roleplay\gamemodes\DL-RP.pwn(21392) : error 033: array must be indexed (variable "Vehicles")
C:\Users\-\Desktop\voor reboot\unnamed roleplay\gamemodes\DL-RP.pwn(21392) : error 029invalid expressionassumed zero
C
:\Users\-\Desktop\voor reboot\unnamed roleplay\gamemodes\DL-RP.pwn(21392) : warning 215expression has no effect
C
:\Users\-\Desktop\voor reboot\unnamed roleplay\gamemodes\DL-RP.pwn(21392) : error 001expected token";"but found "]"
C:\Users\-\Desktop\voor reboot\unnamed roleplay\gamemodes\DL-RP.pwn(21392) : fatal error 107too many error messages on one line
Compilation aborted
.Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase
4 Errors

Reply
#6

how do you define VehicleBattery? can you show me the variable please?
Reply
#7

new VehicleFuel[MAX_VEHICLES];
new VehicleBattery[MAX_VEHICLES];
new ServerVehicle[MAX_VEHICLES] = 0;

PHP код:
public BatteryUpdate()
{
    new 
engine,lights,alarm,doors,bonnet,boot,objective;
      for(new 
i=0;i<MAX_SERVERVEHICLES;i++)
       {
         
GetVehicleParamsEx(i,engine,lights,alarm,doors,bonnet,boot,objective);
         if(
engine == 1)
         {
            if(
VehicleBattery[i] != 100)
            {
                
VehicleBattery[i] += 1;
            }
        }
        else if(
engine == && lights == 1)
        {
            if(
VehicleBattery[i] >= 5)
            {
                
VehicleBattery[i] -= 1;
               }
             else
              {
                  
SetVehicleParamsEx(i,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
            }
        }
    }

edited...
Reply
#8

Quote:
Originally Posted by lulo356
Посмотреть сообщение
new VehicleFuel[MAX_VEHICLES];
new VehicleBattery[MAX_VEHICLES];
new ServerVehicle[MAX_VEHICLES] = 0;

PHP код:
public BatteryUpdate()
{
    new 
engine,lights,alarm,doors,bonnet,boot,objective;
      for(new 
i=0;i<MAX_SERVERVEHICLES;i++)
       {
         
GetVehicleParamsEx(i,engine,lights,alarm,doors,bonnet,boot,objective);
         if(
engine == 1)
         {
            if(
VehicleBattery[i] != 100)
            {
                
VehicleBattery[i] += 1;
            }
        }
        else if(
engine == && lights == 1)
        {
            if(
VehicleBattery[i] >= 5)
            {
                
VehicleBattery[i] -= 1;
               }
             else
              {
                  
SetVehicleParamsEx(i,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
            }
        }
    }

edited...
Why are you looping through
Код:
MAX_SERVERVEHICLES
when its defined as
Код:
MAX_VEHICLES
?
Reply
#9

Quote:
Originally Posted by -CaRRoT
Посмотреть сообщение
Why are you looping through
Код:
MAX_SERVERVEHICLES
when its defined as
Код:
MAX_VEHICLES
?
He could simply have it defined.
Reply
#10

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
He could simply have it defined.
Alright, fix his issue then.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)