how to next checkpoint
#1

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
PHP код:
CMD:startdriving(playeridparams[])
{
    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(playerid2071.4209,-1913.3623,13.32635.0);
         
SendClientMessage(playeridwarna_biru"mengemudilah dengan hati2 ikuti checkpoint");
     }
     else 
SendClientMessage(playeridwarna_merah"Hanya digunakan di drivingschool");
    return 
1;

Being one checkpoint passes to last
PHP код:
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
Reply
#2

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).
Reply
#3

Quote:
Originally Posted by AndySedeyn
Посмотреть сообщение
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 ?
Reply
#4

PHP код:
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;

Reply
#5

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
PHP код:
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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)