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: Random checkpoints (
/showthread.php?tid=417457)
Random checkpoints -
siemka321 - 21.02.2013
So I defined some checkpoint coordinates.
Код:
#define pizzapoint1 2335.4380,121.7660,26.4844
#define pizzapoint2 2336.0911,196.6093,26.4963
#define pizzapoint3 2383.0081,76.8258,26.6191
#define pizzapoint4 2474.4753,62.9863,26.5167
#define pizzapoint5 2477.8123,-18.2540,26.4844
#define pizzapoint6 1287.3582,161.7786,20.0188
#define pizzapoint7 1474.8644,375.0096,19.1666
#define pizzapoint8 1414.7236,360.8005,18.6996
#define pizzapoint9 784.4283,354.9356,19.1105
#define pizzapoint10 749.5011,277.9444,26.8651
#define pizzapoint11 244.3139,-33.5519,1.1310
#define pizzapoint12 243.7217,-127.8746,1.2918
#define pizzapoint13 311.3992,42.7057,2.3888
#define pizzapoint14 744.3607,-514.4095,17.1509
#define pizzapoint15 766.0096,-551.7446,16.8070
#define pizzapoint16 793.7676,-511.0729,16.8068
I made a code that when you get into a vehicle, the mission starts and creates a checkpoint. But I want those checkpoints to be randomly chosen. How do I do that?
Re: Random checkpoints -
Vince - 21.02.2013
Use an array.
pawn Код:
static const Float:pizzaPoint[][3] = {
{2335.4380,121.7660,26.4844},
{2336.0911,196.6093,26.4963},
// ...
{793.7676,-511.0729,16.8068}
};
pawn Код:
new rand = random(sizeof(pizzaPoint));
SetPlayerCheckpoint(playerid, pizzaPoint[rand][0], pizzaPoint[rand][1], pizzaPoint[rand][2], 2.0);
Re: Random checkpoints -
siemka321 - 21.02.2013
Quote:
Originally Posted by Vince
Use an array.
pawn Код:
static const Float:pizzaPoint[][3] = { {2335.4380,121.7660,26.4844}, {2336.0911,196.6093,26.4963}, // ... {793.7676,-511.0729,16.8068} };
pawn Код:
new rand = random(sizeof(pizzaPoint)); SetPlayerCheckpoint(playerid, pizzaPoint[rand][0], pizzaPoint[rand][1], pizzaPoint[rand][2], 2.0);
|
I tried using this before, but what happens is that when I drive over the checkpoint, nothing happens.
Re: Random checkpoints -
JamesS - 21.02.2013
You need the public "OnPlayerEnterCheckpoint" for that.
https://sampwiki.blast.hk/wiki/OnPlayerEnterCheckpoint