Can't get Dynamic Checkpoint to work correctly, not creating new ID.
#1

pawn Код:
if(checkpointid == DrivingCheck[playerid][0])
    {
        printf("CALLED CHECK 0, %d", DrivingCheck[playerid][0]);
        RemovePlayerMapIcon(playerid, 0);
        SendClientMessage(playerid, COLOUR_ORANGE, "Please proceed ahead and REVERSE park in the highlighted bay (checkpoint). Mind your speed and obstacles.");
        SendClientMessage(playerid, COLOUR_RED, "You must reverse park or the test will not continue, you must park parallel to the other vehicles");
        DrivingCheck[playerid][1] = CreateDynamicCP(-2065.4126,-164.0089,35.2117, 2, GetPlayerVirtualWorld(playerid), 0, playerid, 100.0);
        SetPlayerMapIcon(playerid, 0, -2065.4126,-164.0089,35.2117, 0, COLOUR_RED, MAPICON_LOCAL);
        DestroyDynamicCP(DrivingCheck[playerid][0]);
    }
    else if(checkpointid == DrivingCheck[playerid][1])
    {
            printf("CALLED CHECK 0, %d", DrivingCheck[playerid][1]);
        //new vehicleid = GetPlayerVehicleID(playerid), Float: angle;
        //GetVehicleZAngle(vehicleid, angle);
        //new newangle = floatround(angle);
        //if(newangle == 267 ||newangle == 268 || newangle == 269 || newangle == 270 || newangle == 271 || newangle == 272 || newangle == 273 || newangle == 274)
        //{
        RemovePlayerMapIcon(playerid, 0);
        SendClientMessage(playerid, COLOUR_ORANGE, "Well Done! You completed the reverse bay park!");
        SendClientMessage(playerid, COLOUR_ORANGE, "Please proceed ahead to the next checkpoint at the car park exit. Mind your speed and obstacles.");
        DrivingCheck[playerid][2] = CreateDynamicCP(-2035.7332,-167.8290,35.1569, 2, GetPlayerVirtualWorld(playerid), 0, playerid, 100.0);
        SetPlayerMapIcon(playerid, 0, -2035.7332,-167.8290,35.1569, 0, COLOUR_RED, MAPICON_LOCAL);
        DestroyDynamicCP(DrivingCheck[playerid][1]);
        //}
        /*else
        {
            SendClientMessage(playerid, COLOUR_RED, "Please attempt the reverse park again (exit and enter the checkpoint at correct angle).");
        }
        */

    }
    else if(checkpointid == DrivingCheck[playerid][2])
    {
        RemovePlayerMapIcon(playerid, 0);
        SendClientMessage(playerid, COLOUR_ORANGE, "Independent Driving Module.");
        SendClientMessage(playerid, COLOUR_ORANGE, "Please proceed ahead to the next checkpoint at the end of the street. Mind your speed and obstacles.");
        SendClientMessage(playerid, COLOUR_RED, "Be very aware of obstacles on the road, damage to the vehicle may cause you to fail your test.");
        DrivingCheck[playerid][3] = CreateDynamicCP(-2050.1340,-260.8407,35.0739, 2, GetPlayerVirtualWorld(playerid), 0, playerid, 100.0);
        SetPlayerMapIcon(playerid, 0, -2050.1340,-260.8407,35.0739, 0, COLOUR_RED, MAPICON_LOCAL);
        DestroyDynamicCP(DrivingCheck[playerid][2]);
    }
    else if(checkpointid == DrivingCheck[playerid][3])
    {
        RemovePlayerMapIcon(playerid, 0);
        SendClientMessage(playerid, COLOUR_ORANGE, "Urban area driving and parking.");
        SendClientMessage(playerid, COLOUR_ORANGE, "Please proceed ahead to the next checkpoint at the end of the street on the right and park your vehicle.");
        SendClientMessage(playerid, COLOUR_RED, "You do not have to park the vehicle at any certain angle, just as long as you enter the bay (Checkpoint) and turn around.");
        SendClientMessage(playerid, COLOUR_RED, "Be extremely aware of obstacles on the road, damage to the vehicle may cause you to fail your test.");
        DrivingCheck[playerid][4] = CreateDynamicCP(-2044.6074,-205.7463,35.0555, 2, GetPlayerVirtualWorld(playerid), 0, playerid, 100.0);
        SetPlayerMapIcon(playerid, 0, -2044.6074,-205.7463,35.0555, 0, COLOUR_RED, MAPICON_LOCAL);
        DestroyDynamicCP(DrivingCheck[playerid][3]);
    }
    else if(checkpointid == DrivingCheck[playerid][4])
    {
        RemovePlayerMapIcon(playerid, 0);
        SendClientMessage(playerid, COLOUR_ORANGE, "For the final part of you test, continue out of the garage following the road to the two trucks on the side of the street.");
        SendClientMessage(playerid, COLOUR_RED, "Please park the vehicle between the two trucks, you must park at a reasonable angle so as to not block traffic.");
        SendClientMessage(playerid, COLOUR_RED, "Be extremely aware of obstacles on the road, damage to the vehicle may cause you to fail your test.");
        DrivingCheck[playerid][5] = CreateDynamicCP(-2027.6936,-233.1335,35.1566, 2, GetPlayerVirtualWorld(playerid), 0, playerid, 100.0);
        SetPlayerMapIcon(playerid, 0, -2027.6936,-233.1335,35.1566, 0, COLOUR_RED, MAPICON_LOCAL);
        DestroyDynamicCP(DrivingCheck[playerid][4]);
    }
    else if(checkpointid == DrivingCheck[playerid][5])
    {
        new vehicleid = GetPlayerVehicleID(playerid), Float: angle;
        GetVehicleZAngle(vehicleid, angle);
        new newangle = floatround(angle);
        if(newangle == 356 ||newangle == 357 || newangle == 358 || newangle == 359 || newangle == 360 || newangle == 361 || newangle == 362)
        {
            RemovePlayerMapIcon(playerid, 0);
            SendClientMessage(playerid, COLOUR_ORANGE, "Well Done! You completed the parallel park!");
            SendClientMessage(playerid, COLOUR_ORANGE, "To complete your test, please proceed to the last checkpoint on your map to receieve your results. Mind your speed and obstacles.");
            DrivingCheck[playerid][6] = CreateDynamicCP(-2024.5856,-126.0978,35.1566, 2, GetPlayerVirtualWorld(playerid), 0, playerid, 100.0);
            SetPlayerMapIcon(playerid, 0, -2024.5856,-126.0978,35.1566, 0, COLOUR_RED, MAPICON_LOCAL);
            DestroyDynamicCP(DrivingCheck[playerid][5]);
        }
        /*else
        {
            SendClientMessage(playerid, COLOUR_RED, "Please attempt the parallel park again (exit and enter the checkpoint at correct angle).");
        }
        */

    }
    else if(checkpointid == DrivingCheck[playerid][6])
    {
        new string[128], reason[64], Float: health;
        DestroyDynamicCP(DrivingCheck[playerid][6]);
        RemovePlayerMapIcon(playerid, 0);
        RemovePlayerFromVehicle(playerid);
        SetPlayerPos(playerid, -2033.55774, -117.38980, 1034.62805);
        SetPlayerVirtualWorld(playerid, 0);
        SetPlayerInterior(playerid, 3);
        TakingTest[playerid] = 0;
        if(GetVehicleHealth(testcar[playerid], health) < 950)
        {
            TestFailed[playerid] = 1;
            format(reason, sizeof(reason), "Test vehicle damaged significantly.");
        }
        if(TestSpeed[playerid] > 30)
        {
            TestFailed[playerid] = 1;
            format(reason, sizeof(reason), "Excessive speed: %d MPH - LIMIT 30 MPH.", TestSpeed[playerid]);
            TestSpeed[playerid] = 0;
        }
        if(TestTimeTaken[playerid] > 360000)
        {
            TestFailed[playerid] = 1;
            format(reason, sizeof(reason), "Exceeded reasonable time of completion - LIMIT: 6 minutes - Your Time: %d minutes", TestTimeTaken[playerid]);
            TestTimeTaken[playerid] = 0;
        }
        switch(TestFailed[playerid])
        {
            case 0:
            {
                SendClientMessage(playerid, COLOUR_GREEN, "_________Driving Test Results_________");
                format(string, sizeof(string), "Driving Test "COL_GREEN"PASSED.");
                SendClientMessage(playerid, COLOUR_WHITE, string);
                SendClientMessage(playerid, COLOUR_ORANGE, "Congratulations! You are now the holder of a driving license, good luck!");
                SendClientMessage(playerid, COLOUR_GREEN, "________________________________________");
                GameTextForPlayer(playerid, "~g~DRIVING TEST PASSED", 3000, 1);
            }
            case 1:
            {
                SendClientMessage(playerid, COLOUR_GREEN, "_________Driving Test Results_________");
                format(string, sizeof(string), "Driving Test "COL_RED"FAILED.");
                SendClientMessage(playerid, COLOUR_WHITE, string);
                format(string, sizeof(string), "Reason for failure: "COL_RED"%s", reason);
                SendClientMessage(playerid, COLOUR_WHITE, string);
                SendClientMessage(playerid, COLOUR_WHITE, "Please consider your reason for failing and try again when you are prepared.");
                SendClientMessage(playerid, COLOUR_GREEN, "________________________________________");
                GameTextForPlayer(playerid, "~r~DRIVING TEST FAILED", 3000, 1);

            }
        }

    }
To explain, the first three checkpoints work perfectly but the third checkpoint just sets it back to the DrivingCheck[playerid][1] again. It's very confusing, could anyone help me out?
Reply
#2

Sorry Dokins, missed this last night. What it actually may be is that, when you enter the code block for the appropriate checkpoint (such as DrivingCheck[playerid][1]), you never actually reassign (or reset) that variable to 0 so theres always a chance the checkpointid could equal each of your variables.

What happens when you reset each DrivingCheck[playerid][0.. X] to -1 or 0 after you destroy them?

So like:
pawn Код:
DestroyCP(playerid, DrivingCheck[playerid][1]);
DrivingCheck[playerid][1] = 0;
Reply
#3

This is why you use enums instead of arbitrary array index references in your code.
Reply
#4

Although I'd love to know what that means, I don't, Pottus and I'm sure you worded it like that to probably make yourself sound smart and me sound dumb, if you could kindly explain that in layman's terms that would help.

Also, Jason, I've actually fixed the issue with toggling the checkpoints. It's confused because the ID's all equal the same and I'll just destroy them afterwards.

Thank you for all your help and support
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)