Checkpoint...
#1

pawn Код:
//Checkpoints
new cps1;
new cps2;
new cps3;
new cps4;
new cps5;
new cps6;
new cps7;
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 0)
    {
        if(response == 1)
        {
            MoveObject(drivingschoolramp,  1620.647217, -1008.745483, 21.613716, 1);
            SendClientMessage(playerid, 0xEF994300, "Slijedite checkpointe, pazite da se ne sudarite!");
            cps1 = CreateCheckpoint(playerid, 1546.4567,-1018.0248,23.9063, 2, 500);
        }
    }
    return 1;
}
pawn Код:
public OnPlayerEnterStreamedCheckpoint(playerid, streamid)
{
    if(streamid == cps1)
    {
        cps2 = CreateCheckpoint(playerid, 1558.6582,-1025.8751,23.9063, 2, 500);
        DisablePlayerCheckpoint(playerid);
    }
    if(streamid == cps2)
    {
        cps3 = CreateCheckpoint(playerid, 1572.4071,-1017.6917,23.9140, 2, 500);
        DisablePlayerCheckpoint(playerid);
    }
    if(streamid == cps3)
    {
        cps4 = CreateCheckpoint(playerid, 1578.5472,-1024.1747,23.9063, 2, 500);
        DisablePlayerCheckpoint(playerid);
    }
    if(streamid == cps4)
    {
        cps5 = CreateCheckpoint(playerid, 1584.9760,-1018.5584,23.9063, 2, 500);
        DisablePlayerCheckpoint(playerid);
    }
    if(streamid == cps5)
    {
        cps6 = CreateCheckpoint(playerid, 1592.5760,-1024.9053,23.9063, 2, 500);
        DisablePlayerCheckpoint(playerid);
    }
    return 1;
}
and it shows only 1st(cps1) and last checkpoint(cps6), so when I enter cps1 it shows cps6 why? im using cps streamer
Reply
#2

The problem is simple, you're calling all of the if statements in a row, so it's all happening instantly. This is what I mean:

Player enters checkpoint 1, cps2 is created, check is run again straight away for cps2, and will go through. This will continue all the way down to the last checkpoint.

How can you fix it? Like so:

pawn Код:
public OnPlayerEnterStreamedCheckpoint(playerid, streamid)
{
    if(streamid == cps1)
    {
        cps2 = CreateCheckpoint(playerid, 1558.6582,-1025.8751,23.9063, 2, 500);
        DisablePlayerCheckpoint(playerid);
    }
    else if(streamid == cps2)
    {
        cps3 = CreateCheckpoint(playerid, 1572.4071,-1017.6917,23.9140, 2, 500);
        DisablePlayerCheckpoint(playerid);
    }
    else if(streamid == cps3)
    {
        cps4 = CreateCheckpoint(playerid, 1578.5472,-1024.1747,23.9063, 2, 500);
        DisablePlayerCheckpoint(playerid);
    }
    else if(streamid == cps4)
    {
        cps5 = CreateCheckpoint(playerid, 1584.9760,-1018.5584,23.9063, 2, 500);
        DisablePlayerCheckpoint(playerid);
    }
    else if(streamid == cps5)
    {
        cps6 = CreateCheckpoint(playerid, 1592.5760,-1024.9053,23.9063, 2, 500);
        DisablePlayerCheckpoint(playerid);
    }
    return 1;
}
Note: You should also have DisablePlayerCheckpoint before creating a new one.
Reply
#3

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
The problem is simple, you're calling all of the if statements in a row, so it's all happening instantly. This is what I mean:

Player enters checkpoint 1, cps2 is created, check is run again straight away for cps2, and will go through. This will continue all the way down to the last checkpoint.

How can you fix it? Like so:

pawn Код:
public OnPlayerEnterStreamedCheckpoint(playerid, streamid)
{
    if(streamid == cps1)
    {
        cps2 = CreateCheckpoint(playerid, 1558.6582,-1025.8751,23.9063, 2, 500);
        DisablePlayerCheckpoint(playerid);
    }
    else if(streamid == cps2)
    {
        cps3 = CreateCheckpoint(playerid, 1572.4071,-1017.6917,23.9140, 2, 500);
        DisablePlayerCheckpoint(playerid);
    }
    else if(streamid == cps3)
    {
        cps4 = CreateCheckpoint(playerid, 1578.5472,-1024.1747,23.9063, 2, 500);
        DisablePlayerCheckpoint(playerid);
    }
    else if(streamid == cps4)
    {
        cps5 = CreateCheckpoint(playerid, 1584.9760,-1018.5584,23.9063, 2, 500);
        DisablePlayerCheckpoint(playerid);
    }
    else if(streamid == cps5)
    {
        cps6 = CreateCheckpoint(playerid, 1592.5760,-1024.9053,23.9063, 2, 500);
        DisablePlayerCheckpoint(playerid);
    }
    return 1;
}
Note: You should also have DisablePlayerCheckpoint before creating a new one.
TY it works!
yes I had disable 1st but i though it can make difference lol
its ok now
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)