27.11.2014, 20:27
Something like this would do the trick.
It should start at the first index of the array and work it's way up until the end of the array, then start over from the first set of coordinates, so it keeps going.
It should start at the first index of the array and work it's way up until the end of the array, then start over from the first set of coordinates, so it keeps going.
pawn Код:
public OnPlayerEnterCheckpoint(playerid)
{
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 431)
{
switch (BusDriver[playerid])
{
case 1:
{
SCM(playerid, -1, "Go to the next bus stop!");
}
case 2:
{
pInfo[playerid][Credits] ++;
GivePlayerMoney(playerid, 500);
}
case 3, 4, 6, 7, 8, 9, 10, 11:
{
GivePlayerMoney(playerid, 500);
}
case 5:
{
pInfo[playerid][Credits] ++;
}
}
// Increase the value of BusDriver every time you enter a checkpoint
BusDriver[playerid] = BusDriver[playerid] + 1;
// If the end of the array has been reached, set it back to 1 so you start over your bus-route
if (BusDriver[playerid] == sizeof(BusCP))
BusDriver[playerid] = 1;
// Set the checkpoint based on which step in the route you are driving
// Use "-1" because arrays don't start at 1, they start at 0, we need to substract 1 from the BusDriver variable
SetPlayerCheckpoint(playerid, BusCP[BusDriver[playerid] - 1][0], BusCP[BusDriver[playerid] - 1][1], BusCP[BusDriver[playerid] - 1][2], 5);//busstop2