This code causes Runtime error 22
#1

Hello People,

Yesterday I made a help request since I kept getting Runtime error 22.
I went cutting parts out of my script into a new script and found the code that causes the runtime error.
I just cant see the problem x)

pawn Код:
public OnPlayerSpawn(playerid)
{
    if(MapTime != 1200)
    {
        new rand = random(sizeof(SpawnVehicles));
        new rnd = random(sizeof(SpawnPoints));
        Player[playerid][LastCar] = AddStaticVehicleEx(SpawnVehicles[rand][0], SpawnPoints[CurrentMap][rnd][0], SpawnPoints[CurrentMap][rnd][1], SpawnPoints[CurrentMap][rnd][2], SpawnPoints[CurrentMap][rnd][3], -1, -1, -1);
        PutPlayerInVehicle(playerid, Player[playerid][LastCar], 0);
        SetPlayerColor(playerid, ALIVEGREEN);
        TogglePlayerSpectating(playerid, 0);
    }
    else
    {
        SCM(playerid, NOTICE2, "> The game will start shortly!");
    }
    return 1;
}
This are the SpawnVehicles and SpawnPoints things
pawn Код:
new Float:SpawnPoints[MAX_MAPS][][4] =
{
    {
        {585.2798, 1505.1494, 374.7411, 0.0000},
        {570.7695, 1507.6335, 374.7411, -22.0000},
        {559.3127, 1515.2843, 374.7411, -36.0000},
        {550.9893, 1527.0104, 374.7411, -58.0000},
        {548.8347, 1541.1188, 374.7411, -94.0000},
        {553.1444, 1552.8341, 374.7411, -118.0000},
        {560.4863, 1562.7729, 374.7411, -128.0000},
        {569.4068, 1568.6963, 374.7411, -152.0000},
        {599.2963, 1509.5494, 374.7411, 24.0000},
        {609.0432, 1519.7307, 374.7411, 54.0000},
        {613.8626, 1535.9028, 374.7411, 82.0000},
        {610.5563, 1553.8574, 374.7411, 118.0000},
        {601.8462, 1564.5435, 374.7411, 142.0000}
    },
    {
        {1516.6193, -1343.5270, 331.1477, 0.0000},
        {1504.3636, -1339.6896, 331.1477, -24.0000},
        {1494.4601, -1332.8392, 331.1477, -44.0000},
        {1487.3043, -1323.1720, 331.1477, -60.0000},
        {1484.4692, -1311.4364, 331.1477, -82.0000},
        {1486.8243, -1300.3571, 331.1477, -98.0000},
        {1509.9259, -1280.4216, 331.1477, -178.0000},
        {1521.1614, -1280.4551, 331.1477, -190.0000},
        {1532.4818, -1284.5511, 331.1477, -212.0000},
        {1540.9180, -1291.8628, 331.1477, -228.0000},
        {1546.4932, -1301.7428, 331.1477, -244.0000},
        {1548.8530, -1311.9092, 331.1477, -260.0000},
        {1546.5038, -1324.3477, 331.1477, -287.0000}
    },
    {
        {3381.6125, -2319.9932, 47.4447, 0.0000},
        {3394.2463, -2317.1045, 47.4447, 26.0000},
        {3403.5742, -2310.7549, 47.4447, 42.0000},
        {3411.2297, -2302.0220, 47.4447, 62.0000},
        {3414.0874, -2292.0530, 47.4447, 76.0000},
        {3414.2307, -2281.7280, 47.4447, 92.0000},
        {3411.2996, -2270.9583, 47.4447, 106.0000},
        {3367.3394, -2317.4260, 47.4447, -22.0000},
        {3356.9951, -2310.8574, 47.4447, -48.0000},
        {3350.6316, -2302.3921, 47.4447, -66.0000},
        {3347.7080, -2291.1531, 47.4447, -90.0000},
        {3348.3906, -2280.5510, 47.4447, -108.0000},
        {3352.2373, -2271.2991, 47.4447, -116.0000}
    },
    {
        {3030.7651, -1714.1014, 5.4140, -16.0000},
        {3018.6475, -1710.5886, 5.4140, -30.0000},
        {3009.4661, -1702.1119, 5.4140, -60.0000},
        {3004.8174, -1690.8959, 5.4140, -82.0000},
        {3004.8958, -1679.0525, 5.4140, -106.0000},
        {3009.2554, -1667.5747, 5.4140, -124.0000},
        {3018.0298, -1658.2810, 5.4140, -148.0000},
        {3029.4451, -1652.3661, 5.4140, -166.0000},
        {3041.0393, -1652.0685, 5.4140, -184.0000},
        {3053.3784, -1655.1782, 5.4140, -210.0000},
        {3062.7642, -1662.5416, 5.4140, -230.0000},
        {3043.9685, -1713.1207, 5.4140, 2.0000},
        {3054.3306, -1708.6062, 5.4140, 26.0000}
    },
    {
        {1359.6683, -3026.7212, 10.3308, 0.0000},
        {1347.3188, -3023.8518, 10.3308, -33.0000},
        {1337.6382, -3016.3494, 10.3308, -53.0000},
        {1331.7793, -3006.6577, 10.3308, -75.0000},
        {1329.5199, -2995.3359, 10.3308, -91.0000},
        {1333.4027, -2982.8984, 10.3308, -115.0000},
        {1341.8007, -2973.9297, 10.3308, -133.0000},
        {1353.1160, -2969.1873, 10.3308, -157.0000},
        {1365.1775, -2968.9023, 10.3308, -183.0000},
        {1377.7871, -2974.4363, 10.3308, -207.0000},
        {1371.7369, -3024.0090, 10.3308, 33.0000},
        {1380.8043, -3017.4485, 10.3308, 45.0000},
        {1388.1356, -3009.9050, 10.3308, 55.0000}
    },
    {
        {2872.8525, 392.5188, 15.8739, 0.0000},
        {2883.6614, 395.5276, 15.8739, 20.0000},
        {2892.7441, 400.7635, 15.8739, 32.0000},
        {2899.1257, 408.7927, 15.8739, 40.0000},
        {2863.2629, 394.1850, 15.8739, -10.0000},
        {2852.9651, 398.8764, 15.8739, -30.0000},
        {2845.8079, 407.8704, 15.8739, -58.0000},
        {2842.0947, 418.6797, 15.8739, -90.0000},
        {2842.9856, 428.8853, 15.8739, -112.0000},
        {2846.9778, 438.0630, 15.8739, -126.0000},
        {2854.6411, 446.0839, 15.8739, -144.0000},
        {2864.0488, 450.4969, 15.8739, -164.0000},
        {2874.1221, 451.9822, 15.8739, -180.0000}
    }
};

