PDA

View Full Version : how to next checkpoint


Jihanz
26/03/2017, 06:00 AM
can you help me why every time I step on the first checkpoint I definitely get the final checkpoint ....

whereas there I make it uniform


first checkpoint
CMD:startdriving(playerid, params[])
{
if(TelahLogin[playerid] == 0) return SendClientMessage(playerid,warna_merah,"Kamu belum login");
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,COLOR_LIGHTBLUE,"Kamu tidak bisa menggunakan command ini di dalam kendaraan");
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 458) {
cpd[playerid] = 1;
SetPlayerCheckpoint(playerid, 2071.4209,-1913.3623,13.3263, 5.0);
SendClientMessage(playerid, warna_biru, "mengemudilah dengan hati2 ikuti checkpoint");
}
else SendClientMessage(playerid, warna_merah, "Hanya digunakan di drivingschool");
return 1;
}
Being one checkpoint passes to last
if(cpd[playerid] == 1){
cpd[playerid] = 2;
SetPlayerCheckpoint(playerid,2081.1523,-1831.5197,13.1621,5.0);
}
if(cpd[playerid] == 2){
SetPlayerCheckpoint(playerid,2108.8325,-1753.1776,13.1821,5.0);
cpd[playerid] = 3;
}

Thanks Before

AndySedeyn
26/03/2017, 06:04 AM
Make use of else if statements rather than just if statements. By the time your code reaches the second if statement, the value of cpd has already been set to 2 (in the preceding if statement).

Jihanz
26/03/2017, 06:12 AM
Make use of else if statements rather than just if statements. By the time your code reaches the second if statement, the value of cpd has already been set to 2 (in the preceding if statement).

can you give me example ?

AndySedeyn
26/03/2017, 06:20 AM
if(cpd[playerid] == 1){
cpd[playerid] = 2;
SetPlayerCheckpoint(playerid,2081.1523,-1831.5197,13.1621,5.0);
}
else if(cpd[playerid] == 2){
SetPlayerCheckpoint(playerid,2108.8325,-1753.1776,13.1821,5.0);
cpd[playerid] = 3;
}

coool
26/03/2017, 06:34 AM
Hehe the same problem was with me when player enters the 1st checkpoint you declare cpd[playerid] = 2;
And below it you check for cpd[playerid] = 2
if(cpd[playerid] == 1){
cpd[playerid] = 2; //cpd now is 2
SetPlayerCheckpoint(playerid,2081.1523,-1831.5197,13.1621,5.0);
}
if(cpd[playerid] == 2) //Here you check for cpd 2 and you have increased it already. And it will keep contiuing until the last one
{
SetPlayerCheckpoint(playerid,2108.8325,-1753.1776,13.1821,5.0);
cpd[playerid] = 3;
}
Solution: Start not in ascending but descending order. The if and else if will also work.