Всем доброго времени суток, вот копался копался и ничего так и не понял. прошу вас как опытных людей в этом деле помочь разобраться. мне нужно вместо рандомного выбора точки загрузки из списка, сделать чтобы сервер выбирал ближайшую к игроку. а точку разгрузки так и оставить. или хотя бы скиньте пример как сделать МОД НА ИНКЛУДАХ ТОГО ПРОШУ НЕ ПИСАТЬ ЧТО ЭТО ЗА ИЗВРАЩЕНИЕ или что то в этом роде. Скидываю ряд цепи выбора рандомного груза: [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] != 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)