public OnPlayerEnterCheckpoint(playerid)
{
print("Someone entered a checkpoint, checking what one");
if(PlayerCPInformation[playerid][MissionCheckPoint] == 1 && AccountInformation[playerid][CurrentlyWorking] > -1)
{
print("Someone entered a mission checkpoint");
if(GetPlayerVehicleID(playerid) == AccountInformation[playerid][WorkingVehicleID])
{
print("The vehicle it was started in is valid");
new job = AccountInformation[playerid][CurrentlyWorking];
if(JobInformation[job][JobEndPoint] && !IsPlayerInRangeOfPoint(playerid, 20, JobInformation[job][F_START][0], JobInformation[job][F_START][1], JobInformation[job][F_START][2]))
{
new dist = JobInformation[job][JobDistance];
AccountInformation[playerid][CurrentlyWorking] = -1;
DisablePlayerCheckpoint(playerid);
for(new j = 0; j < MAX_SERVER_JOBS; j ++)
{
if(JobInformation[j][JobLinked] == JobInformation[job][JobLinked]) dist += JobInformation[j][JobDistance];
}
new string[128];
format(string,sizeof(string), "[WORK]: Congratulations you have successfully completed a mission, and you have travelled a total of '%d Metres'", dist);
SendClientMessage(playerid, COLOR_WHITE, string);
} else {
print("No End point for this checkpoint, finding the next location");
new njid = NextMissionStep(playerid, AccountInformation[playerid][CurrentlyWorking]);
if(njid > -1)
{
print("Found the next section, calculating the distance (if needed) and setting the next checkpoint.");
if(!IsPlayerInRangeOfPoint(playerid, 20, JobInformation[job][F_START][0], JobInformation[job][F_START][1], JobInformation[job][F_START][2]))
{
new dist = Distance(JobInformation[job][F_START][0], JobInformation[job][F_START][1], JobInformation[job][F_START][2], JobInformation[job][F_END][0], JobInformation[job][F_END][1], JobInformation[job][F_END][2]);
AccountInformation[playerid][MissionTotalDistance] += dist;
}
DisablePlayerCheckpoint(playerid);
SetPlayerCheckpoint(playerid, JobInformation[njid][F_START][0], JobInformation[njid][F_START][1],JobInformation[njid][F_START][2], 15);
AccountInformation[playerid][CurrentlyWorking] = JobInformation[njid][JobID];
} else {
SendClientMessage(playerid, COLOR_LIGHTRED, "There seems to be an issue with finding the next step in the job, that is either ('The End Point' or 'Next Checkpoint')");
SendClientMessage(playerid, COLOR_LIME, "Your balance has been updated with the total amount of money for the distance you've flown so far!");
}
}
} else {
SendClientMessage(playerid, COLOR_LIGHTRED, "You must finish the mission in the vehicle you started it in");
}
} else {
SendClientMessage(playerid, COLOR_LIGHTRED, "You're not currently doing a mission");
}
}
{
MissionCheckPoint,
}
new PlayerCPInformation[MAX_PLAYERS][PlayerCPInfo];
enum JobInfo
{
JobID,
JobSlotUsed,
JobLinked,
JobDistance,
JobStep,
JobEndPoint,
Float: F_START[3],
Float: F_END[3],
};
new JobInformation[MAX_SERVER_JOBS][JobInfo];
JobInformation[1][F_START][0] = 1.9260,
JobInformation[1][F_START][1] = -41.4742,
JobInformation[1][F_START][2] = 2.0921;
JobInformation[1][F_END][0] = 310.0681,
JobInformation[1][F_END][1] = 2029.8296,
JobInformation[1][F_END][2] = 16.6159;
JobInformation[1][JobID] = 1;
JobInformation[1][JobLinked] = 1;
JobInformation[1][JobStep] = 1;
JobInformation[1][JobEndPoint] = 0;
JobInformation[2][F_START][0] = 1.9260,
JobInformation[2][F_START][1] = -41.4742,
JobInformation[2][F_START][2] = 2.0921;
JobInformation[2][F_END][0] = 310.0681,
JobInformation[2][F_END][1] = 2029.8296,
JobInformation[2][F_END][2] = 16.6159;
JobInformation[2][JobID] = 2;
JobInformation[2][JobLinked] = 1;
JobInformation[2][JobStep] = 2;
JobInformation[2][JobEndPoint] = 0;
JobInformation[3][F_START][0] = 1.9260,
JobInformation[3][F_START][1] = -41.4742,
JobInformation[3][F_START][2] = 2.0921;
JobInformation[3][F_END][0] = 310.0681,
JobInformation[3][F_END][1] = 2029.8296,
JobInformation[3][F_END][2] = 16.6159;
JobInformation[3][JobID] = 3;
JobInformation[3][JobLinked] = 1;
JobInformation[3][JobStep] = 3;
JobInformation[3][JobEndPoint] = 1;
What I noticed is you don't have prints where you actually disable or set the next checkpoint. I would put prints there, because if the print gets called it is a problem with the way you are using the Checkpoints, if they don't get called then their is a problem with either your if statements or your variables.
|