sizeof error
#1

Array;
PHP код:
new VehicleCols[][] =
{
    {
4,1123,1113,1101,175,162,140,136,1},
    {
41,4147,4752,5266,6674,7487,87,91,91113,113},
    {
10,1013,1322,2230,3039,3990,9098,98110,110},
    {
36,137,130,128,125,140,1101,1113,1},
    {
113,39119,50123,92109,100101,10195,10583,11066,25},
    {
11,124,136,140,175,191,1123,14,1},
    {
1,1},
    {
3,1},
    {
26,26},
    {
1,1},
    {
4,19,110,125,136,140,145,184,1},
    {
12,164,1123,1116,1112,1106,180,175,1},
    {
9,110,811,125,827,129,830,137,8},
    {
87,188,191,1105,1109,1119,14,125,1},
    {
25,128,143,167,1},
    {
72,19,195,124,1},
    {
20,125,136,140,162,175,192,10,1},
    {
1,3},
    {
1,1}, // leviathn none
    
{119,119117,227114,114108,10895,9581,8161,6141,41},
    {
45,7547,7633,7513,7654,7569,7659,7587,76},
    {
6,1},
    {
4,113,125,130,136,140,175,195,1},
    {
96,2597,25101,25111,31113,3683,5767,59},
    {
1,161,561,171,531,51,35},
    {
1,02,23,23,66,1615,3024,5335,61},
    {
43,0},
    {
37,3742,4253,5362,627,710,1011,1115,15},
    {
0,1},
    {
4,75},
    {
12,1213,1314,141,22,11,33,110,10},
    {
46,26},
    {
71,5975,5992,7247,7455,8359,8371,8782,87},
    {
43,0},
    {
43,0},
    {
1,112,122,26,64,446,4653,53},
    {
1,1},
    {
83,187,192,195,1109,1119,4511,1},
    {
54,779,787,795,1698,20105,20123,20125,21},
    {
6,76},
    {
57,88,1743,2154,3867,837,7865,7925,78},
    {
34,3432,3220,20110,11066,6684,84118,118121,121},
    {
2,9679,4282,5467,86126,9670,96110,5467,98},
    {
0,011,10525,10936,040,3675,360,360,109},
    {
4,120,124,125,136,140,154,184,1},
    {
32,3632,4232,5332,6632,1432,32},
    {
34,3435,3537,3739,3941,4143,4345,4547,47},
    {
1,1}, // squalo special
    
{75,2},
    {
3,6},
    {
1,74},
    {
1,1},
    {
123,123125,12536,3616,1618,1846,4661,6175,75},
    {
1,31,51,161,221,351,441,531,57},
    {
56,56},
    {
26,26},
    {
84,1584,5884,3132,7443,311,3177,3132,74},
    {
84,6391,63102,65105,72110,93121,9312,9523,1},
    {
58,12,163,118,132,145,113,134,1},
    {
91,1101,1109,1113,14,125,130,136,1},
    {
26,2628,2844,4451,5157,5772,72106,106112,112},
    {
1,31,91,181,3017,2346,2346,3257,34},
    {
36,137,143,153,161,175,179,188,1},
    {
12,1213,1314,141,22,11,33,110,10},
    {
79,7984,847,711,1119,1922,2236,3653,53},
    {
14,75},
    {
14,75},
    {
67,7668,7678,762,7616,7618,7625,7645,88},
    {
51,158,860,168,82,113,822,136,8},
    {
6,646,4653,533,3},
    {
1,3},
    {
43,0},
    {
120,117103,111120,11474,91120,11274,83120,11366,71},
    {
56,1556,53},
    {
56,1556,53},
    {
97,181,1105,1110,191,174,184,183,1},
    {
2,399,3917,121,133,037,041,2956,29},
    {
6,77,61,689,91119,117103,10277,8771,77},
    {
92,194,1101,1121,10,122,136,175,1},
    {
72,166,159,145,140,139,135,120,1},
    {
27,3659,3660,3555,4154,3149,2345,3240,29},
    {
73,4512,122,26,64,446,4653,53},
    {
1,13,36,646,4665,914,112,926,1},
    {
41,4148,4852,5264,6471,7185,8510,1062,62},
    {
1,1}, // camper special
    
{12,3550,3240,2666,36},
    {
1,731,741,751,761,771,781,79},
    {
1,1},
    {
26,1429,4226,5754,2926,33,2912,3974,35},
    {
2,262,29},
    {
13,11814,123120,123112,12084,11076,102},
    {
0,0},
    {
40,6571,7252,6664,7230,7260,72},
    {
30,2677,2681,2724,5528,5649,5952,6971,107},
    {
36,13},
    {
36,11736,1342,3042,3354,3675,7992,10198,109},
    {
123,124119,122118,117116,115114,108101,10688,995,6},
    {
74,7266,7253,5637,1922,2220,209,140,0},
    {
0,1},
    {
11,12313,12020,11724,11227,10736,10537,10743,93},
    {
109,25109,32112,3210,3230,4432,5284,6684,69},
    {
75,8440,8440,11028,11925,11921,11913,1194,119},
    {
14,75},
    {
7,9436,8851,7553,75 ,58,6775,6775,6179,62},
    {
83,6687,7487,7598,83101,100103,101117,116123,36},
    {
51,3957,3845,2934,965,914,112,926,1},
    {
13,11814,123120,123112,12084,11076,102}, // Rancher lure
    
{3,36,67,752,5276,76},
    {
37,3742,4253,5362,627,710,1011,1115,15},
    {
1,1},
    {
7,174,161,116,125,130,136,153,1},
    {
43,4346,4639,3928,2816,166,65,52,2},
    {
3,904,907,688,6612,6027,9734,5137,51},
    {
17,3915,12332,11245,8852,7157,6761,9696,96},
    {
38,5121,3621,3430,3454,3455,2048,1851,6},
    {
10,125,128,136,140,154,175,1113,1},
    {
13,7624,7763,7842,7654,7739,7811,7662,77},
    {
116,1119,1122,14,19,124,127,136,1},
    {
37,3636,3640,3643,4147,4151,7254,7555,84},
    {
2,399,3917,121,133,037,041,2956,29},
    {
1,1},
    {
1,1}, // hydra none
    
{74,7475,1387,11892,3115,11825,11836,0118,118},
    {
3,33,86,257,798,8236,10539,10651,118},
    {
1,1}, // copbike none
    
{1,1}, // cement special
    
{1,117,2018,2022,3036,4344,5152,54},
    {
2,399,3917,121,133,037,041,2956,29},
    {
52,153,166,175,176,181,195,1109,1},
    {
1,1}, // fbitruck none
    
{37,3742,4253,5362,627,710,1011,1115,15},
    {
110,1111,1112,1114,1119,1122,14,113,1},
    {
2,3536,251,5391,211,2240,35},
    {
1,1}, // combine none
    
{73,174,175,177,179,183,184,191,1},
    {
37,3742,4253,5362,627,710,1011,1115,15},
    {
3,128,131,155,166,197,1123,1118,1},
    {
9,112,126,9630,9632,137,157,9671,96},
    {
1,1},
    {
1,1},
    {
96,6786,7079,7470,8661,9875,7575,91},
    {
37,3742,4253,5362,627,710,1011,1115,15},
    {
51,158,860,168,82,113,822,136,8},
    {
13,11824,11831,9332,9245,92113,92119,113122,113},
    {
76,832,843,867,811,118,902,283,13},
    {
3,1},
    {
50,147,144,9640,9639,130,128,969,96},
    {
62,3778,382,623,872,78113,78119,627,78},
    {
122,1123,1125,110,124,137,155,166,1},
    {
1,1},
    {
74,3972,3975,3979,3983,3684,3689,3591,35},
    {
37,3742,4253,5362,627,710,1011,1115,15},
    {
67,172,175,183,191,1101,1109,120,1},
    {
56,5649,4926,124},
    {
38,955,2361,7471,8791,8798,114102,119111,3},
    {
53,3215,3245,3234,3065,3214,3212,3243,32},
    {
51,158,160,168,12,113,122,136,1},
    {
1,1},
    {
1,1},
    {
112,1116,1117,124,130,135,136,140,1},
    {
51,158,860,168,82,113,822,136,8},
    {
52,399,3917,121,133,037,041,2956,29},
    {
57,88,1743,2154,3867,837,7865,7925,78},
    {
36,135,117,111,1116,1113,1101,192,1},
    {
1,6},
    {
1,1}, // rctiger none
    
{37,3742,4253,5362,627,710,1011,1115,15},
    {
109,130,895,184,883,172,871,152,8},
    {
97,9688,6490,9693,6497,9699,81102,114114,1},
    {
2,399,3917,121,133,037,041,2956,29},
    {
1,1},
    {
1,1},
    {
2,3536,251,5391,211,2240,35},
    {
94,1101,1116,1117,14,125,130,137,1},
    {
91,38115,4385,679,778,877,1879,1886,24},
    {
26,26},
    {
12,119,9631,6425,9638,151,9657,166,96},
    {
67,168,9672,174,875,9676,879,184,96},
    {
1,38,78,108,1623,3140,44},
    {
1,1},
    {
37,3742,4253,5362,627,710,1011,1115,15},
    {
92,9281,8167,6766,6661,6153,5351,5147,4743,43},
    {
54,158,166,172,175,187,1101,136,1},
    {
41,1041,2049,1156,123110,113112,116114,118119,101},
    {
1,1},
    {
1,1},
    {
37,3742,4253,5362,627,710,1011,1115,15},
    {
119,1122,18,110,113,125,127,132,1},
    {
36,140,143,153,172,175,195,1101,1},
    {
1,1},
    {
37,3731,3123,2322,227,7124,124114,114112,112},
    {
1,1}, // freibox none
    
{1,1},
    {
1,1},
    {
51,158,860,168,82,113,822,136,8},
    {
1,1}, // rccam none
    
{112,20},
    {
0,1},
    {
0,1},
    {
0,1},
    {
0,1},
    {
81,832,843,867,811,118,902,283,13},
    {
1,1},
    {
58,169,175,7718,132,145,4513,134,1},
    {
58,169,175,7718,132,145,4513,134,1},
    {
67,7668,7678,762,7616,7618,7625,7645,88},
    {
61,832,843,867,811,118,902,283,13},
    {
1,1}, // bagboxa none
    
{1,1}, // bagboxb none
    
{1,1},
    {
36,36}, // boxburg
    
{1,1}, // farmtr1 none
    
{1,1// utiltr1 none
    
}; 
Anywhere;
PHP код:
stock GetVehicleColor(modelid, &color1=0, &color2=0)
{
    if(
modelid 400 || modelid >> 611) return 0;
    new 
rand random(sizeof(VehicleCols[modelid-400])/2); // Line 563
    
color1 VehicleCols[modelid-400][rand 2];
    
color2 VehicleCols[modelid-400][rand 1];
    return 
1;

Example;
PHP код:
    new color1color2;
    
GetVehicleColor(450color1color2);
    
printf("%i"color1);
    
printf("%i"color2); 
Error;
Код:
C:\Users\Vetle\sampie\gamemodes\gm.pwn(563) : error 001: expected token: "]", but found "-identifier-"
C:\Users\Vetle\sampie\gamemodes\gm.pwn(563) : warning 215: expression has no effect
C:\Users\Vetle\sampie\gamemodes\gm.pwn(563) : error 001: expected token: ";", but found "]"
C:\Users\Vetle\sampie\gamemodes\gm.pwn(563) : error 029: invalid expression, assumed zero
C:\Users\Vetle\sampie\gamemodes\gm.pwn(563) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#2

Have you tried [modelid]-400)/2)
Reply
#3

The sizeof() operator cannot be used on certain cells in an array. Your two-dimensional array doesn't have it's sizes specified, and sizeof(VehicleCols[]) (that's the way to use it) doesn't have a way to return a constant size, as it varies across different rows.
Reply
#4

Quote:
Originally Posted by Wicko
Посмотреть сообщение
The sizeof() operator cannot be used on certain cells in an array. Your two-dimensional array doesn't have it's sizes specified, and sizeof(VehicleCols[]) (that's the way to use it) doesn't have a way to return a constant size, as it varies across different rows.
So i have to add another value to the array?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)