error 052: multi-dimensional arrays must be fully initialized
#1

PHP Code:
new TrailerDestination[][][Trailer] =
{
    {
        {
"Gas Station"1941.9574, -1790.263713.3828},
        {
"Gas Station"980.5435, -921.293041.2895}
    },
    {
        {
"Ammu Nation"1363.7482, -1287.414813.5469}
    }, 
// ====================================== error line
    
{
        {
"Well Stacked Pizza"2094.8977, -1800.015413.3426},
        {
"Cluckin' Bell"2370.5210,-1910.6147,13.1099},
        {
"Cluckin' Bell"2408.2141,-1482.2157,23.5552},
        {
"Cluckin' Bell"922.3662,-1358.4125,13.0151},
        {
"Joe's Sticky Ring"1015.9811,-1345.2292,13.1014},
        {
"Burger Shot"788.3559,-1635.6775,13.1099},
        {
"Burger Shot"788.3559,-1635.6775,13.1099}
    },
    {
        {
"Construction Materials"1857.0723,-1321.2823,13.1993}
    }
};
CMD:work(playeridparams[])
{
    new 
Float:xFloat:yFloat:ztrailertype 0string[128] = "Destination\nDistance\n";
    if(!
IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playeridCOLOR_PLAYER"ERROR: You are not in any vehicle!");
    switch(
GetVehicleTrailer(GetPlayerVehicleID(playerid)))
    {
        case 
584trailertype 0;
        default: 
SendClientMessage(playeridCOLOR_PLAYER"ERROR: You do not have any trailers on your truck!");
     }
     
GetPlayerPos(playeridxyz);
    for(new 
07i++)
    {
        
format(stringsizeof(string), "%s%s\n%f"stringTrailerDestination[trailertype][i][Name], GetDistance(xyzTrailerDestination[trailertype][i][DestX], TrailerDestination[trailertype][i][DestY], TrailerDestination[trailertype][i][DestZ]));
    }
    return 
1;

Code:
C:\Users\metro\Documents\SA-MP\gamemodes\ls2.pwn(38) : error 052: multi-dimensional arrays must be fully initialized
Help.

EDIT: GetDistance works.
Reply
#2

TrailerDestination[trailertype][i][Name]


try


TrailerDestination[][trailer]


Or
try TrailerDestination[][]
Reply
#3

show us Trailer enum.
Reply
#4

new TrailerDestination[][Trailer] =
{
{"Gas Station", 1941.9574, -1790.2637, 13.3828},
{"Gas Station", 980.5435, -921.2930, 41.2895},
{"Ammu Nation", 1363.7482, -1287.4148, 13.5469} ,
{"Well Stacked Pizza", 2094.8977, -1800.0154, 13.3426},
{"Cluckin' Bell", 2370.5210,-1910.6147,13.1099},
{"Cluckin' Bell", 2408.2141,-1482.2157,23.5552},
{"Cluckin' Bell", 922.3662,-1358.4125,13.0151},
{"Joe's Sticky Ring", 1015.9811,-1345.2292,13.1014},
{"Burger Shot", 788.3559,-1635.6775,13.1099},
{"Burger Shot", 788.3559,-1635.6775,13.1099},
{"Construction Materials", 1857.0723,-1321.2823,13.1993}

};
Reply
#5

Well.. I don't think someone of you read the error message.
An multi-dimensional arrays must be fully initialized. That's means, if you declare somes values in one of your array's dimension ; you need to set others dimensions's size explicitly and every value from any dimensions.

In other words (taken from this website):
If an array with more than one dimension is initialized at its declaration, then there must be equally many literal vectors/sub- arrays at the right of the equal sign (“=”) as specified for the major dimension(s) of the array.

Example of a code produce error:
PHP Code:
new Array[][][] =
{
    {
        {
0},
        {
1}
    },
    {
        {
0}
    }
}; 
Solution:
PHP Code:
new Array[][][] =
{
    {
        {
0},
        {
1}
    },
    {
        {
0},
        {
1}
    }
}; 
Reply
#6

PHP Code:
enum Trailer
{
    
Name[32],
    
Float:DestX,
    
Float:DestY,
    
Float:DestZ
};
new 
TrailerDestination[][][Trailer] =
{
    {
        {
"Gas Station"1941.9574, -1790.263713.3828},
        {
"Gas Station"980.5435, -921.293041.2895}
    },
    
    {
        {
"Ammu Nation"1363.7482, -1287.414813.5469},
        {
"Ammu Nation"1363.7482, -1287.414813.5469}
    },
    
    {
        {
"Well Stacked Pizza"2094.8977, -1800.015413.3426},
        {
"Cluckin' Bell"2370.5210,-1910.6147,13.1099},
        {
"Cluckin' Bell"2408.2141,-1482.2157,23.5552},
        {
"Cluckin' Bell"922.3662,-1358.4125,13.0151},
        {
"Joe's Sticky Ring"1015.9811,-1345.2292,13.1014},
        {
"Burger Shot"788.3559,-1635.6775,13.1099},
        {
"Burger Shot"788.3559,-1635.6775,13.1099}
    }, 
// ERROR LINE
    
    
{
        {
"Construction Materials"1857.0723,-1321.2823,13.1993},
        {
"Ammu Nation"1363.7482, -1287.414813.5469}
    } 
// ERROR LINE
}; 
Code:
C:\Users\metro\Documents\SA-MP\gamemodes\ls2.pwn(50) : error 018: initialization data exceeds declared size
C:\Users\metro\Documents\SA-MP\gamemodes\ls2.pwn(55) : error 052: multi-dimensional arrays must be fully initialized
I edited it a bit.

What I want to achieve: Different types of trailer for different destinations.
Reply
#7

Try.
PHP Code:
new TrailerDestination[12][Trailer] =
{
    {
"Gas Station"1941.9574, -1790.263713.3828},
     {
"Gas Station"980.5435, -921.293041.2895},
      {
"Ammu Nation"1363.7482, -1287.414813.5469},
    {
"Well Stacked Pizza"2094.8977, -1800.015413.3426},
    {
"Cluckin' Bell"2370.5210,-1910.6147,13.1099},
    {
"Cluckin' Bell"2408.2141,-1482.2157,23.5552},
    {
"Cluckin' Bell"922.3662,-1358.4125,13.0151},
    {
"Joe's Sticky Ring"1015.9811,-1345.2292,13.1014},
    {
"Burger Shot"788.3559,-1635.6775,13.1099},
    {
"Burger Shot"788.3559,-1635.6775,13.1099},
    {
"Construction Materials"1857.0723,-1321.2823,13.1993},
    {
"Ammu Nation"1363.7482, -1287.414813.5469}
}; 
Reply
#8

Quote:
Originally Posted by DelK
View Post
Try.
PHP Code:
new TrailerDestination[12][Trailer] =
{
    {
"Gas Station"1941.9574, -1790.263713.3828},
     {
"Gas Station"980.5435, -921.293041.2895},
      {
"Ammu Nation"1363.7482, -1287.414813.5469},
    {
"Well Stacked Pizza"2094.8977, -1800.015413.3426},
    {
"Cluckin' Bell"2370.5210,-1910.6147,13.1099},
    {
"Cluckin' Bell"2408.2141,-1482.2157,23.5552},
    {
"Cluckin' Bell"922.3662,-1358.4125,13.0151},
    {
"Joe's Sticky Ring"1015.9811,-1345.2292,13.1014},
    {
"Burger Shot"788.3559,-1635.6775,13.1099},
    {
"Burger Shot"788.3559,-1635.6775,13.1099},
    {
"Construction Materials"1857.0723,-1321.2823,13.1993},
    {
"Ammu Nation"1363.7482, -1287.414813.5469}
}; 
Yes, that would work. But I am talking about the 3D arrays. For example, for the Petrol Trailer:
PHP Code:
    // Trailer 1
        
{"Gas Station"1941.9574, -1790.263713.3828}, // Destination 1
        
{"Gas Station"980.5435, -921.293041.2895}// Destination 2
    
}, 
for the Petrol trailer, only these distances would be covered by the array, so if I use TrailerDestination[0][0][Name] (which means Trailer 1, Destination 1, Name), that would certainly call the variable. But the problem is, it gives off an error.
Reply
#9

