Quote:
Originally Posted by Sniper Kitty
pawn Code:
forward GetNearestBus(playerid, name[], len); public GetNearestBus(playerid, name[], len) { new Float:d = 9999.000; new Float:dis = 0.0000; new number = -1; for(new i = 0; i <= sizeof(BusStops); i++) { dis = GetPlayerDistanceFromPoint(playerid, BusStops[i][BusCords][0], BusStops[i][BusCords][1], BusStops[i][BusCords][2]); if(dis < d) { d = dis; number = i; } } new name[34]; format(name, len, BusStops[number][BusName], 0); return name; }
The above code is my fix to your problem. Indent where needed.
Things wrong:
- Your finding the furthest bus stop... you should be finding the nearest.
- - Change if(dis > d) to if(dis < d)
- - Change new Float:d = 0.000; to new Float:d = 9999.000;
- You're returning the result of format, not the name of the bustop.
- - Redo the return.
|
Biggest Bullshit ever for returning this....