Szerző Téma: Tömb méret  (Megtekintve 1321 alkalommal)

Tömb méret
« Dátum: 2011. november 13. - 11:53:19 »
0 Show voters
C:\\DOCUME~1\\RENDSZ~1\\Asztal\\samp03csvr_R5_win32\\gamemodes\\LRS.pwn(374) : error 018: initialization data exceeds declared size
Pawn compiler 3.2.3664           Copyright (c) 1997-2006, ITB CompuPhase
 
1 Error.

 
Lényegében 1 3D-s tömböt hoztam létre addig eljutottam én is, hogy a mérettel van valami, de hogy mi azt nem tudom.
[pawn]new Float: RacePos[][][] =
{
{
    {0.0,0.0,0.0}
},
{
   {-720.3224,968.2543,11.9224},
   {-825.1019,1078.2097,34.3409},
   {-908.1907,1305.4861,36.6834},
   {-1059.3177,1508.5449,34.1326},
   {-1130.7715,1757.1620,35.8118},
   {-1168.9417,1994.4725,138.0054},
   {-1072.3501,2224.0232,88.0512},
   {-1102.0239,2370.5225,85.0658},
   {-1278.3246,2213.7393,99.5277},
   {-1289.7250,2489.4011,87.0598},
   {-1208.3042,2339.8867,113.4240},
   {-1102.1383,2381.3435,84.5949},
   {-1224.4812,2677.4438,46.4149},
   {-1382.8615,2663.7275,53.8155},
   {-1655.3499,2613.5425,78.9941},
   {-1744.7561,2462.3372,72.7979},
   {-1685.7472,2389.4800,57.1322},
   {-1752.0596,2289.5938,35.2305},
   {-1613.5000,2382.9360,51.1633},
   {-1489.6725,2124.8967,45.7818},
   {-1439.1870,1932.0891,51.8262},
   {-1249.9791,1805.2781,41.1891},
   {-1103.4821,1660.8248,35.7966},
   {-1000.1243,1402.3280,41.8564},
   {-893.5744,1251.8864,34.4885},
   {-839.1600,1001.2753,24.5275},
   {-679.7209,965.8635,12.1328}
},
{
    {-45.8689,2501.6558,16.6618},
   {431.9776,2504.3010,16.0611},
   {600.1133,2071.7419,36.7113},
   {535.8548,1682.7572,10.8859},
   {657.4739,1864.1206,5.0288},
   {814.9026,1142.0156,27.9532},
   {972.5131,735.6183,10.2572},
   {1797.4706,836.3384,10.2412},
   {1831.8013,1617.6892,6.8061},
   {2070.7295,1711.5808,10.2450},
   {2118.1765,2022.1599,10.4052},
   {1927.3357,2070.0835,10.2345},
   {1928.3735,2391.8125,10.2315},
   {2026.9077,2643.8723,10.4474},
   {2087.7825,2772.8125,10.2338},
   {2386.5671,2712.8345,10.4440},
   {2385.9609,2413.1235,10.2494},
   {2227.1655,2413.3589,10.4251},
   {2144.5674,1859.6625,10.2496},
   {2424.3611,1771.9443,10.2415},
   {2427.7966,1474.2819,10.6439},
   {2636.6323,1473.5166,10.6146},
   {2547.3865,955.7063,10.4102},
   {2547.6748,773.2813,10.4433},
   {2426.0396,636.8236,10.2408},
   {2287.6726,633.4083,10.6446},
   {2287.1248,714.3221,10.6403},
   {2147.8091,752.9783,10.4412},
   {1911.1230,773.3427,10.2365},
   {1928.8123,683.2397,10.3854}
},
{
        {2717.8091,1338.9520,6.4338},
   {2726.4175,2012.7516,6.4615},
   {2362.3379,2633.1465,6.4693},
   {1652.5654,2476.1948,6.5669},
   {1226.5543,1960.2418,6.4615},
   {1229.4977,951.7524,6.5397},
   {2166.6235,851.9556,6.4653},
   {2726.6272,1277.0698,6.4653},
   {2717.8635,1900.4493,6.4448}
},
{
        {2343.9875,490.5016,-0.6056},
   {1741.0317,571.1424,-0.2740},
   {1242.1133,622.1588,0.0749},
   {603.0948,418.3969,-0.2104,},
   {260.7111,494.2618,-0.0391},
   {-510.4104,618.2807,-0.0251},
   {-504.6451,1179.9462,-0.0746},
   {-648.2136,1797.5640,-0.0628},
   {-710.6655,1983.0654,-0.1096},
   {-780.2529,1832.7721,-0.0888},
   {-598.9083,1428.6146,-0.1379},
   {-570.1831,978.4864,-0.0449},
   {-807.7171,621.3245,-0.1468},
   {-1214.7452,762.2311,-0.0478},
   {-1264.8453,988.1876,-0.1557},
   {-1320.6018,1477.6466,-0.4071},
   {-1793.8278,1784.6997,-0.1634},
   {-2179.2729,1663.1252,-0.1578},
   {-2678.6689,1545.3646,-0.2273},
   {-2798.9248,1719.0129,-0.0746},
   {-2712.2622,1990.5525,0.0519},
   {-2325.9565,2165.3887,-0.1093},
   {-2407.5767,2260.5955,-0.0281}
},
{
   {1477.3064,1371.7738,10.9973},
   {1478.7161,1689.5498,41.1524},
   {1736.7744,2019.5577,121.0787},
   {2509.4880,2144.0671,73.3225},
   {2889.3618,1742.3782,26.9581},
   {2909.7637,890.6199,85.6869},
   {2439.4053,485.2849,76.4504},
   {1376.6353,540.1570,50.9352},
   {831.0225,837.5938,61.6961},
   {418.7011,1522.2126,87.4925},
   {-315.4722,1703.0105,114.7047},
   {-910.7182,1568.7649,107.7349},
   {-1412.0406,1678.5187,73.0881},
   {-1713.9781,2233.0864,85.9840},
   {-1567.8761,2687.0662,132.1516},
   {-893.0511,2852.5125,123.6459},
   {-232.9117,2511.7537,65.2267},
   {375.8190,2500.8582,16.6619}
},
{
    {2809.0884,911.5413,10.2658},
   {2728.0862,910.8793,10.2247},
   {2727.7222,852.3715,10.2468},
   {2626.8398,843.1307,4.8218},
   {2562.8386,814.0107,4.8314},
   {2600.9126,790.9474,4.8321},
   {2645.0042,828.6792,8.3349},
   {2684.7446,789.7457,10.4629},
   {2681.4187,693.9355,10.1768},
   {2471.2178,701.7421,10.3014},
   {2427.6309,701.8656,10.1883},
   {2256.8989,713.0547,10.1838},
   {2138.6311,714.9421,10.3300},
   {2059.4907,714.7882,10.7618},
   {1988.0522,716.2535,10.1871},
   {1867.9827,702.0924,10.3698},
   {1818.2043,704.0927,10.2659},
   {1758.8345,973.5285,10.0648},
   {1584.4287,996.0328,10.1819},
   {1578.2910,933.0598,10.1834},
   {1542.7607,976.4830,10.3158},
   {1490.6351,994.1796,10.3273},
   {1379.1245,989.0377,12.6289},
   {1304.6183,1059.9086,10.3737},
   {1171.4708,1171.1914,10.2674},
   {1171.4708,1171.1914,10.2674},
   {1023.3295,1347.7145,10.3341}
},
{
    {2601.2881,2268.5410,10.3838},
   {2628.7634,2307.1973,10.2136},
   {2611.2529,2233.1191,10.2460},
   {2427.5376,2233.2676,10.4422},
   {2427.4326,2413.3650,10.4345},
   {2288.0466,2414.9487,10.3781},
   {2287.8127,2283.0737,10.4375},
   {2116.9966,2281.2751,10.3860},
   {2027.3442,2399.5996,10.3243},
   {2027.6116,2644.0908,10.4431},
   {1907.6108,2659.9199,10.2378},
   {1907.6316,2713.4658,10.4294},
   {1687.6621,2723.5691,10.2539},
   {1682.2472,2820.3428,10.2374},
   {1544.6887,2811.5205,10.2423},
   {1550.6841,2680.0352,10.2230},
   {1587.0419,2589.7104,10.4287},
   {1477.9221,2589.4260,10.6465},
   {1476.4878,2393.1086,10.4294},
   {1617.2810,2329.7039,10.3863}
},
{
    {-1831.0972,2128.9233,7.4260},
   {-1837.9584,1875.6820,0.3122},
   {-1616.2444,1711.6473,0.7099},
   {-1487.0460,1365.3743,0.2732},
   {-1158.5540,1052.4220,-0.0913},
   {-906.1534,903.6910,0.1278},
   {-721.6799,966.5105,12.5005},
   {-687.1494,1043.7883,11.5220},
   {-554.5125,1145.6825,-0.1118},
   {-625.9177,1357.5911,-0.0851},
   {-855.2821,1386.5314,-0.5450}
},
{
    {-871.7238,1996.1228,60.3828},
   {-737.5961,2060.3989,60.3828},
   {-523.3774,1993.0833,60.1875},
   {-467.1178,2079.9229,58.8067},
   {-379.7869,2221.5659,42.0938}
},
{
    {2097.0657,1159.9626,24.5625},
   {2220.5735,1095.5527,36.0367},
   {2274.9480,1111.4734,71.5831},
   {2284.3589,1177.1698,85.9375},
   {2323.5454,1283.1837,97.4552},
   {2396.1982,1552.7727,68.4252},
   {2272.2002,1676.7944,113.5389},
   {2345.0222,1823.6351,45.9831},
   {2394.4836,2098.5708,65.5921},
   {2277.4143,2442.0259,47.7078},
   {2106.5532,2384.9756,45.2265}
},
{
    {-2304.3679,-1664.4762,483.3255},
   {-2336.9575,-1817.2593,434.1870},
   {-2445.0579,-1718.9540,431.8926},
   {-2437.3318,-1808.9084,410.3822},
   {-2515.0085,-1752.2340,401.5709},
   {-2483.1602,-1502.0892,391.7757},
   {-2330.8357,-1451.4417,382.0009},
   {-2213.7949,-1612.9999,379.2620},
   {-2195.6467,-1719.7162,376.2817},
   {-2214.8496,-1508.3636,359.3989},
   {-2376.3586,-1397.0062,359.4340},
   {-2546.9465,-1497.0792,358.7327},
   {-2556.5525,-1448.9645,355.2173},
   {-2425.8088,-1358.0496,336.9928},
   {-2335.8784,-1293.7928,309.2131},
   {-2502.8806,-1270.6611,273.7525},
   {-2616.8210,-1361.8350,262.9135},
   {-2671.2805,-1369.8567,251.6068},
   {-2582.9749,-1167.7534,188.8984},
   {-2522.9111,-1110.9392,177.0143},
   {-2716.2039,-1274.2168,154.2704},
   {-2762.6477,-1544.2009,140.3163},
   {-2785.6624,-1749.0576,141.3658},
   {-2813.1409,-1863.2570,121.6098},
   {-2712.5872,-1922.7501,106.1276},
   {-2671.2993,-2089.4011,75.3057},
   {-2583.9824,-2165.9275,64.1783},
   {-2423.5674,-2134.6543,57.8799},
   {-2325.1868,-2174.2778,36.8076},
   {-2396.9319,-2206.1787,32.9573}
},
{
    {-2815.3660,-332.9168,6.7622},
   {-2809.2112,-70.1876,6.7583},
   {-2808.5166,157.0558,6.7583},
   {-2583.4570,157.6758,3.9068},
   {-2324.7302,314.6559,38.9344},
   {-2146.8206,320.6116,34.8990},
   {-2143.2212,566.5267,34.7446},
   {-2143.4585,731.4633,69.1393},
   {-1791.2090,731.4971,34.7427},
   {-1713.8262,845.0668,24.4615},
   {-1714.1973,924.5170,24.4693},
   {-2002.6395,925.0917,45.0240},
   {-2004.1073,1066.1913,55.2985},
   {-2522.5271,1115.7233,55.3052},
   {-2606.7419,1005.2093,77.8639},
   {-2606.5591,808.1576,49.5534},
   {-2348.1494,808.3323,39.9501},
   {-2143.1433,807.7341,69.1411},
   {-2143.3579,481.5247,34.7427},
   {-2167.3157,-67.8224,34.8990},
   {-1935.1555,-65.0250,25.2818},
   {-1802.0378,-116.3809,5.2337},
   {-1818.3864,-568.6442,16.0669},
   {-1922.9165,-579.0583,24.1724},
   {-1911.5759,-934.1658,44.1483},
   {-1913.0189,-1364.6785,40.0742}
},
{
    {-2783.7498,-325.6830,6.3216},
   {-2812.6636,-329.2929,6.3152},
   {-2807.4360,-211.6364,6.3146},
   {-2758.0303,-210.1400,6.3236},
   {-2758.0588,-71.5905,6.5143},
   {-2808.6248,-70.3923,6.3150},
   {-2808.3699,-7.5524,6.3149},
   {-2707.2651,-4.7676,3.4632},
   {-2706.1306,37.2519,3.5804},
   {-2604.2341,39.2922,3.6026},
   {-2546.3652,37.7384,15.7312},
   {-2501.0889,-70.7072,24.8683},
   {-2508.8997,-129.7918,24.7603},
   {-2604.4307,-130.7738,3.4635},
   {-2604.1636,-209.2011,3.4638},
   {-2656.2627,-234.1330,4.3814},
   {-2720.1206,-293.1105,6.3229},
   {-2780.9351,-287.1300,6.3231}
},
{
    {-2211.9124,170.0186,59.4706},
   {-2212.7378,219.0821,79.5201},
   {-2176.7407,409.3387,122.0171},
   {-2112.5374,534.3760,141.1204},
   {-1875.1211,616.1238,153.4263},
   {-1678.0693,660.4459,78.8784},
   {-1560.6077,642.1852,23.3477},
   {-1484.6439,532.3824,23.3143},
   {-1426.3304,376.2508,42.1937},
   {-1507.6163,107.5554,28.9249},
   {-1703.9330,-74.2664,34.6890},
   {-1929.2003,-90.7920,31.7016},
   {-2276.2393,-76.4920,65.1589},
   {-2330.2397,34.8200,67.4524},
   {-2298.9548,204.2039,54.6865},
   {-2237.6499,323.3880,66.4676},
   {-2192.1094,423.1786,58.8433}
},
{
    {-1942.2935,-2452.6387,30.5162},
   {-1820.7042,-2335.7810,35.4910},
   {-1684.0756,-2224.1902,36.9151},
   {-1550.6501,-2150.3782,9.0384},
   {-1285.1797,-2221.7725,22.1140},
   {-1068.5326,-2374.5205,46.7561},
   {-929.0363,-2365.5635,57.3055},
   {-795.1513,-2470.3892,77.5915},
   {-715.8746,-2350.2815,40.6724},
   {-585.5927,-2368.2903,27.2010},
   {-669.7538,-2504.6890,40.4415},
   {-737.3174,-2654.1282,83.7966},
   {-866.2664,-2672.1606,97.8564},
   {-1054.5120,-2678.3713,40.0836},
   {-1231.9468,-2635.8870,9.0893},
   {-1470.9910,-2635.2622,42.7668},
   {-1691.0576,-2595.7976,31.6765},
   {-1874.0341,-2435.6765,32.4246},
   {-1962.6924,-2451.5347,30.4901},
   {-2009.2357,-2410.2395,30.4904}
},
{
    {1331.2690,-2383.9380,13.2131},
   {1347.8330,-2628.0562,13.2132},
   {1564.2072,-2684.2783,6.4315},
   {1945.6587,-2684.5320,6.6069},
   {2175.1533,-2499.2405,13.2137},
   {2371.6670,-2204.3281,13.2134},
   {2816.2651,-2122.6860,10.7711},
   {2890.8440,-1615.4443,10.7161},
   {2891.1047,-960.9489,10.7133},
   {2714.3042,-315.1754,27.2203},
   {2749.7461,257.6654,20.1037},
   {2272.4270,324.7554,32.5038},
   {1632.9896,309.3086,20.9242},
   {1662.7704,329.6475,30.0948},
   {1640.0691,-37.9995,36.4264},
   {1688.7927,-455.9129,33.0194},
   {1632.0253,-1116.3580,58.8264},
   {1592.4406,-1569.4150,28.4259},
   {1604.6222,-2081.7002,19.0232},
   {1331.7098,-2278.3469,13.2248}
},
{
    {1296.7009,-712.1177,92.5509},
   {1064.2460,-774.8040,106.2757},
   {789.5958,-894.8710,55.8516},
   {675.9607,-1059.7976,48.9433},
   {593.9534,-1170.7067,44.9910},
   {311.5713,-1290.0936,53.6933},
   {165.1512,-1397.6339,46.9063},
   {170.8138,-1199.7637,48.7017},
   {288.6477,-1066.1315,87.0322},
   {527.0615,-903.0948,71.3758},
   {804.0917,-798.2452,66.5739},
   {1040.8936,-620.2328,117.5233},
   {1254.7839,-616.6053,103.2907},
   {1394.3191,-580.0294,78.4094},
   {1326.4735,-694.3179,91.8182}
},
{
    {728.8257,-1653.5706,-0.4276},
   {723.1194,-1929.0009,-0.6162},
   {575.2673,-2018.8801,-0.6081},
   {328.4088,-2044.3032,-0.5568},
   {89.6183,-1954.5170,-0.5043},
   {34.6318,-1616.7848,-0.5071},
   {57.8114,-1350.8282,-0.3615},
   {57.1755,-1090.1971,-0.4659},
   {-64.7754,-910.9921,-0.4405},
   {-149.1523,-766.8879,-0.4657},
   {21.3875,-547.2409,-0.3749},
   {224.0129,-407.4388,-0.5204},
   {415.2187,-281.3073,-0.4089},
   {674.1439,-220.2565,-0.3107},
   {904.1084,-126.9819,-0.3789},
   {1258.3307,-182.5200,-0.4536},
   {1515.4598,-219.4929,-0.4627},
   {1717.6038,-21.1727,-0.5112},
   {1908.0088,-89.6605,-0.4967},
   {2090.8953,-81.1423,-0.5005}
},
{
    {1560.1689,8.3134,23.5094},
   {1491.7327,-202.3846,11.3545},
   {1251.5875,-142.1809,38.6127},
   {1070.6567,-64.5807,20.4917},
   {876.3596,-91.1837,25.9644},
   {731.1143,-173.1375,20.1755},
   {522.3263,-216.9313,15.4238},
   {307.9947,-372.6108,9.2861},
   {208.2185,-293.0483,1.1847},
   {182.7441,-215.3446,1.1774},
   {-54.0138,-195.1367,1.4631},
   {-105.2965,-79.5735,2.8721},
   {-37.4877,141.0764,2.8708},
   {-201.9453,203.9832,11.1404},
   {-336.7879,169.7826,6.2199},
   {-596.1279,234.4380,19.3579},
   {-615.8264,106.4744,36.6152},
   {-620.1275,-66.6579,63.2536},
   {-513.1718,-166.7690,75.4485}
}
};[/pawn]
Tök mindegy a sorszám mivel akármelyik részt ami { } között van ha kiszedem megmarad a hiba.
Ty.

Tömb méret
« Válasz #1 Dátum: 2011. november 13. - 12:12:21 »
0 Show voters
Amekkora a legnagyobb elsõ dimenzió mérete ugyanakkorának kell lennie a többinek is.
Tehát adattal kitöltve inicializálva kell lennie.
Megpróbálok most egy rövid példát írni:
[pawn]
new tobbdimenzio[2][3][4] = {
{ // inicializálás kezdete az egésznek
// elsõ tömb  tobbdimenzio[0]
    {
        {1,2,3,4}, // tobbdimenzio[0][0]
        {1,2,3,4}, // tobbdimenzio[0][1]
        {0,0,0,0}  // tobbdimenzio[0][2]// Ezt is ki kell tölteni akkor is ha nem tartalmaz számodra értékes adatot mivel meghatároztad /vagy a fordító meghatározza a tömb legkisebb méretét, mely az adathalmaz legnagyobb méretével egyenlõ.
    },
//második tömb tobbdimenzio[1]
    {
        {1,2,3,4}, // tobbdimenzio[1][0] --> tobbdimenzio[1][0][0] = 1; tobbdimenzio[1][0][1] = 2;  tobbdimenzio[1][0][2] = 3;  tobbdimenzio[1][0][3] = 4;
        {5,6,7,8}, // tobbdimenzio[1][1] --> tobbdimenzio[1][1][0] = 5; tobbdimenzio[1][1][1] = 6;  tobbdimenzio[1][1][2] = 7;  tobbdimenzio[1][1][3] = 8;
        {9,10,11,12} // tobbdimenzio[1][2] --> tobbdimenzio[1][2][0] =9; tobbdimenzio[1][2][1] = 10;  tobbdimenzio[1][2][2] = 11;  tobbdimenzio[1][2][3] = 12;
    }
};
[/pawn]
Másképp írva minden egyes cellának meg kell határoznod az értékét ha nulla akkor is.
Még másképp írva, hatalmas memória pazarlás az ilyen megoldások használata.

Tömb méret
« Válasz #2 Dátum: 2011. november 13. - 13:48:55 »
0 Show voters
Oké, hatalmas memóriapazarlás. Tudsz valami módszert 2D-s tömbökön kívül még erre?

Nem elérhető kurta999

  • 2759
  • Éllő fédisznó
    • Profil megtekintése
Tömb méret
« Válasz #3 Dátum: 2011. november 13. - 14:06:04 »
0 Show voters
Fájlba elmenteni és mindig betölteni minden versenynél csak azt, amelyiket használod.

Tömb méret
« Válasz #4 Dátum: 2011. november 13. - 14:23:05 »
0 Show voters
Egyszer már próbáltam úgy hogy rögtön olvassa a fájlból mikor versenyzik így még nem, de megpróbálom thx.

Tömb méret
« Válasz #5 Dátum: 2011. november 13. - 15:12:54 »
0 Show voters
Legbeváltabb módszer hogy létrehozol egy versenynek egy változót ami a maximális CP-k számával azonos méretû.
[pawn]
#define MAX_RACE_CHECKPOINT 32 //Itt meghatározod mennyi lehet a maximális checkpoint.
new Float:RacePos[MAX_RACE_CHECKPOINT][3]; //Itt csak 3 adat x, y, z[/pawn]
Majd ezt a változót használod fel minden egyes verseny kezdetekor az aktuális verseny checkpointjainak tárolására.
Persze használhatsz enum adat felépítést is elõnye hogy bármilyen típusú adatot tárolhatsz benne, nincs lekorlátozva egy adat típusra.
[pawn]
enum Race_Enum
{
    Float:race_x,
    Float:race_y,
    Float:race_z,
    race_bonus
};
new RacePos[MAX_RACE_CHECKPOINT][Race_Enum];
[/pawn]

Tömb méret
« Válasz #6 Dátum: 2011. november 13. - 15:21:32 »
0 Show voters
Eszerint fogom csinálni kössz.

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal