Dynamic checkpoints not working properly.
#1

So I've tried to make it so when you enter the first dynamic cp another will appear at a different location - but it didn't work. So I tried to add a timer to "debug" it, so to speak. Adding the timer successfully made the second checkpoint move to the correct position, but upon entering it the original timer i created will repeat and therefor respawn the checkpoint. (No, the timer doesn't loop. It is only called once.)

Relevant code below.

pawn Код:
new cp_truckerjob;
new cp_tdelivery;

stock TruckerRandomCP(playerid) //This is the stock that creates the first "Random checkpoint"
{
    new rand = random(2);
    switch(rand)
    {
        case 0:
        {
            cp_truckerjob = CreateDynamicCP(663.7012,-547.2297,16.1418, 3.0, -1, -1, playerid, 50000);
        }
        case 1:
        {
            cp_truckerjob = CreateDynamicCP(1341.0321,332.4201,19.8278, 3.0, -1, -1, playerid, 50000);
        }
        case 2:
        {
            cp_truckerjob = CreateDynamicCP(2319.1831,-93.5659,26.2110, 3.0, -1, -1, playerid, 50000);
        }
    }
}



//This is when they enter the checkpoints.
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
    if(checkpointid == cp_truckerjob)
    {
        new string[128];
        for(new i = 0; i < MAX_VEHICLES; i++)
        {
            if(IsTrailerAttachedToVehicle(TruckerJobVehicle[i]))
            {
                if(IsPlayerInVehicle(playerid, TruckerJobVehicle[i]))
                {
                    DestroyDynamicCP(cp_truckerjob);
                    tamount[playerid] = tJob[tLoadAmount] *2;
                    format(string,sizeof(string), "You have earned %d$ for your packages. Deliver the truck back to the depot to collect your pay.", tamount[playerid]);
                    SCM(playerid,COLOR_GREEN, string);
                    tJob[tLoaded] = 0;
                    tJob[tLoadAmount] = 0; ///unload the truck
                    TIMER_TDELIVERY[playerid] = SetTimerEx("tDeliveryTimer", 4000, false, "i", playerid);
                    break;
                }
                if(i == MAX_VEHICLES - 1)
                {
                    SCM(pid,COLOR_GREY, "[ERROR]: You're not in a Semi Truck.");
                }
            }
            if(i == MAX_VEHICLES - 1)
            {
                SCM(pid,COLOR_GREY, "[ERROR]: You need a trailer attached to a semi truck.");
            }
        }
    }
    if(checkpointid == cp_tdelivery)
    {
        DestroyDynamicCP(cp_tdelivery);
        SCM(playerid,COLOR_GREEN, "Truck returned and payment collected.");
        tJob[tDeliverFinished] = 1;
        GivePlayerMoney(playerid, tamount[playerid]);
        tamount[playerid] = 0; //resetting it.
    }
}
Thanks for any help.
Reply


Messages In This Thread
Dynamic checkpoints not working properly. - by rangerxxll - 01.06.2014, 03:59
Re: Dynamic checkpoints not working properly. - by RajatPawar - 01.06.2014, 04:05
Re: Dynamic checkpoints not working properly. - by rangerxxll - 01.06.2014, 04:07

Forum Jump:


Users browsing this thread: 2 Guest(s)