05.02.2015, 22:37
Well, you didn't mention it had to be at least 500 units away and since you called your function getClosestPizzaDelivery I assumed you wanted to get the closest location...
Anyway, try this one. This should select a random house between 500 and 2500 units away:
Make sure, when you use this function, it doesn't return '-1'. (No house found). I added this to prevent the server from getting in an infinite loop.
Anyway, try this one. This should select a random house between 500 and 2500 units away:
Make sure, when you use this function, it doesn't return '-1'. (No house found). I added this to prevent the server from getting in an infinite loop.
pawn Код:
getClosestPizzaDelivery(playerid)
{
new Float:pDistance, i, index = -1, loop;
while(index == -1)
{
loop++;
i = random(sizeof(Houses));
pDistance = GetPlayerDistanceFromPoint(playerid, Houses[i][EHouseX], Houses[i][EHouseY], Houses[i][EHouseZ]);
if(500.0 < pDistance < 2500.0)
{
index = i;
}
if(loop == 500) return -1;
}
SetPVarFloat(playerid, "PizzaTravelDistance", pDistance );
return index;
}

