• Страница 1 из 1
  • 1
Модератор форума: drifter-dron, admin, TweIk  
Как переделать с рандомного выбора на ближайший к игроку
ALEXSДата: Вторник, 27.01.2015, 00:51:23 | Сообщение # 1

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

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

{"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[/PHP]

Автор - ALEXS
Дата добавления - 27.01.2015 в 00:51:23
  • Страница 1 из 1
  • 1
Поиск:
Загрузка страницы, займет меньше минуты...
Загрузка...

Статистика Форума
Последнии темы Читаемые темы Лучшие пользователи Новые пользователи
Система телефонов поломалась
Не в себе
фильм скалайн
Трансформеры 3
форсаж 6
Ищу [FS]Для админок на сервер
нужны координаты карты для отметки зон...
Помогите найти мод
pawno урок автоматические ворота
обращение к скриптерам.
Вопросы по скриптингу
Ваши ошибки при компиляции GM/FS

Вопросы по скриптингу

(1081)

Считаем до 1000

(274)

Ваши ошибки при компиляция gm

(260)

Набор в команду

(80)

Ваши ошибки при компиляции GM/FS

(71)

вопроосы по скриптингу от 22.04.2013

(64)

Баннеробмен

(64)

несколько команд на samp 0.3 c

(64)

Оценки сайта samp-pawno.ru

(55)

Заказ хостинга

(51)

Набор в команду(форум)

(45)

Урок №61 по созданию системы авто для GodFather

(45)

admin

(3869)

[east_side]_trane

(443)

TWiX

(316)

valych

(501)

drifter-dron

(477)

danik_rok

(317)

Dimka_71rus

(360)

Drifter96

(300)

MaNb9K

(220)

[MTA]MaPeR5518

(181)

Dima_Tkach

(107)

Nik_Ull

(184)

ps798829

(Среда 08:23:47)

system32xzxz

(Четверг 09:25:24)

torbin169

(Суббота 23:09:29)

kuchuk_00

(Суббота 17:10:14)

artem_boyko_3

(Суббота 15:57:37)

greggelbak

(Среда 18:29:37)

vladisvlavs

(Среда 13:51:57)

add02102002

(Понедельник 22:37:15)

Диман221

(Понедельник 18:12:45)

almas051004

(Воскресенье 11:05:32)

megasuccessms

(Суббота 14:15:36)

nawe

(Пятница 22:25:23)

Вверх
17:22:23
ОбновитьСмайлыУправление мини-чатом
ЧАТ-PAWNO
2010-2025

vkontakte :samp-pawno.ru: