GetNearestsVehicles without cikle.
#1

Hi,

It's possible to get nearest vehicles without doing cikle? for example i have only 20 near vehicle to player but i have in server 1800 vehicles and my max_vehicles is 2000, i have do big cikle, it's possible to make cikle including just 20 repeatings or something else?
Reply
#2

One way would be foreach/y_iterate. Add to an iterator the streamed vehicles and loop through them. You have to use the old multi-iterator method though.

An example:
pawn Код:
// global:
static
    Iterator: gPlayerStreamedVehicles[MAX_PLAYERS]<MAX_VEHICLES>;
   
// OnGameModeInit:
Iter_Init(gPlayerStreamedVehicles);

// OnPlayerConnect:
Iter_Clear(gPlayerStreamedVehicles[playerid]);

public OnVehicleStreamIn(vehicleid, forplayerid)
{
    Iter_Add(gPlayerStreamedVehicles[forplayerid], vehicleid);
    return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
    Iter_Remove(gPlayerStreamedVehicles[forplayerid], vehicleid);
    return 1;
}

// somewhere:
foreach (new v : gPlayerStreamedVehicles[playerid])
{
    // "v" vehicleid is streamed in
}
Reply
#3

Thanks it's only way or there is better way?

I could do this foreach in onplayerupdate? do some getvehiclepos and some calculations, distances
Reply
#4

Quote:
Originally Posted by ScIrUsna
Посмотреть сообщение
Thanks it's only way or there is better way?

I could do this foreach in onplayerupdate? do some getvehiclepos and some calculations, distances
It's not the "only" way technically, but it is the best one you'll find. y_iterate is made specifically for these types of things!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)