Checkpoint help
#1

Hello guys.
Im makeing a train driver job, where the driver has to drive between checkpoints. (Using Incognito's streamer).
I made a /drive command, that will set the checkpoints if the player is inside the train.
I did like this:
pawn Код:
new traincp[5];
new ptraincp[MAX_PLAYERS];
pawn Код:
COMMAND:drive(playerid, params[])
{
    if(PlayerInfo[playerid][pJob] == 2)
    {
        if(IsPlayerInVehicle(playerid, psdrivervehicles[0]))
        {
            SendClientMessage(playerid, COLOR_YELLOW, "( ! ) Train Driver Job started");
            SendClientMessage(playerid, COLOR_YELLOW, "( ! ) Go to the Checkpoint");
            traincp[0] = CreateDynamicRaceCP(1, 1772.4253,-1953.9143,13.5469, 2864.7729,1328.5391,10.8203, 4.0, 0, 0, playerid, 100.0);
        }
        else SendClientMessage(playerid, COLOR_NORMALRED, "( ! ) You must be in the Train or a Bus to drive");
    }
    else return 0;
    return 1;
}
pawn Код:
public OnPlayerEnterDynamicRaceCP(playerid, checkpointid)
{
    if(checkpointid == traincp[0])
    {
        ptraincp[playerid] = 1;
        SendClientMessage(playerid, COLOR_YELLOW, "( ! ) Changing Passengers. Please wait...");
        SetTimerEx("TrainCPS", 7000, false, "d", playerid);
    }
    if(checkpointid == traincp[1])
    {
        ptraincp[playerid] = 2;
        SendClientMessage(playerid, COLOR_YELLOW, "( ! ) Changing Passengers. Please wait...");
        SetTimerEx("TrainCPS", 7000, false, "d", playerid);
    }
    if(checkpointid == traincp[2])
    {
        ptraincp[playerid] = 3;
        SendClientMessage(playerid, COLOR_YELLOW, "( ! ) Changing Passengers. Please wait...");
        SetTimerEx("TrainCPS", 7000, false, "d", playerid);
    }
    if(checkpointid == traincp[3])
    {
        ptraincp[playerid] = 4;
        SendClientMessage(playerid, COLOR_YELLOW, "( ! ) Changing Passengers. Please wait...");
        SetTimerEx("TrainCPS", 7000, false, "d", playerid);
    }
    if(checkpointid == traincp[4])
    {
        ptraincp[playerid] = 5;
        SendClientMessage(playerid, COLOR_YELLOW, "( ! ) Changing Passengers. Please wait...");
        SetTimerEx("TrainCPS", 7000, false, "d", playerid);
    }
    return 1;
}
pawn Код:
forward TrainCPS(playerid);
public TrainCPS(playerid)
{
    if(ptraincp[playerid] == 1)
    {
        SendClientMessage(playerid, COLOR_YELLOW, "( ! ) Drive to the next Station");
        SendClientMessage(playerid, COLOR_YELLOW, "( ! ) ServerMoney +2");
        DestroyDynamicRaceCP(traincp[0]);
        PlayerInfo[playerid][pMoney] += 2;
        PlayerPlaySound(playerid, 1138, 0, 0, 0);
        SaveUserData(playerid);
        traincp[1] = CreateDynamicRaceCP(1, 2864.7729,1328.5391,10.8203, 1395.0898,2632.3098,10.8203, 4.0, 0, 0, playerid, 100.0);
    }
    if(ptraincp[playerid] == 2)
    {
        SendClientMessage(playerid, COLOR_YELLOW, "( ! ) Drive to the next Station");
        SendClientMessage(playerid, COLOR_YELLOW, "( ! ) ServerMoney +2");
        DestroyDynamicRaceCP(traincp[1]);
        PlayerInfo[playerid][pMoney] += 2;
        PlayerPlaySound(playerid, 1138, 0, 0, 0);
        SaveUserData(playerid);
        traincp[2] = CreateDynamicRaceCP(1, 1395.0898,2632.3098,10.8203, -1944.3983,95.3343,25.7186, 4.0, 0, 0, playerid, 100.0);
    }
    if(ptraincp[playerid] == 3)
    {
        SendClientMessage(playerid, COLOR_YELLOW, "( ! ) Drive to the next Station");
        SendClientMessage(playerid, COLOR_YELLOW, "( ! ) ServerMoney +2");
        DestroyDynamicRaceCP(traincp[2]);
        PlayerInfo[playerid][pMoney] += 2;
        PlayerPlaySound(playerid, 1138, 0, 0, 0);
        SaveUserData(playerid);
        traincp[3] = CreateDynamicRaceCP(1, -1944.3983,95.3343,25.7186, 840.6030,-1390.3347,-1.6173, 4.0, 0, 0, playerid, 100.0);
    }
    if(ptraincp[playerid] == 4)
    {
        SendClientMessage(playerid, COLOR_YELLOW, "( ! ) Drive to the next Station");
        SendClientMessage(playerid, COLOR_YELLOW, "( ! ) ServerMoney +2");
        DestroyDynamicRaceCP(traincp[3]);
        PlayerInfo[playerid][pMoney] += 2;
        PlayerPlaySound(playerid, 1138, 0, 0, 0);
        SaveUserData(playerid);
        traincp[4] = CreateDynamicRaceCP(1, 840.6030,-1390.3347,-1.6173, 1772.4253,-1953.9143,13.5469, 4.0, 0, 0, playerid, 100.0);
    }
    if(ptraincp[playerid] == 5)
    {
        SendClientMessage(playerid, COLOR_YELLOW, "( ! ) Train driver Job completed");
        DestroyDynamicRaceCP(traincp[4]);
        DestroyDynamicRaceCP(traincp[0]);
        PlayerInfo[playerid][pMoney] += 2;
        PlayerPlaySound(playerid, 1138, 0, 0, 0);
        SaveUserData(playerid);
    }
    return 1;
}
But it doesnt work exacteley.
Hope you can help me a bit. Thanks.
Reply
#2

so what exactly seems to be the problem sir?
Reply
#3

Only the first checkpoint appears
Reply
#4

maybe you need to write else between the cp.
Reply
#5

Use else if after the first if.
Reply
#6

try this
pawn Код:
COMMAND:drive(playerid, params[])
{
    if(PlayerInfo[playerid][pJob] == 2)
    {
        if(IsPlayerInVehicle(playerid, psdrivervehicles[0]))
        {
            ptraincp[playerid] = 0;
            SendClientMessage(playerid, COLOR_YELLOW, "( ! ) Train Driver Job started");
            SendClientMessage(playerid, COLOR_YELLOW, "( ! ) Go to the Checkpoint");
            traincp[0] = CreateDynamicRaceCP(1, 1772.4253,-1953.9143,13.5469, 2864.7729,1328.5391,10.8203, 4.0, 0, 0, playerid, 100.0);
        }
        else SendClientMessage(playerid, COLOR_NORMALRED, "( ! ) You must be in the Train or a Bus to drive");
    }
    else return 0;
    return 1;
}

public OnPlayerEnterDynamicRaceCP(playerid, checkpointid)
{
    if(checkpointid == traincp[0])
    {
        ptraincp[playerid] ++;
        SendClientMessage(playerid, COLOR_YELLOW, "( ! ) Changing Passengers. Please wait...");
        SetTimerEx("TrainCPS", 7000, false, "ii", playerid, ptraincp[playerid]);
    }
    return 1;
}

forward TrainCPS(playerid, id);
public TrainCPS(playerid, id)
{
    switch(id)
    {
        case 1:
        {
            DestroyDynamicRaceCP(traincp[0]);
            traincp[0] = CreateDynamicRaceCP(1, 2864.7729,1328.5391,10.8203, 1395.0898,2632.3098,10.8203, 4.0, 0, 0, playerid, 100.0);
        }
        case 2:
        {
            DestroyDynamicRaceCP(traincp[0]);
            traincp[0] = CreateDynamicRaceCP(1, 1395.0898,2632.3098,10.8203, -1944.3983,95.3343,25.7186, 4.0, 0, 0, playerid, 100.0);
        }
        case 3:
        {
            DestroyDynamicRaceCP(traincp[0]);
            traincp[0] = CreateDynamicRaceCP(1, -1944.3983,95.3343,25.7186, 840.6030,-1390.3347,-1.6173, 4.0, 0, 0, playerid, 100.0);
        }
        case 4:
        {
            DestroyDynamicRaceCP(traincp[0]);
            traincp[0] = CreateDynamicRaceCP(1, 840.6030,-1390.3347,-1.6173, 1772.4253,-1953.9143,13.5469, 4.0, 0, 0, playerid, 100.0);
        }
        case 5:
        {
            SendClientMessage(playerid, COLOR_YELLOW, "( ! ) Train driver Job completed");
            DestroyDynamicRaceCP(traincp[0]);
            ptraincp[playerid] = 0;
        }
    }
    if( id < 5) SendClientMessage(playerid, COLOR_YELLOW, "( ! ) Drive to the next Station");
    SendClientMessage(playerid, COLOR_YELLOW, "( ! ) ServerMoney +2");
    PlayerInfo[playerid][pMoney] += 2;
    PlayerPlaySound(playerid, 1138, 0, 0, 0);
    SaveUserData(playerid);
    return 1;
}
Reply
#7

I got a tutorial about this, check my signature if you still need help
Reply
#8

Thank you for the help everyone
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)