Dynamic Checkpoints - Using the same ID?
#1

Hello. I'm having an issue with dynamic checkpoints. The issue is when I enter a specific checkpoint, it does what it's suppose too AND it does what the previous CP ID is suppose too. It's a bit strange. Its like using both CP ID's at once.

I've assigned variables to each, so I'm not too sure why they aren't working. Is there a bug I should be aware of? I read over my code a dozen times and no CP variables were misplaced, at all. What could be causing this?

If you need more code, let me know. I'll post what happens when they ENTER the checkpoint.

pawn Код:
if(checkpointid == mCP[playerid])
    {
        if(pJob[playerid][mMailStock] > 0 ) return SCM(pid,COLOR_GREY, "[ERROR]: You're already loaded with stock.");
        TIMER_MAILMANSTOCK = SetTimerEx("MailManStockTimer", 7000, false, "i", playerid);
        new string[128];
        format(string,sizeof(string), "*%s waits as the mail men deliver the stock into his truck*", GetName(playerid));
        SCM(playerid,COLOR_GREEN, "{FFFFFF}[Job]: {0E7A04}Please wait while your stock is loaded into your truck.");
        SendLocalClientMessage(30.0, COLOR_ME, playerid, string);
        TogglePlayerControllable(pid, false);
    }
    if(checkpointid == mCPDeliver[playerid])
    {
        if(pJob[playerid][mMailStock] < 1)
        {
            SCM(pid,COLOR_RED, "You're out of stock. Reload at the mail man job location.");
            DestroyDynamicCP(mCPDeliver[playerid]);
            return 1;
        }
        if(IsPlayerInAnyVehicle(playerid))
        {
            SCM(pid,COLOR_GREY, "[ERROR]: You need to be on foot to deliver mail.");
            return 1;
        }
        pJob[playerid][mMailStock] --;
        CreateMailCP(playerid);
        new string[128];
        format(string,sizeof(string), "Remaining stock: %d", pJob[playerid][mMailStock]);
        SCM(pid, COLOR_GREY, string);
    }
    return 1;
Thanks for any help.
Reply
#2

I've tried debugging it and it seems to want to call the cp ID mCP (which is the first one.) when mCPDeliver (the second.) should be called. I even printed it out in the console to attempt to find this bug. I've checked my code countless times and I'm not misplacing any variables.

Reply
#3

I had a similar problem the other day and it was because the var holding the checkpoint ID was not being reset, hence when the OnPlayerEnterDynamicCP was being called it both of the var's had the same CP ID assigned to it.

I simply added DestroyDynamicCP(mCPDeliver[playerid]); mCPDeliver[playerid] = -1; whenever destroying a CP which means the checkpoint ID that use to exist doesn't anymore.

It may not be the solution to your problem but this stumped me the other day when I came across it . Goodluck!
Reply
#4

Quote:
Originally Posted by ******
Посмотреть сообщение
Yeah, I said print values, not just code paths.
Tried, didn't help at all. The values looked fine. I just got rid of dynamic checkpoints and reverted to regular checkpoints.

Thank you anyways.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)