new SpawnVehicles[][]= {401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,
                        416,418,419,420,421,422,423,424,426,427,428,429,431,433, 434,
                        436,437,438,439,440,443,444,445,448,451,455,456,457,458,461,462,463,
                        466,467,468,470,471,474,475,477,478,479,480,481,482,483,486,
                        489,490,491,492,494,495,496,498,499,500,502,503,504,505,506,507,508,509,510,
                        514,515,516,517,518,521,522,523,524,525,526,527,528,529,530,531,532,533,534,535,536,
                        540,541,542,543,544,545,546,547,549,550,551,552,554,555,556,557,558,559,560,561,562,
                        565,566,567,568,573,574,575,576,578,579,580,581,582,585,586,587,589,596,597,598,599,
                        600,601,602,603,604};
Код:
new rand = random(sizeof(SpawnVehicles));
	    new rnd = random(sizeof(SpawnPoints));
	    Player[playerid][LastCar] = AddStaticVehicleEx(SpawnVehicles[rand][0], SpawnPoints[CurrentMap][rnd][0], SpawnPoints[CurrentMap][rnd][1], SpawnPoints[CurrentMap][rnd][2], SpawnPoints[CurrentMap][rnd][3], -1, -1, -1);
its in those lines..
Reply
#2

pawn Код:
//Change
new rnd = random(sizeof(SpawnPoints));
//to
new rnd = random(sizeof(SpawnPoints[]));
Additionaly

pawn Код:
new SpawnVehicles[][]
You don't need 2d array for single numbers, use
pawn Код:
new SpawnVehicles[]
instead.

Then change
pawn Код:
SpawnVehicles[rand][0]
to
pawn Код:
SpawnVehicles[rand]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)