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
};
forward GetNearestBus(playerid, name[], len);
public GetNearestBus(playerid, name[], len)
{
new Float:d = 0.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;
}
}
return format(name, len, BusStops[number][BusName], 0);
}
new bs[34];
GetNearestBus(playerid, bs, 34);
new strr[128];
format(strr, sizeof(strr), "Current Stop - %s **Speaker**", bs);
forward GetNearestBus(playerid, zone[], len);
stock GetNearestBus(playerid, zone[], len) whats that? its a public or a stock? rofl xD |
forward GetNearestBus(playerid, name[], len);
public GetNearestBus(playerid, name[], len)
{
new Float:d = 0.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;
}
}
return format(name, len, BusStops[number][BusName], 0);
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;
}
}
format(name, len, BusStops[number][BusName], 0);
return name;
}
pawn Code:
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. |
new name[34];
format(name, len, BusStops[number][BusName], 0);
return name;
}
forward GetNearestBus(playerid, name[], len);
public GetNearestBus(playerid, name[], len)
No dude go back up.
I fucking fixed it *excuse my language* |
forward GetNearestBus(playerid, name[], len);
public GetNearestBus(playerid, name[], len)
{
new Float:d = 0.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;
}
}
return format(name, len, BusStops[number][BusName], 0);
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;
}
}
format(name, len, BusStops[number][BusName], 0);
return name;
}
- You're returning the result of format, not the name of the bustop. - - Redo the return. |
stock getfactionname(playerid, faction[], len)
{
if(PlayerInfo[playerid][Fmember] == 1) return format(faction, len, "San Fierro Police Department", 0);
else if(PlayerInfo[playerid][Fmember] == 2) return format(faction, len, "F.B.I", 0);
else if(PlayerInfo[playerid][Fmember] == 3) return format(faction, len, "San Fierro Medical Center", 0);
else if(PlayerInfo[playerid][Fmember] == 4) return format(faction, len, "National Army", 0);
//Blablabla
//Blablabla
new factionn[128];
getfactionname(playerid, factionn, sizeof(factionn));
new bs[34];
GetNearestBus(playerid, bs, 34);
Would you just try the code I posted first?
I used to respect you but now your stubbornness is showing to me. ~ TheLazySloth ~ |
Then how come mine worked for me on my test server... and yours isnt working for either me nor you?
|
C:\Users\Milan\Documents\GTA San Andreas Scripts + Server\Reality Roleplay Gamemode Script\RealityRPrr.pwn(36094) : error 067: variable cannot be both a reference and an array (variable "name") C:\Users\Milan\Documents\GTA San Andreas Scripts + Server\Reality Roleplay Gamemode Script\RealityRPrr.pwn(36095) : error 067: variable cannot be both a reference and an array (variable "name") C:\Users\Milan\Documents\GTA San Andreas Scripts + Server\Reality Roleplay Gamemode Script\RealityRPrr.pwn(36110) : error 090: public functions may not return arrays (symbol "GetNearestBus")
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;
}
}
format(name, len, BusStops[number][BusName], 0);
return name;
}
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;
}
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;
}
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;
}