SA-MP Forums Archive
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=282552)



Random checkpoints - lukas567 - 11.09.2011

Hello!

I want to make a BMX system with random checkpoints, but when i enter first checkpoint other wont appear...

News:
Код:
new Float: bmx1[10][3] =
{
  { -2028.8643,-105.7695,38.4339},
  { -2012.5841,-103.2338,41.0875},
  { -1700.3256,1223.0607,32.7146},
  { -1523.2424,489.4354,10.1117},
  { -1751.3070,266.6934,8.3100},
  { -1750.1702,158.9871,9.1140},
  { -1702.7638,69.8973,9.0848},
  { -2153.2749,-184.2894,40.6409},
  { -2151.7327,-92.2773,44.4817},
  { -2147.4937,-181.7524,38.2085}
};
new bmxo[MAX_PLAYERS];
OnDialogResponse (because i have to type /bgps to show dialog with question: Do you want to start your tricking?)

Код:
new rand = random(sizeof(bmx1));
if(dialogid == 9)
{
bmxo[playerid] = SetPlayerCheckpoint(playerid,bmx1[rand][0],bmx1[rand][1],bmx1[rand][2],3);
return 1;
}
OnPlayerEnterCheckpoint:

Код:
new rand = random(sizeof(bmx1));
if(bmxo[playerid] == 1)
{
bmxo[playerid] = SetPlayerCheckpoint(playerid,bmx1[rand][0],bmx1[rand][1],bmx1[rand][2],3);
}
Where's the problem?


Re: Random checkpoints - Vince - 11.09.2011

SetPlayerCheckpoint doesn't return a value, as far as I know. I think it always returns 0.


Re: Random checkpoints - lukas567 - 11.09.2011

So from:
new rand = random(sizeof(bmx1));
if(bmxo[playerid] == 1)
{
bmxo[playerid] = SetPlayerCheckpoint(playerid,bmx1[rand][0],bmx1[rand][1],bmx1[rand][2],3);
}

To:
new rand = random(sizeof(bmx1));
if(bmxo[playerid] == 1)
{
bmxo[playerid] = SetPlayerCheckpoint(playerid,bmx1[rand][0],bmx1[rand][1],bmx1[rand][2],3);
return 0;
}
?


Re: Random checkpoints - Babul - 11.09.2011

the trick is to set another checkpoint, but NOT the one you just touched, the modulo (%) does it.
storing the actual checkpoint in the bmxo[playerid] is already done, you only needed that formula to calculate one of the next in the bmx array...

OnDialogResponse:
Код:
if(dialogid == 9)
{
	new rand = random(sizeof(bmx1));
	SetPlayerCheckpoint(playerid,bmx1[rand][0],bmx1[rand][1],bmx1[rand][2],3);
	bmxo[playerid] = rand;
	return 1;
}
OnPlayerEnterCheckpoint:
Код:
{
	new rand = (1+bmxo[playerid]+random(sizeof(bmx1)-1))%sizeof(bmx1);
	bmxo[playerid] = rand;
	SetPlayerCheckpoint(playerid,bmx1[rand][0],bmx1[rand][1],bmx1[rand][2],3);
	return 1;
}



Re: Random checkpoints - DonWade - 06.01.2012

@Babul , thanks for this , it worked fine for me (+rep)