Random checkpoints
#1

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?
Reply
#2

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

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;
}
?
Reply
#4

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;
}
Reply
#5

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


Forum Jump:


Users browsing this thread: 1 Guest(s)