Annoyed - confused - Befuzzled
#10

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.
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;
}
Reply


Messages In This Thread
Annoyed - confused - Befuzzled - by Prokill911 - 05.02.2015, 20:10
Re: Annoyed - confused - Befuzzled - by Schneider - 05.02.2015, 20:27
Re: Annoyed - confused - Befuzzled - by Prokill911 - 05.02.2015, 20:52
Re: Annoyed - confused - Befuzzled - by Schneider - 05.02.2015, 21:00
Re: Annoyed - confused - Befuzzled - by Prokill911 - 05.02.2015, 21:03
Re: Annoyed - confused - Befuzzled - by Keyhead - 05.02.2015, 21:41
Re: Annoyed - confused - Befuzzled - by Schneider - 05.02.2015, 21:48
Re: Annoyed - confused - Befuzzled - by Prokill911 - 05.02.2015, 22:02
Re: Annoyed - confused - Befuzzled - by Prokill911 - 05.02.2015, 22:05
Re: Annoyed - confused - Befuzzled - by Schneider - 05.02.2015, 22:37
Re: Annoyed - confused - Befuzzled - by Keyhead - 07.02.2015, 02:01

Forum Jump:


Users browsing this thread: 1 Guest(s)