i tried this and worked.

PHP Code:
#include <a_samp>

enum Trailer 

    
Name[32], 
    
Float:DestX
    
Float:DestY
    
Float:DestZ 
}; 

new const 
TrailerDestination[][Trailer][] = 
{
    { 
        {
"Gas Station"1941.9574, -1790.263713.3828}, 
        {
"Gas Station"980.5435, -921.293041.2895
    }, 
    { 
        {
"Ammu Nation"1363.7482, -1287.414813.5469
    },
    { 
        {
"Well Stacked Pizza"2094.8977, -1800.015413.3426}, 
        {
"Cluckin' Bell"2370.5210,-1910.6147,13.1099}, 
        {
"Cluckin' Bell"2408.2141,-1482.2157,23.5552}, 
        {
"Cluckin' Bell"922.3662,-1358.4125,13.0151}, 
        {
"Joe's Sticky Ring"1015.9811,-1345.2292,13.1014}, 
        {
"Burger Shot"788.3559,-1635.6775,13.1099}, 
        {
"Burger Shot"788.3559,-1635.6775,13.1099
    }, 
    { 
        {
"Construction Materials"1857.0723,-1321.2823,13.1993
    } 
}; 
Reply
#10

PHP Code:
new TrailerDestination[][][Trailer] = 

    { 
        {
"Gas Station"1941.9574, -1790.263713.3828}, 
        {
"Gas Station"980.5435, -921.293041.2895},
        {
""0.00.00.0},
        {
""0.00.00.0},
        {
""0.00.00.0},
        {
""0.00.00.0},
        {
""0.00.00.0}
    }, 
     
    { 
        {
"Ammu Nation"1363.7482, -1287.414813.5469}, 
        {
"Ammu Nation"1363.7482, -1287.414813.5469},
        {
""0.00.00.0},
        {
""0.00.00.0},
        {
""0.00.00.0},
        {
""0.00.00.0},
        {
""0.00.00.0}
    }, 
     
    { 
        {
"Well Stacked Pizza"2094.8977, -1800.015413.3426}, 
        {
"Cluckin' Bell"2370.5210,-1910.6147,13.1099}, 
        {
"Cluckin' Bell"2408.2141,-1482.2157,23.5552}, 
        {
"Cluckin' Bell"922.3662,-1358.4125,13.0151}, 
        {
"Joe's Sticky Ring"1015.9811,-1345.2292,13.1014}, 
        {
"Burger Shot"788.3559,-1635.6775,13.1099}, 
        {
"Burger Shot"788.3559,-1635.6775,13.1099
    }, 
// ERROR LINE 
     
    

        {
"Construction Materials"1857.0723,-1321.2823,13.1993}, 
        {
"Ammu Nation"1363.7482, -1287.414813.5469},
        {
""0.00.00.0},
        {
""0.00.00.0},
        {
""0.00.00.0},
        {
""0.00.00.0},
        {
""0.00.00.0}
    } 
// ERROR LINE 
}; 
u.u
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)