PDA

Просмотр полной версии : [Вопрос] Проверка



Long-
31.03.2017, 16:02
Всем привет скриптеры.
Я почему то не могу вдуплить в проверку, не знаю почему, мозг будто отбрасывает :D Не знаю даже как объяснить.
Вроде сделал все правильно, но он не как не хочет выдавать желаемое, вроде все логичное.

Начал работать с чекпоинтами , ну вроде все хорошо, в нем сделал проверку, но она не срабатывает.

Т.е сделал 4 слота, если 1 слот занят встаем на 2 если 2 и 1 занят встаем на 3 и т.п
Но почему то если 1 и 2 занят то он всеравно встает на 2, странно.

Вот мои наброски:


if(checkpointid == CheckPointJobPress1[playerid] && IsPlayerInVehicle(playerid, gVehicleJobPress[GetPVarInt(playerid, "NumberVehiclePress")]))
{
DestroyDynamicCP(CheckPointJobPress1[playerid]);
CheckPointJobPress1[playerid] = 0;

if(gPressSlot_1 != 0 && gPressSlot_2 != 0 && gPressSlot_3 != 0 && gPressSlot_4 != 0)
return SendClientMessage(playerid, -1, "Сейчас все прессы заняты, ждите пока осободится один из них.");

gObjectAttachVehiclePress[playerid] = CreateObject(12957, 0.0 , 0.0 ,0.0, 0.0, 0.0, 0.0, 0.0);

new
v = GetPVarInt(playerid, "NumberVehiclePress");

AttachObjectToVehicle(gObjectAttachVehiclePress[playerid], gVehicleJobPress[v], 0.0, 1.0, 0.4, 0.0, 0.0, 90.0);

//Если 1 пресс занят то вызываем 2-ой
if(gPressSlot_1 != 0)
{
CheckPointJobPress2[playerid] = CreateDynamicCP(-1669.9131,51.5018,3.5733, 1.7, -1, -1, playerid);

SetPVarFloat(playerid, "Position_press_controller_x", -1674.8478);
SetPVarFloat(playerid, "Position_press_controller_y", 40.9721);
SetPVarFloat(playerid, "Position_press_controller_z", 3.5547);

SetPVarFloat(playerid, "Position_press_x", -1669.9131);
SetPVarFloat(playerid, "Position_press_y", 51.5018);
SetPVarFloat(playerid, "Position_press_z", 3.5733);
gPressSlot_2 = 1;
return 1;
}
//end
//Если 2 пресс занят вызываем 3-ий пресс
if(gPressSlot_2 != 0)
{
CheckPointJobPress2[playerid] = CreateDynamicCP(-1668.3890,93.9657,3.5733, 1.7, -1, -1, playerid);

SetPVarFloat(playerid, "Position_press_controller_x", -1679.0974);
SetPVarFloat(playerid, "Position_press_controller_y", 89.9217);
SetPVarFloat(playerid, "Position_press_controller_z", 3.5452);

SetPVarFloat(playerid, "Position_press_x", -1668.3890);
SetPVarFloat(playerid, "Position_press_y", 93.9657);
SetPVarFloat(playerid, "Position_press_z", 3.5733);
gPressSlot_3 = 1;
return 1;
}
//end
//Если 3 занят вызываем 4-ий
if(gPressSlot_3 != 0)
{
CheckPointJobPress2[playerid] = CreateDynamicCP(-1648.0936,73.9195,3.5733, 1.7, -1, -1, playerid);

SetPVarFloat(playerid, "Position_press_controller_x", -1652.1462);
SetPVarFloat(playerid, "Position_press_controller_y", 63.3789);
SetPVarFloat(playerid, "Position_press_controller_z", 3.5451);

SetPVarFloat(playerid, "Position_press_x", -1648.0936);
SetPVarFloat(playerid, "Position_press_y", 73.9195);
SetPVarFloat(playerid, "Position_press_z", 3.5733);
gPressSlot_4 = 1;
return 1;
}
//end
//Если 1 пресс не занят то занимаем первый
CheckPointJobPress2[playerid] = CreateDynamicCP(-1690.1558,72.1034,3.5733, 1.7, -1, -1, playerid);

SetPVarFloat(playerid, "Position_press_controller_x", 1700.5906);
SetPVarFloat(playerid, "Position_press_controller_y", 68.0051);
SetPVarFloat(playerid, "Position_press_controller_z", 3.5495);

SetPVarFloat(playerid, "Position_press_x", -1690.1558);
SetPVarFloat(playerid, "Position_press_y", 72.1034);
SetPVarFloat(playerid, "Position_press_z", 3.5733);
gPressSlot_1 = 1;
//end
return 1;
}

Может кто подскажет

Item
31.03.2017, 20:24
Лучше сделать цикл с прогоном по всем трем слотам. Если слот свободен - записываем его номер в определенную переменную, и уже в дальнейшем работаем с этой переменной

wAx
31.03.2017, 22:40
if(gPressSlot_2 != 0)
{
CheckPointJobPress2[playerid] = CreateDynamicCP(-1668.3890,93.9657,3.5733, 1.7, -1, -1, playerid);

SetPVarFloat(playerid, "Position_press_controller_x", -1679.0974);
SetPVarFloat(playerid, "Position_press_controller_y", 89.9217);
SetPVarFloat(playerid, "Position_press_controller_z", 3.5452);

SetPVarFloat(playerid, "Position_press_x", -1668.3890);
SetPVarFloat(playerid, "Position_press_y", 93.9657);
SetPVarFloat(playerid, "Position_press_z", 3.5733);
gPressSlot_3 = 1;
return 1;
}
ты выставляешь значение 1 слоту номер 3 при использовании 2 слота, присмотрись

gPressSlot_3 = 1; // а надо gPressSlot_2 = 1;

Long-
01.04.2017, 18:14
if(gPressSlot_2 != 0)
{
CheckPointJobPress2[playerid] = CreateDynamicCP(-1668.3890,93.9657,3.5733, 1.7, -1, -1, playerid);

SetPVarFloat(playerid, "Position_press_controller_x", -1679.0974);
SetPVarFloat(playerid, "Position_press_controller_y", 89.9217);
SetPVarFloat(playerid, "Position_press_controller_z", 3.5452);

SetPVarFloat(playerid, "Position_press_x", -1668.3890);
SetPVarFloat(playerid, "Position_press_y", 93.9657);
SetPVarFloat(playerid, "Position_press_z", 3.5733);
gPressSlot_3 = 1;
return 1;
}
ты выставляешь значение 1 слоту номер 3 при использовании 2 слота, присмотрись

gPressSlot_3 = 1; // а надо gPressSlot_2 = 1;

Ну, все правильно, объясню:

Если gPressSlot_2 != 0 то мы чекпоинт ставим на 3 пресс тем самым gPressSlot_3 =1 .

Long-
01.04.2017, 18:58
Closed, исправил после того как немного поспал :)