SA-MP Forums Archive
Last checkpoint was not destroyed - 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: Last checkpoint was not destroyed (/showthread.php?tid=419067)



Last checkpoint was not destroyed - newbienoob - 27.02.2013

I have a problem with race checkpoint.

pawn Код:
public OnPlayerEnterDynamicRaceCP(playerid,checkpointid)
{
    if(checkpointid == cp[0])
    {
        cp[1] = CreateDynamicRaceCP(0,258.1696,2502.3184,16.0474,-78.5963,2498.3335,16.0418,10,200, .streamdistance = 500);
        DestroyDynamicRaceCP(cp[0]);
    }
    else if(checkpointid == cp[1])
    {
        cp[2] = CreateDynamicRaceCP(1,-78.5963,2498.3335,16.0418,-78.5963,2498.3335,16.0418,10,200, .streamdistance = 500);
        DestroyDynamicRaceCP(cp[1]);
    }
    else if(checkpointid == cp[2]) //This one doesn't work. I didn't receive "win" message and cp[2] was not destroyed.
    {
        SendClientMessage(playerid,-1,"win");
        DestroyDynamicRaceCP(cp[2]);
        SetPlayerVirtualWorld(playerid,0);
        return 1;
    }
    return 1;
}
I'm using streamer plugin.


Re: Last checkpoint was not destroyed - [MG]Dimi - 27.02.2013

How did you define cp[];?


Re: Last checkpoint was not destroyed - newbienoob - 27.02.2013

new cp[3];


Re: Last checkpoint was not destroyed - RajatPawar - 27.02.2013

How about using just 'else' on the last line (since it doesn't have any other choice) instead of 'else if'? Or using switch statements?


Re: Last checkpoint was not destroyed - DaRk_RaiN - 27.02.2013

Quote:
Originally Posted by Rajat_Pawar
Посмотреть сообщение
How about using just 'else' on the last line (since it doesn't have any other choice) instead of 'else if'? Or using switch statements?
He can't switch statements in this situation.


Re: Last checkpoint was not destroyed - newbienoob - 27.02.2013

I don't think that's the problem. + I will get an errors if I do that.


Re: Last checkpoint was not destroyed - Riddick94 - 27.02.2013

Yes, he can use switch.


Re: Last checkpoint was not destroyed - newbienoob - 27.02.2013

pawn Код:
switch (checkpointid)
    {
        case cp[0]:
        {
            cp[1] = CreateDynamicRaceCP(0,258.1696,2502.3184,16.0474,-78.5963,2498.3335,16.0418,10,200, .streamdistance = 500);
            DestroyDynamicRaceCP(cp[0]);
        }
?

Can't.


Re: Last checkpoint was not destroyed - Riddick94 - 27.02.2013

pawn Код:
#include    <a_samp>
#include    <streamer>

new cp[3];

public OnPlayerEnterDynamicRaceCP(playerid, checkpointid)
{
    for(new i = 0; i < 3; i++)
    {
        if(checkpointid == cp[i])
        {
            switch(i)
            {
                case 0:
                {
                    DestroyDynamicRaceCP(cp[0]);
                    cp[1] = CreateDynamicRaceCP(0,258.1696,2502.3184,16.0474,-78.5963,2498.3335,16.0418,10,200, .streamdistance = 500);
                }

                case 1:
                {
                    DestroyDynamicRaceCP(cp[1]);
                    cp[2] = CreateDynamicRaceCP(1,-78.5963,2498.3335,16.0418,-78.5963,2498.3335,16.0418,10,200, .streamdistance = 500);
                }

                case 2:
                {
                    SendClientMessage(playerid, -1, "win");
                    DestroyDynamicRaceCP(cp[2]);
                    SetPlayerVirtualWorld(playerid,0);
                }
            }
        }
    }
    return true;
}