So I have this arrays of checkpoints I have made. How can I use them under the callback OnPlayerEnterRaceCheckpoint (detecting which is the last checkpoint)
PHP код:
new const Float:g_arrCheckpoints[][] = {
{3199.9063, -1603.0369, 11.0098},
{3199.8782, -1577.8555, 11.2266},
{3199.8042, -1554.7965, 11.0993},
{3199.8364, -1544.1656, 11.0098},
{3200.2439, -1533.0986, 11.0098},
{3222.5374, -1533.3177, 11.2266},
{3241.9172, -1533.0231, 11.0098},
{3242.0122, -1516.8359, 11.6601},
{3241.9187, -1501.1729, 6.0084},
{3242.0002, -1486.0942, 6.2266},
{3241.7668, -1472.2089, 7.3302},
{3241.9143, -1463.2189, 10.5974},
{3241.7896, -1452.3059, 14.5464},
{3241.8970, -1436.9100, 20.2788},
{3241.7861, -1427.0548, 11.2403},
{3241.5625, -1407.2910, 11.7712},
{3217.9495, -1407.5604, 11.0993},
{3217.0859, -1394.6508, 11.0084},
{3217.6970, -1382.2604, 11.0084},
{3241.9387, -1382.0331, 10.9599}
};
You can use sizeof to get size of an arry so you would know what is in it on last or to check last data in it saved at which slot...
PHP код:
public OnPlayerEnterRaceCheckpoint(playerid)
{
gCheckpoint[playerid] ++;
if (gCheckpoint[playerid] < sizeof(g_arrCheckpoints))
{
SetPlayerRaceCheckpoint(playerid, 0, g_arrCheckpoints[gCheckpoint[playerid]][0], g_arrCheckpoints[gCheckpoint[playerid]][1], g_arrCheckpoints[gCheckpoint[playerid]][2], g_arrCheckpoints[gCheckpoint[playerid]+1][0], g_arrCheckpoints[gCheckpoint[playerid]+1][1], g_arrCheckpoints[gCheckpoint[playerid]+1][2], 5.0);
}
else
{
SetPlayerRaceCheckpoint(playerid, 1, g_arrCheckpoints[gCheckpoint[playerid]][0], g_arrCheckpoints[gCheckpoint[playerid]][1], g_arrCheckpoints[gCheckpoint[playerid]][2], 0.0, 0.0, 0.0, 5.0);
}
return 1;
}
You should first check and then increase. I had an example for a single race: