SA-MP Forums Archive
Second Checkpoint does not remove itself and does not call the third one - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Second Checkpoint does not remove itself and does not call the third one (/showthread.php?tid=514287)



Second Checkpoint does not remove itself and does not call the third one - AndySedeyn - 20.05.2014

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!


Re: Second Checkpoint does not remove itself and does not call the third one - sl!x - 20.05.2014

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


Re: Second Checkpoint does not remove itself and does not call the third one - AndySedeyn - 20.05.2014

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.


Re: Second Checkpoint does not remove itself and does not call the third one - sl!x - 20.05.2014

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


Re : Second Checkpoint does not remove itself and does not call the third one - mirou123 - 20.05.2014

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


Re: Re : Second Checkpoint does not remove itself and does not call the third one - AndySedeyn - 20.05.2014

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.


Re: Second Checkpoint does not remove itself and does not call the third one - Matess - 20.05.2014

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;
}



Re: Second Checkpoint does not remove itself and does not call the third one - AndySedeyn - 20.05.2014

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.


Re: Second Checkpoint does not remove itself and does not call the third one - MacT - 20.05.2014

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


Re: Second Checkpoint does not remove itself and does not call the third one - AndySedeyn - 20.05.2014

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.