18.08.2010, 06:28
More easly way
with this you dont need on checkpoints else if else if, because Bus routes usual is about 10+ stops, so for each bus stop else if, is abit masive
pawn Код:
new BusCP[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
BusCP[playerid] = 9999;
}
new Float:BusStops[10][3] = {
{x,y,z),
{x,y,z),
{x,y,z),
{x,y,z),
{x,y,z),
{x,y,z),
{x,y,z),
{x,y,z),
{x,y,z),
{x,y,z)
};
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/startroute", cmdtext, true, 10) == 0)
{
if(BusCP[playerid] == 9999)
{
SetPlayerRaceCheckpoint(playerid,0,BusStop[0][0],BusStop[0][1],BusStop[0][2],BusStop[1][0],BusStop[1][1],BusStop[1][2],5.00);
BusCP[playerid] = 0;
return 1;
}
else
{
SendClientMessage(playerid,COLOR,"You are already on route!");
}
}
return 1;
}
public OnPlayerEnterRaceCheckpoint(playerid)
{
if(BusCP[playerid] < 9999)
{
BusCP[playerid]++;
new b = BusCP[playerid];
if(b == 9)
{
SendClientMessage(playerid,COLOR,"You end the route.");
}
else if(b <= 7)
{
SetPlayerRaceCheckpoint(playerid,0,BusStop[b][0],BusStop[b][1],BusStop[b][2],BusStop[b+1][0],BusStop[b+1][1],BusStop[b+1][2],5);
}
else
{
SetPlayerRaceCheckpoint(playerid,1,BusStop[b][0],BusStop[b][1],BusStop[b][2],BusStop[b+1][0],BusStop[b+1][1],BusStop[b+1][2],5);
}
}
return 1;
}