Checkpoints are skipped
#1

Hi there, I have a problem. The first checkpoint in my array is skipped,
Because this happens, The drivers license at the end will never be given because CarTest[playerid] will always be one smaller then CarLic

pawn Код:
new Float:CarLic[][3] =
{
    {1959.1808,-2109.0481,13.2653},
    {2100.1204,-2112.4785,13.1946},
    {2193.5034,-2164.3613,13.2731},
    {2284.0278,-2082.4016,13.2631},
    {2215.7712,-1975.9647,13.2728},
    {2315.8411,-1973.9744,13.2587},
    {2316.5715,-1895.9763,13.2635},
    {2208.7671,-1892.5656,13.4172},
    {2083.0229,-1892.0494,13.2646},
    {2075.4966,-1929.6680,13.2180},
    {1966.5492,-1930.8490,13.2651},
    {1969.3895,-1990.7878,13.4302}
};
CMD:taketest(playerid, params[])
{
    if(PlayerInfo[playerid][Carlic] == 0)
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
            if(vteam[GetPlayerVehicleID(playerid)] == 59)
            {
                if(PlayerInfo[playerid][Cash] < 500) return SCM(playerid, COLOR_GREY, "You don't have enough money!");
                if(isonlic[playerid] != -1) return SCM(playerid, COLOR_GREY, "You are already on a test!");
                SetPlayerCheckpoint(playerid, 1962.4423,-1991.0620,13.2692, 9.0);
                GivePlayerCash(playerid, -500);
                TogglePlayerControllable(playerid, 1);
                SendClientMessage(playerid, COLOR_GREEN, "Drive carefully, The maximum speed at this road is 60km/h.");
                isonlic[playerid] = 1;
                CarTest[playerid] = 1;
                return 1;
            }
            else return SCM(playerid, COLOR_GREY,"This is not a license test car!");
        }
        else return SCM(playerid, COLOR_GREY, "You are not in a vehicle!");
    }
    else return SCM(playerid, COLOR_GREY, "You already have your driving license!");
}

OnPlayerEnterCheckpoint

pawn Код:
if(CarTest[playerid] != -1)
    {
        new Float:h;
        new vehicleid = GetPlayerVehicleID(playerid);
        GetVehicleHealth(GetPlayerVehicleID(playerid), h);
        if(h > 900)
        {
            if(CarTest[playerid] < sizeof(CarLic))
            {
                CarTest[playerid]++;
                SetPlayerCheckpoint(playerid, CarLic[CarTest[playerid]][0], CarLic[CarTest[playerid]][1], CarLic[CarTest[playerid]][2], 10.0);
            }
            else
            {
                SendClientMessage(playerid, 0x999999AA, "You earned your Driving license! Good job!");
                DisablePlayerCheckpoint(playerid);
                CarTest[playerid] = -1;
                isonlic[playerid] = -1;
                PlayerInfo[playerid][Carlic] = 1;
                SendClientMessage(playerid, COLOR_GREEN, "Congratulations! you can now buy a vehicle and drive a car legally!");
                SetVehicleToRespawn(GetPlayerVehicleID(playerid));
            }
        }
        else
        {
            TogglePlayerControllable(playerid, 0);
            SendClientMessage(playerid, 0x999999AA, "You failed your test because you got too much damage! Use /exitcar to leave the vehicle!");
            GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
            SetVehicleParamsEx(vehicleid,false,lights,alarm,doors,bonnet,boot,objective);
            carengine[vehicleid] = 0;
            isonlic[playerid] = -1;
            CarTest[playerid] = -1;
            DisablePlayerCheckpoint(playerid);
        }
    }
Reply
#2

Add a dummy location Like
pawn Код:
{0.0, 0.0, 0.0},
Reply
#3

But will that fix the problem of CarTest[playerid] never becoming the same size as CarLic?
Reply
#4

Setting this to 0 in your command will work, I think. Array indices always start at 0, not 1.
pawn Код:
CarTest[playerid] = 1;
Reply
#5

I guess so since then it just doesnt read the dummy wich isnt important... so it will count the right amount i guess
Reply
#6

Quote:
Originally Posted by Vince
Посмотреть сообщение
Setting this to 0 in your command will work, I think. Array indices always start at 0, not 1.
pawn Код:
CarTest[playerid] = 1;
Awesome vince! Will test it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)