Автор Тема: [Скрипт] Крафт предметов на правый клик мыши (extra_rc.hpp)  (Прочитано 68 раз)

ReloadeD

  • Administrator
  • Новенький
  • *****
  • Сообщений: 17
  • Рейтинг: 15
    • Просмотр профиля
extra_rc.hpp
    class M4A3_EP1 {
class m4a3_add_attach {
text = "Add: Attahcments";
script = "[['SOURCE_WPN','OUTPUT_WPN','TEXT',0],[0,0],['TOOL1','TOOL2'],['ADD_ITEM1','ADD_ITEM2'],['REM_ITEM1','REM_ITEM1'],['ADD_TOOL1','ADD_TOOL2'],['REM_TOOL1','REM_TOOL2']] execVM 'custom\craft.sqf';";
};
    };

craft.sqf
private["_source","_output","_text","_type","_workbench","_fireplace","_tools","_addMag","_remMag","_addWpn","_remWpn","_dist","_pos","_rad","_nearwork","_nearfire","_holder","_txt1","_txt2","_selected","_mgs","_num","_cnt","_result"];

_source = (_this select 0) select 0; // Исходный предмет (weapon или magazine)
_output = (_this select 0) select 1; // Изготавливаемый предмет (weapon или magazine)
_text = (_this select 0) select 2; // Текст после успешного выполнения
_type = (_this select 0) select 3; // Тип изготавливаемого (weapon=0, magazine=1)
_workbench = (_this select 1) select 0; // Требование верстака (no=0, yes=1)
_fireplace = (_this select 1) select 1; // Требование костра (no=0, yes=1)
_tools = (_this select 2); // Необходимые инструменты [массив, количество не ограничено]
_addMag = (_this select 3); // Добавляемые предметы (magazines) [массив, количество не ограничено]
_remMag = (_this select 4); // Удаляемые предметы (magazines) [массив, количество не ограничено]
_addWpn = (_this select 5); // Добавляемые предметы (weapons) [массив, количество не ограничено]
_remWpn = (_this select 6); // Удаляемые предметы (weapons) [массив, количество не ограничено]
_dist = 3; // Дистанция до костра/верстака
_pos = getPosATL player;
_rad = 1;
_nearwork = count (nearestObjects [player, ["Wooden_shed_DZ","WoodShack_DZ","WorkBench_DZ"], _dist]);
_nearfire = {inflamed _x} count (getPosATL player nearObjects _dist);
_num = "";
_result = false;

if ((_fireplace > 0) and (_nearfire == 0)) exitwith {
[format["Требуется костер в радиусе %1 метров",_dist],1] call dayz_rollingMessages;
};
if ((_workbench > 0) and (_nearwork == 0)) exitwith {
[format["Требуется верстак в радиусе %1 метров",_dist],1] call dayz_rollingMessages;
};

{
if (_x !="" && !(player hasWeapon _x)) exitwith {
_txt1 = (gettext (configFile >> 'cfgweapons' >> _x >> 'displayName'));
[format["Нужен инструмент %1",_txt1],1] call dayz_rollingMessages;
_result = true;
};
} count _tools;

{
if (_x !="") then {
_selected = _x;
_mgs = {_selected == _x} count magazines player;
_cnt = {_selected == _x} count _remMag;
if (_selected == _source) then {
_cnt = _cnt + 1;
};
if !(_selected in magazines player) then {
_num = _cnt;
_txt2 = (gettext (configFile >> 'cfgmagazines' >> _x >> 'displayName'));
[format["Необходимо еще %1шт %2",_num,_txt2],1] call dayz_rollingMessages;
_result = true;
} else {
if  (_mgs < _cnt) then {
_num = _cnt - _mgs;
} else {
_num = 0;
};
if  (_num != 0) exitwith {
_txt2 = (gettext (configFile >> 'cfgmagazines' >> _x >> 'displayName'));
[format["Необходимо еще %1шт %2",_num,_txt2],1] call dayz_rollingMessages;
_result = true;
};
};
};
} count _remMag;

{
if (_x !="" && !(player hasWeapon _x)) exitwith {
_txt1 = (gettext (configFile >> 'cfgweapons' >> _x >> 'displayName'));
[format["Нужен %1",_txt1],1] call dayz_rollingMessages;
_result = true;
};
} count _remWpn;

if (_result) exitWith {};

closeDialog 0;

dayz_actionInProgress = true;
player playActionNow "Medic";
[player,"repair",0,false,10] call dayz_zombieSpeak;
[player,10,true,(getPosATL player)] spawn player_alertZombies;
sleep 6;
_holder = createVehicle ["WeaponHolder", _pos, [], _rad, "CAN_COLLIDE"];
_holder setposATL _pos;

{_holder addMagazineCargoGlobal [_x,1];} count _addMag;
{player removeMagazine _x;} count _remMag;
{_holder addWeaponCargoGlobal [_x,1];} count _addWpn;
{player removeWeapon _x;} count _remWpn;

if (_type > 0) then {
player removeMagazine _source;
_holder addMagazineCargoGlobal [_output,1];
} else {
player removeWeapon _source;
_holder addWeaponCargoGlobal [_output,1];
};

sleep 2;
player reveal _holder;
player action ["Gear", _holder];
sleep 1;
[format["%1",_text],1] call dayz_rollingMessages;
dayz_actionInProgress = false;

Установка extra_rc.hpp