29.07.2012, 03:03
98.154.158.193:1994 - On my test server it will tell you the nearest bus stop.
Edit: I closed the test server.
Edit: I closed the test server.
pawn Code:
enum BusStopsMain {
BusName[34],
Float: BusCords[3]
};
static const BusStops[][BusStopsMain] = {
{"Doherty Station", {-2002.7013,145.5387,27.63840}}, // BusStop 1: Train Station
{"National Bank", {-1998.4659,471.1749,35.10720}}, // BusStop 2: San Fierro Bank
{"Department of Licenses", {-1869.0721,600.3917,35.11500}}, // Bus Stop 3: Department of licenses
{"San Fierro Police Department", {-1631.8818,726.1474,14.56140}}, // Bus Stop 4: San Fierro Police Department
{"Westside Avenue", {-1529.6941,961.0469,7.132800}}, // Bus Stop 5: Docks
{"Oto's Motorbikes", {-1630.6411,1251.6025,7.14990}}, // Bus Stop 6: Oto's autos
{"Pier-39", {-1990.4875,1314.1171,7.13860}}, // Bus Stop 7: Pier 39
{"Calton Heights", {-2147.3218,1278.8663,24.6881}}, // Bus Stop 8: Calton Heights
{"Juniper Hill", {-2271.9961,1064.8588,81.8771}}, // Bus Stop 9:Juniper Hill
{"Chinatown", {-2272.3606,689.1893,49.39800}}, // Bus Stop 10: Chinatown
{"San Fierro Medical Center", {-2588.3118,571.5823,14.56070}}, // Bus Stop 11: San Fierro Medical Center
{"Ocean Flats", {-2710.1938,-26.9371,4.350200}} // Bus Stop 12: Ocean Flats South
};
// Indent where needed.
stock GetNearestBus(PlayerID, &Name[], Len) {
new Float: d = 9999.000,
Float: dis = 9999.0000,
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;
}
}
format(Name, Len, BusStops[number][BusName], 0);
return Name;
}
public OnPlayerConnect(playerid) {
new BusStop[34];
GetNearestBus(playerid, BusStop, 34);
new String[(34 + 20)];
format(String, sizeof(String), "Nearest Bus Stop: %s", BusStop), SendClientMessage(playerid, -1, String);
return true;
}