Help with Race Checkpoints
#1

Hi, so I need some help with race checkpoints.

on top of the script:
pawn Код:
new dcp[MAX_PLAYERS][10];
Creating first checkpoint:
pawn Код:
dcp[playerid][0] = SetPlayerRaceCheckpoint(PlayerThatInvited, 0, 2720.0857, -2405.7524, 13.4609, 2345.2678, -2662.7524, 13.5229, 4);
The callback:
pawn Код:
public OnPlayerEnterRaceCheckpoint(playerid)
{
    // Track #1
    // 2720.0857,-2405.7524,13.4609 Start
    // 2345.2678,-2662.7524,13.5229 2nd
    // 2391.4956,-2407.0464,13.3803 3rd
    // 2719.8816,-2405.5457,13.4609 Finish
   
    // Track #2
    if(dcp[playerid][0])
    {
        dcp[playerid][0] = -1;
        dcp[playerid][1] = SetPlayerRaceCheckpoint(playerid, 0, 2345.2678, -2662.7524, 13.5229, 2391.4956, -2407.0464, 13.3803, 4);
    }
    if(dcp[playerid][1])
    {
        dcp[playerid][1] = -1;
        dcp[playerid][2] = SetPlayerRaceCheckpoint(playerid, 0, 2391.4956,-2407.0464,13.3803, 2719.8816,-2405.5457,13.4609, 4);
    }
    if(dcp[playerid][2])
    {
        dcp[playerid][2] = -1;
        dcp[playerid][3] = SetPlayerRaceCheckpoint(playerid, 0, 2719.8816,-2405.5457,13.4609, 2719.8816,-2405.5457,13.4609, 4);
    }
    if(dcp[playerid][3])
    {
        dcp[playerid][3] = -1;
        DisablePlayerRaceCheckpoint(playerid);
        SendClientMessageToAll(-1, "Someone finished duel track one");
        cmd_dueloff(playerid);
    }
    return 1;
}
The problem is that when i enter the first checkpoint - the server thinks I entered the last checkpoint and writes "Someone finished duel track one"
Reply
#2

EDIT.. Solved it:

pawn Код:
public OnPlayerEnterRaceCheckpoint(playerid)
{
    // Track #1
    // 2720.0857,-2405.7524,13.4609 Start
    // 2345.2678,-2662.7524,13.5229 2nd
    // 2391.4956,-2407.0464,13.3803 3rd
    // 2719.8816,-2405.5457,13.4609 Finish
    switch(ReachedCP[playerid])
    {
        case 1:
        {
            ReachedCP[playerid]++;
            SetPlayerRaceCheckpoint(playerid, 0, 2345.2678, -2662.7524, 13.5229, 2391.4956, -2407.0464, 13.3803, 4);
        }
        case 2:
        {
            ReachedCP[playerid]++;
            SetPlayerRaceCheckpoint(playerid, 0, 2391.4956,-2407.0464,13.3803, 2719.8816,-2405.5457,13.4609, 4);
           
        }
        case 3:
        {
            ReachedCP[playerid]++;
            SetPlayerRaceCheckpoint(playerid, 0, 2719.8816,-2405.5457,13.4609, 2719.8816,-2405.5457,13.4609, 4);
        }
        case 4:
        {
            ReachedCP[playerid] = 0;
            DisablePlayerRaceCheckpoint(playerid);

            new pname[32], string[128];
            GetPlayerName(playerid, pname, sizeof(pname));
           
            format(string, sizeof(string), "[DUEL] {FFA500}%s {FFFFFF}has finished duel in {FFA500}%i", pname);
           
            SendClientMessageToAll(COLOR_YELLOW, string);
            cmd_dueloff(playerid);
        }
    }
    return 1;
}
Mode's can delete this thread or lock it!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)