29.08.2015, 20:10
Here is a dummy script which you can edit to suit your needs:
You basically call startRun whenever you want him to start, For example inside a command.
PHP код:
#define MAX_CPS 5
new Float:CPs[MAX_CPS][3] = {
{0.0, 0.0, 0.0},
{0.0, 0.0, 0.0},
{0.0, 0.0, 0.0},
{0.0, 0.0, 0.0},
{0.0, 0.0, 0.0}
};
new currentCP[MAX_PLAYERS] = -1;
/* Callable Functions */
forward startRun(playerid);
public startRun(playerid)
{
currentCP[playerid] = 0;
ShowCP(playerid);
return 1;
}
/* private Funcs */
ShowCP(playerid)
{
SetPlayerCheckpoint(playerid, CPs[currentCP[playerid]][0], CPs[currentCP[playerid]][1], CPs[currentCP[playerid]][2], 5);
return 1;
}
/* Timer Funcs */
forward SetNextCP(playerid);
public SetNextCP(playerid)
{
TogglePlayerControllable(playerid, true);
if(currentCP[playerid] == MAX_CPS){
currentCP[playerid] = -1;
SendClientMessage(playerid, -1, "Done");
} else {
currentCP[playerid]++;
ShowCP(playerid);
}
return 1;
}
/* Callbacks */
public OnPlayerEnterCheckpoint(playerid)
{
if(currentCP[playerid] == -1) return 1;
if(IsPlayerInRangeOfPoint(playerid, 5, CPs[currentCP[playerid]][0], CPs[currentCP[playerid]][1], CPs[currentCP[playerid]][2]))
{
TogglePlayerControllable(playerid, false);
SetTimerEx("SetNextCP", 10000, 0, "i", playerid);
}
return 1;
}