Second Checkpoint does not remove itself and does not call the third one
#1

The problem I am experiencing is that when I enter the first checkpoint it works good but when I enter the second checkpoint it simply keeps refreshing itself and does not call the third one.

Here's the OnPlayerEnterDynamicCP.
pawn Код:
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
    new Float: sX, Float: sY, Float: sZ;
    if(checkpointid == dmvcp1)
    {
        DestroyDynamicCP(dmvcp1);
        dmvcp2 = CreateDynamicCP(1606.9996, -2319.3191, -2.8516, 5, 0, 0, playerid, 2000);
        return 1;
    }
    if(checkpointid == dmvcp2)
    {
        DestroyDynamicCP(dmvcp2);
        dmvcp3 = CreateDynamicCP(1575.9720, -2296.1660, -2.9355, 5, 0, 0, playerid, 2000);
        return 1;
    }
    if(checkpointid == dmvcp3)
    {
        DestroyDynamicCP(dmvcp3);
        GivePlayerCash(playerid, -2500);
        GameTextForPlayer(playerid, "~g~ Passed!", 1500, 0);
        GetPlayerPos(playerid, sX, sY, sZ);
        SetPlayerPos(playerid, sX, sY, sZ+2);
        DestroyVehicle(dmvcar[0]);
        return 1;
    }
    return 0;
}
I've tried many things, I tried using SetPlayerCheckpoint and place them under OnPlayerEnterCheckpoint, and that had the same effect.
I've tried returning 1 at the end of OnPlayerEnterDynamicCP and that didn't really influence the case.
I first started off with leaving the returns out. (Under each if statement) and what that did was showing me everything Checkpoint 3 should show.

Checkpoints is my weakness, I always struggle with them.
Anyhow, help is much appreciated!
Reply
#2

maybe i sound like a noob but maybe this could help you https://sampwiki.blast.hk/wiki/PickupTypes
Reply
#3

Quote:
Originally Posted by sl!x
Посмотреть сообщение
maybe i sound like a noob but maybe this could help you https://sampwiki.blast.hk/wiki/PickupTypes
I don't see how that's related to my problem.
Reply
#4

i mean maybe try to create them like this
PHP код:
AddStaticPickup(124221503.33591432.358510.11910); 
but it is just an idea of a beginner
Reply
#5

Try to remove DestroyDynamicCP(...); since only one checkpoint can be shown at a time.
Reply
#6

Quote:
Originally Posted by mirou123
Посмотреть сообщение
Try to remove DestroyDynamicCP(dmvcp1); since only one checkpoint can be shown at a time.
I destroy dmvcp1 to get dmvcp2 streamed.
Reply
#7

Try:

pawn Код:
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
    new Float: sX, Float: sY, Float: sZ;
    if(checkpointid == dmvcp1)
    {
        DestroyDynamicCP(dmvcp1);
        dmvcp2 = CreateDynamicCP(1606.9996, -2319.3191, -2.8516, 5, 0, 0, playerid, 2000);
    }
    else if(checkpointid == dmvcp2)
    {
        DestroyDynamicCP(dmvcp2);
        dmvcp3 = CreateDynamicCP(1575.9720, -2296.1660, -2.9355, 5, 0, 0, playerid, 2000);
    }
    else if(checkpointid == dmvcp3)
    {
        DestroyDynamicCP(dmvcp3);
        GivePlayerCash(playerid, -2500);
        GameTextForPlayer(playerid, "~g~ Passed!", 1500, 0);
        GetPlayerPos(playerid, sX, sY, sZ);
        SetPlayerPos(playerid, sX, sY, sZ+2);
        DestroyVehicle(dmvcar[0]);
    }
    return 0;
}
Reply
#8

Quote:
Originally Posted by Matess
Посмотреть сообщение
Try:

pawn Код:
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
    new Float: sX, Float: sY, Float: sZ;
    if(checkpointid == dmvcp1)
    {
        DestroyDynamicCP(dmvcp1);
        dmvcp2 = CreateDynamicCP(1606.9996, -2319.3191, -2.8516, 5, 0, 0, playerid, 2000);
    }
    else if(checkpointid == dmvcp2)
    {
        DestroyDynamicCP(dmvcp2);
        dmvcp3 = CreateDynamicCP(1575.9720, -2296.1660, -2.9355, 5, 0, 0, playerid, 2000);
    }
    else if(checkpointid == dmvcp3)
    {
        DestroyDynamicCP(dmvcp3);
        GivePlayerCash(playerid, -2500);
        GameTextForPlayer(playerid, "~g~ Passed!", 1500, 0);
        GetPlayerPos(playerid, sX, sY, sZ);
        SetPlayerPos(playerid, sX, sY, sZ+2);
        DestroyVehicle(dmvcar[0]);
    }
    return 0;
}
Same issue.
The first checkpoint gets destroys and it calls the second checkpoint but the second checkpoint refreshes itself and does not get destroyed.
Reply
#9

Maybe try using enums with coordinates and then make function for it, just suggestion. If you dont understood, you can PM me.
Reply
#10

Quote:
Originally Posted by MacT
Посмотреть сообщение
Maybe try using enums with coordinates and then make function for it, just suggestion. If you dont understood, you can PM me.
I understand, don't worry.
I could try that but it seems more complicated then it can be.
I made some variables for the checkpoints that pretty much the same.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)