Yarko
Новичок
Всем доброго времени суток, вот копался копался и ничего так и не понял.
прошу вас как опытных людей в этом деле помочь разобраться.
мне нужно вместо рандомного выбора точки загрузки из списка, сделать чтобы сервер выбирал ближайшую к игроку. а точку разгрузки так и оставить.
или хотя бы скиньте пример как сделать
МОД НА ИНКЛУДАХ ТОГО ПРОШУ НЕ ПИСАТЬ ЧТО ЭТО ЗА ИЗВРАЩЕНИЕ или что то в этом роде.
Скидываю ряд цепи выбора рандомного груза:
прошу вас как опытных людей в этом деле помочь разобраться.
мне нужно вместо рандомного выбора точки загрузки из списка, сделать чтобы сервер выбирал ближайшую к игроку. а точку разгрузки так и оставить.
или хотя бы скиньте пример как сделать
МОД НА ИНКЛУДАХ ТОГО ПРОШУ НЕ ПИСАТЬ ЧТО ЭТО ЗА ИЗВРАЩЕНИЕ или что то в этом роде.
Скидываю ряд цепи выбора рандомного груза:
PHP:
Trucker_SetRandomJobData(playerid, PCV_Needed)
{
// Get a random Load from the loads that are defined for truckers with the given vehicle-type
APlayerData[playerid][LoadID] = Product_GetRandom(PCV_Needed);
// Get a random start-location and end-location for this load
APlayerData[playerid][JobLoc1] = Product_GetRandomStartLoc(APlayerData[playerid][LoadID]);
APlayerData[playerid][JobLoc2] = Product_GetRandomEndLoc(APlayerData[playerid][LoadID]);
// Store the vehicleID (required to be able to check if the player left his vehicle)
APlayerData[playerid][VehicleID] = GetPlayerVehicleID(playerid);
// Store the trailerID (required to be able to check if the player lost his trailer)
APlayerData[playerid][TrailerID] = GetVehicleTrailer(GetPlayerVehicleID(playerid));
// Return 1 to indicate that a job has been set correctly
return 1;
}
stock Product_GetRandomStartLoc(ProductID)// вот именно это выберает рандомно помогите переделать.
{
// Setup local variables
new NumProducts;
// First find out how many valid start-locations there are in this product
for (new i; i < 30; i++)
{
// If the product has a valid location in this index
if (ALoads[ProductID][FromLocations][i] != 0)
NumProducts++; // Count the number of valid start-locations
else // A start-location with ID 0 has been found (dummy-location)
break; // Stop counting
}
// Return the LocationID that's stored at a random index
return ALoads[ProductID][FromLocations][random(NumProducts)];
}
enum TLoad
{
LoadName[50], // The name of the load
bool:Mafia, // Holds "true" if this load is wanted by the mafia
Float:PayPerUnit, // Holds the price for every meter to haul this type of load (this gets multiplied by the distance to calculate the payment)
PCV_Required, // This holds the vehicle-type the player needs to use this load (and automatically the player's class)
FromLocations[30], // This array holds all loading-points for this load
ToLocations[30] // This array holds all unloading-points for this load
}
new ALoads[][TLoad] =
{
// Loads for ore trailer
{"Гравий", false, 1.00, PCV_TruckerOreTrailer, {11}, {1}}, // LoadID 1 11 это загрузка а 1 это разгрузка они берутся отсюда (ниже смотрим
enum TLocation
{
LocationName[50], // The name of the location
Float:LocX, // The X-position of the location
Float:LocY, // The Y-position of the location
Float:LocZ // The Z-position of the location
}
// Setup an array that holds all location-data (except taxi and busdriver classes, these have their own locations)
new ALocations[][TLocation] =
{
// LocationName, LocationX, LocationY, LocationZ
{"Dummy location", 0.0, 0.0, 0.0}, // Location 0 = dummy location (never used)
{"LS Construction Site", 1859.0, -1314.0, 14.0}, // Location 1
{"SF Construction Site", -2083.0, 209.0, 35.5}, // Location 2
{"LV Construction Site", 2708.0, 878.0, 10.0}, // Location 3
{"SF Financial Center", -2039.5, 467.5, 35.2}, // Location 4
{"Clown's Pocket Constr.", 2467.0, 1923.0, 9.8}, // Location 5
{"Solarin Industries", -1822.5, 41.25, 15.25}, // Location 6
{"Blueberry Truck Terminal", 52.75, -278.0, 1.7}, // Location 7
{"KACC Military Fuels", 2708.5, 2641.25, 11.0}, // Location 8
{"SA Federal Mint", -2441.0, 521.5, 30.0}, // Location 9
{"Angel Pine Sawmill", -1965.75, -2436.0, 30.7}, // Location 10
{"Quarry", 587.25, 844.75, -42.5}, // Location 11
