02.08.2015, 08:57
How I can put random checkpoint to somebody when is working without give him same location as last one?
new CPs[8][3] =
{
{ 0.0, 0.0, 0.0 },
{ 0.0, 0.0, 0.0 },
{ 0.0, 0.0, 0.0 },
{ 0.0, 0.0, 0.0 },
{ 0.0, 0.0, 0.0 },
{ 0.0, 0.0, 0.0 },
{ 0.0, 0.0, 0.0 }
}
new pLastCP[MAX_PLAYERS];
// where you set
new rNum = random(sizeof(CPs));
SetPlayerCheckPoint(playerid, CPs[rNum][0], CPs[rNum][1], CPs[rNum][2], 1.0);
pLastCP[playerid] = rNum;
// Where you give another CP
new rNum = random(sizeof(CPs));
if(rNum == pLastCP[playerid)
{
if(rNum == 8) { SetPlayerCheckPoint(playerid, CPs[rNum-1][0], CPs[rNum-1][1], CPs[rNum-1][2], 1.0); pLastCP[playerid] = (rNum - 1); }
if(rNum < 8) { SetPlayerCheckPoint(playerid, CPs[rNum+1][0], CPs[rNum+1][1], CPs[rNum+1][2], 1.0); pLastCP[playerid] = (rNum - 1); }
}
//global at the top of the script:
new LastCheckpoint[MAX_PLAYERS];
new Float:RandomCheckpoints[][] =
{
{123.145,123.123,123.123},
{156.156,156.156,156.156}
};
//Where you want to use it:
RandomCheckpoint_goto:
new rand = random(sizeof(RandomCheckpoints));
if(rand == LastCheckpoint[playerid])goto RandomCheckpoint_goto;
LastCheckpoint[playerid] = rand;
SetPlayerCheckpoint(playerid,RandomCheckpoints[rand][0],RandomCheckpoints[rand][1],RandomCheckpoints[rand][2]);

do
{
newthing = random(/* ... */);
}
while(newthing == oldthing);