Array out of Bounds
#1

Codes that are out of bounds

pawn Код:
// Taxi Vehicles
    JobInfo[JOB_TAXI][jCars][0] = CreateVehicle(420,1727.4966,-1858.6796,13.1931,268.8253,6,6,32000); //Taxi //Error here 1
    JobInfo[JOB_TAXI][jCars][1] = CreateVehicle(420,1727.6429,-1851.1127,13.1925,269.7512,6,6,32000); //Taxi 2
    JobInfo[JOB_TAXI][jCars][2] = CreateVehicle(420,1742.3689,-1858.6511,13.1929,269.8705,6,6,32000); //Taxi 3
    JobInfo[JOB_TAXI][jCars][3] = CreateVehicle(420,1753.3341,-1850.7306,13.2609,271.9358,6,6,32000); //Taxi 4
    JobInfo[JOB_TAXI][jCars][4] = CreateVehicle(438,1763.1429,-1858.9789,13.4170,269.3741,6,6,32000); //Taxi Cab 1
    JobInfo[JOB_TAXI][jCars][5] = CreateVehicle(438,1771.1193,-1850.6611,13.5132,268.5895,6,6,32000); //TaxiCab 2
    JobInfo[JOB_TAXI][jCars][6] = CreateVehicle(438,1780.1282,-1850.4249,13.5132,270.4590,6,6,32000); //Taxi Cab 3
    JobInfo[JOB_TAXI][jCars][7] = CreateVehicle(438,1787.4374,-1859.3351,13.5058,268.6409,6,6,32000); //Taxi Cab 4 - Error Ends here
Arrays:
pawn Код:
enum jobInfo
{
    jCars[17],
    jTrailers[9]
}
new JobInfo[MAX_JOBS][jobInfo];
ERRORS:
Код:
C:\Users\Administrator\Desktop\Legendary  Gaming Roleplay\gamemodes\LG-RP.pwn(35750) : error 032: array index out of bounds (variable "JobInfo")
C:\Users\Administrator\Desktop\Legendary  Gaming Roleplay\gamemodes\LG-RP.pwn(35751) : error 032: array index out of bounds (variable "JobInfo")
C:\Users\Administrator\Desktop\Legendary  Gaming Roleplay\gamemodes\LG-RP.pwn(35752) : error 032: array index out of bounds (variable "JobInfo")
C:\Users\Administrator\Desktop\Legendary  Gaming Roleplay\gamemodes\LG-RP.pwn(35753) : error 032: array index out of bounds (variable "JobInfo")
C:\Users\Administrator\Desktop\Legendary  Gaming Roleplay\gamemodes\LG-RP.pwn(35754) : error 032: array index out of bounds (variable "JobInfo")
C:\Users\Administrator\Desktop\Legendary  Gaming Roleplay\gamemodes\LG-RP.pwn(35755) : error 032: array index out of bounds (variable "JobInfo")
C:\Users\Administrator\Desktop\Legendary  Gaming Roleplay\gamemodes\LG-RP.pwn(35756) : error 032: array index out of bounds (variable "JobInfo")
C:\Users\Administrator\Desktop\Legendary  Gaming Roleplay\gamemodes\LG-RP.pwn(35757) : error 032: array index out of bounds (variable "JobInfo")
C:\Users\Administrator\Desktop\Legendary  Gaming Roleplay\gamemodes\LG-RP.pwn(48628) : error 032: array index out of bounds (variable "JobInfo")
This is the last line errors
pawn Код:
stock IsTaxiVehicle(vehicleid)
{
    for(new i=0; i<10; i++)
    {
        if(vehicleid == JobInfo[JOB_TAXI][jCars][i]) return 1; // Array Error
    }
    return 0;
}
Reply
#2

jCars[17] <<-- remember that when you do that is declaring an array type string
Reply
#3

Any fix?
Reply
#4

pawn Код:
new JCars[2];

// OnGameModeInit
Cars[0] = CreateVehicle(420,1727.4966,-1858.6796,13.1931,268.8253,6,6,32000);
Cars[1] = CreateVehicle(420,1727.4966,-1858.6796,13.1931,268.8253,6,6,32000);
Reply
#5

I wont it for TAXI only with a fix,..
Reply
#6

pawn Код:
for(new i=0; i<10; i++)
That is going out of bounds because there's no 9th index. Change the 10 to 9.
Reply
#7

Quote:
Originally Posted by Vince
Посмотреть сообщение
pawn Код:
for(new i=0; i<10; i++)
That is going out of bounds because there's no 9th index. Change the 10 to 9.
I changed 10 to 9 and it still is Giving errors
Reply
#8

Because if you get errors in compile time cant be in a cycle or something like this (because the compiler dont work the value of the variable).

What is the value of JOB_TAXI and of MAX_JOBS?
Reply
#9

Quote:
Originally Posted by ReVo_
Посмотреть сообщение
Because if you get errors in compile time cant be in a cycle or something like this (because the compiler dont work the value of the variable).

What is the value of JOB_TAXI and of MAX_JOBS?
Thanks soo much, you gave me a idea to check MAX_JOBS and i didnt add one more.. wondered why.. But +Rep for you thank very much
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)