SA-MP Forums Archive
How to make random checkpoints ? - 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: How to make random checkpoints ? (/showthread.php?tid=460467)



How to make random checkpoints ? - bustern - 28.08.2013

How to make when player use command, to get on map random checkpoints ?


Re: How to make random checkpoints ? - ProjectMan - 28.08.2013

Post the coordinates, I will make it for you with commented lines...


Re: How to make random checkpoints ? - Konstantinos - 28.08.2013

pawn Code:
new
    Float: checkpoints[ ][ 3 ] =
    {
        { 0.0, 0.0, 0.0 },
        { 10.0, 10.0, 10.0 },
        { 20.0, 20.0, 20.0 },
        { 30.0, 30.0, 30.0 },
        { 40.0, 40.0, 40.0 }
    }
;

CMD:rcp( playerid, params[ ] )
{
    new
        rand = random( sizeof( checkpoints ) )
    ;
    SetPlayerCheckpoint( playerid, checkpoints[ rand ][ 0 ], checkpoints[ rand ][ 1 ], checkpoints[ rand ][ 2 ], 3.0 );
    return 1;
}



Re: How to make random checkpoints ? - bustern - 28.08.2013

Thx you man.Can i do that with:OnPlayerEneterCheckPoint ?


Re: How to make random checkpoints ? - Konstantinos - 28.08.2013

Instead of the command? No, you cannot. OnPlayerEnterCheckpoint is called only when you enter a checkpoint.

Unless you meant something else and I misunderstood.


Re: How to make random checkpoints ? - bustern - 28.08.2013

Can i make when player enter on checkpoint to get new RANDOM on his map ?


Re: How to make random checkpoints ? - Konstantinos - 28.08.2013

Yes.

pawn Code:
public OnPlayerEnterCheckpoint( playerid )
{
    new
        rand = random( sizeof( checkpoints ) )
    ;
    SetPlayerCheckpoint( playerid, checkpoints[ rand ][ 0 ], checkpoints[ rand ][ 1 ], checkpoints[ rand ][ 2 ], 3.0 );
    return 1;
}



Re: How to make random checkpoints ? - bustern - 28.08.2013

But where i must post cordinates of the checkpoints ?


Re: How to make random checkpoints ? - ProjectMan - 28.08.2013

Quote:
Originally Posted by Konstantinos
View Post
pawn Code:
new
    Float: checkpoints[ ][ 3 ] =
    {
        { 0.0, 0.0, 0.0 },
        { 10.0, 10.0, 10.0 },
        { 20.0, 20.0, 20.0 },
        { 30.0, 30.0, 30.0 },
        { 40.0, 40.0, 40.0 }
    }
;

CMD:rcp( playerid, params[ ] )
{
    new
        rand = random( sizeof( checkpoints ) )
    ;
    SetPlayerCheckpoint( playerid, checkpoints[ rand ][ 0 ], checkpoints[ rand ][ 1 ], checkpoints[ rand ][ 2 ], 3.0 );
    return 1;
}
Quote:
Originally Posted by bustern
View Post
But where i must post cordinates of the checkpoints ?
pawn Code:
new
    Float: checkpoints[ ][ 3 ] =
    { //   X     Y    Z               put your coordinates according to the column.
        { 0.0, 0.0, 0.0 },
        { 10.0, 10.0, 10.0 },
        { 20.0, 20.0, 20.0 },
        { 30.0, 30.0, 30.0 },
        { 40.0, 40.0, 40.0 }
    }
;