Jump to content
skueneth

Create Vehicle - ASLtoATL - Update 1.78

Recommended Posts

Hello Devs and Supporters,

 

I have in my Scripts following:

    _box = createVehicle [_model, ASLtoATL _pos, [], 1, ""];

 

 

or this

 

 

  _terminal = createVehicle ["Land_CampingTable_small_F", ASLtoATL _pos, [], 0, ""];

 

in Logfiles it is not working anymore since 1.78 Update:

 

6:16:13 Error in expression <dels call BIS_fnc_selectRandom;

_box = createVehicle [_model, ASLtoATL _pos, []>
 6:16:13   Error position: <createVehicle [_model, ASLtoATL _pos, []>
 6:16:13   Error Foreign error: Unknown enum value: ""

 

 

or

 

 

 

 6:16:14   Error position: <createVehicle ["Land_CampingTable_small_>
 6:16:14   Error Foreign error: Unknown enum value: ""
 6:16:14 Attempt to override final function - fn_getvehiclevars
Attempt to override final function - fn_preprocesssaveddata
Attempt to override final function - fn_restoresavedvehicle

 

 

 

Please help me

 

 

 

 

 

 

 

 

 

Spoiler

 6:16:13 "Loading parking interact functions complete"
 6:16:13 Error in expression <dels call BIS_fnc_selectRandom;

_box = createVehicle [_model, ASLtoATL _pos, []>
 6:16:13   Error position: <createVehicle [_model, ASLtoATL _pos, []>
 6:16:13   Error Foreign error: Unknown enum value: ""
 6:16:13 File mpmissions\__cur_mp.Malden\addons\storage\ps_functions.sqf, line 84
 6:16:13 "Loading parking saving functions ..."
 6:16:13 "Loading parking saving functions complete"
 6:16:13 "[extDB3] Startup complete!"
 6:16:13 "[INFO] A3W playerSaving = ON"
 6:16:13 "[INFO] A3W baseSaving = ON"
 6:16:13 "[INFO] A3W vehicleSaving = ON"
 6:16:13 "[INFO] A3W boxSaving = ON"
 6:16:13 "[INFO] A3W staticWeaponSaving = ON"
 6:16:13 "[INFO] A3W warchestSaving = ON"
 6:16:13 "[INFO] A3W warchestMoneySaving = ON"
 6:16:13 "[INFO] A3W spawnBeaconSaving = ON"
 6:16:13 "[INFO] A3W timeSaving = ON"
 6:16:13 "[INFO] A3W weatherSaving = ON"
 6:16:13 "Creating Storage at: Cancon ([5448.71,2824.62,43.4979])"
 6:16:13 "Loading parking functions ..."
 6:16:13 "Setting up parking terminals ... "
 6:16:13 "[INFO] A3W hcObjSaving = OFF"
 6:16:14 "No storage in Chapoi"
 6:16:14 Error in expression <_garage allowDamage false;

_terminal = createVehicle ["Land_CampingTable_small_>
 6:16:14   Error position: <createVehicle ["Land_CampingTable_small_>
 6:16:14   Error Foreign error: Unknown enum value: ""
 6:16:14 File mpmissions\__cur_mp.Malden\addons\parking\pp_actions_functions.sqf, line 88
Attempt to override final function - fn_getvehiclevars
Attempt to override final function - fn_preprocesssaveddata
Attempt to override final function - fn_restoresavedvehicle
 6:16:14 "No storage in Sainte Marie"
 6:16:14 a3\structures_f_heli\vr\helpers\sign_sphere25cm_f.p3d: No geometry and no visual shape
 6:16:14 a3\structures_f_heli\vr\helpers\sign_sphere25cm_f.p3d: No geometry and no visual shape
 6:16:14 Error in expression <oWorld [0,0,-0.1])];
}
else
{
_dummy = createVehicle ["Sign_Sphere25cm_F", getP>
 6:16:14   Error position: <createVehicle ["Sign_Sphere25cm_F", getP>
 6:16:14   Error Foreign error: Unknown enum value: ""
 6:16:14 File mpmissions\__cur_mp.Malden\addons\parking\pp_actions_functions.sqf, line 54
 6:16:14 Error in expression <dels call BIS_fnc_selectRandom;

_box = createVehicle [_model, ASLtoATL _pos, []>
 6:16:14   Error position: <createVehicle [_model, ASLtoATL _pos, []>
 6:16:14   Error Foreign error: Unknown enum value: ""
 6:16:14 File mpmissions\__cur_mp.Malden\addons\storage\ps_functions.sqf, line 84
 6:16:14 "Creating parking terminal at Parking1 (Grid 081100)"
 6:16:14 "Creating Storage at: La Pessagne ([3236.31,6276.18,225.299])"
 6:16:14 Error in expression <_garage allowDamage false;

_terminal = createVehicle ["Land_CampingTable_small_>
 6:16:14   Error position: <createVehicle ["Land_CampingTable_small_>
 6:16:14   Error Foreign error: Unknown enum value: ""
 6:16:14 File mpmissions\__cur_mp.Malden\addons\parking\pp_actions_functions.sqf, line 88
 6:16:14 "No storage in Vigny"
 6:16:14 a3\structures_f_heli\vr\helpers\sign_sphere25cm_f.p3d: No geometry and no visual shape
 6:16:14 a3\structures_f_heli\vr\helpers\sign_sphere25cm_f.p3d: No geometry and no visual shape
 6:16:14 Error in expression <oWorld [0,0,-0.1])];
}
else
{
_dummy = createVehicle ["Sign_Sphere25cm_F", getP>
 6:16:14   Error position: <createVehicle ["Sign_Sphere25cm_F", getP>
 6:16:14   Error Foreign error: Unknown enum value: ""
 6:16:14 File mpmissions\__cur_mp.Malden\addons\parking\pp_actions_functions.sqf, line 54
 6:16:14 "No storage in Le Port"
 6:16:14 "Creating parking terminal at Parking2 (Grid 035032)"
 6:16:14 Error in expression <_garage allowDamage false;

_terminal = createVehicle ["Land_CampingTable_small_>
 6:16:14   Error position: <createVehicle ["Land_CampingTable_small_>
 6:16:14   Error Foreign error: Unknown enum value: ""
 6:16:14 File mpmissions\__cur_mp.Malden\addons\parking\pp_actions_functions.sqf, line 88
 6:16:14 "No storage in Arudy"
 6:16:15 "No storage in Goisse"
 6:16:15 "A3Wasteland - world persistence loaded 2 objects from extDB"
 6:16:15 a3\structures_f_heli\vr\helpers\sign_sphere25cm_f.p3d: No geometry and no visual shape
 6:16:15 a3\structures_f_heli\vr\helpers\sign_sphere25cm_f.p3d: No geometry and no visual shape
 6:16:15 Error in expression <oWorld [0,0,-0.1])];
}
else
{
_dummy = createVehicle ["Sign_Sphere25cm_F", getP>
 6:16:15   Error position: <createVehicle ["Sign_Sphere25cm_F", getP>
 6:16:15   Error Foreign error: Unknown enum value: ""
 6:16:15 File mpmissions\__cur_mp.Malden\addons\parking\pp_actions_functions.sqf, line 54
 6:16:15 "No storage in Houdan"
 6:16:15 "Creating parking terminal at Parking3 (Grid 055069)"
 6:16:15 Error in expression <_garage allowDamage false;

 

 

Spoiler

//if (!isNil "parking_functions_defined") exitWith {};
diag_log format["Loading parking functions ..."];

#include "macro.h"

#define strM(x) ([x,","] call format_integer)

pp_marker_create = {
  if (!hasInterface) exitWith {""};
  ARGVX3(0,_name,"");
  ARGVX3(1,_location,[]);
  ARGVX3(2,_this,[]);

  ARGVX3(0,_shape,"");
  ARGVX3(1,_type,"");
  ARGVX3(2,_color,"");
  ARGVX3(3,_size,[]);
  ARGVX3(4,_text,"");

  private["_marker"];
  _marker = createMarkerLocal [_name,_location];
  _marker setMarkerShapeLocal _shape;
  _marker setMarkerTypeLocal _type;
  _marker setMarkerColorLocal _color;
  _marker setMarkerSizeLocal _size;
  //_marker setMarkerText _text;
  (_marker)
};

pp_get_all_cities = {
  if (isARRAY(pp_all_cities)) exitWith {pp_get_all_cities};
  pp_get_all_cities = (nearestLocations [[0,0,0],["NameCityCapital","NameCity","NameVillage"],1000000]);
  (pp_get_all_cities)
};

pp_setup_terminal = {
  params ["_terminal"];
  if (_terminal getVariable ["A3W_parkingTerminalSetupDone",false]) exitWith {};
  private _garage = param [1, nearestBuilding _terminal];

  _terminal allowDamage false;
  _garage allowDamage false;
  _terminal setVariable ["R3F_LOG_disabled", true]; //don't allow players to move the table
  _garage setVariable ["R3F_LOG_disabled", true];

  if (isServer) then
  {
    if (getObjectType _garage == 8) then // manually-placed garage, can attachTo
    {
      _terminal attachTo [_garage, _garage worldToModel (_terminal modelToWorld [0,0,-0.1])];
    }
    else // garage native to map, cannot attachTo so we use invisible dummy
    {
      _dummy = createVehicle ["Sign_Sphere25cm_F", getPosATL _terminal, [], 0, ""];
      _dummy hideObjectGlobal true;
      _dummy allowDamage false;
      _dummy setPosWorld (getPosWorld _terminal vectorAdd [0,0,-0.1]); // vectorAdd to compensate for elevated shed floor
      _dummy setVectorDirAndUp [vectorDir _terminal, vectorUp _terminal];
      _dummy setVariable ["R3F_LOG_disabled", true, true];
      _terminal attachTo [_dummy, [0,0,0]];
    };

    def(_laptop);
    _laptop = createSimpleObject ["Land_Laptop_unfolded_F", getPosASL _terminal]; //createVehicle ["Land_Laptop_unfolded_F", getPosASL _terminal, [], 0, ""];
    _laptop allowDamage false;
    _laptop attachTo [_terminal, [0,-0.1,0.55]];
    _laptop setVariable ["R3F_LOG_disabled", true, true]; //don't allow players to move the laptop
  };

  _terminal setVariable ["A3W_parkingTerminalSetupDone", true];
};

pp_create_terminal = {
 //Land_Laptop_unfolded_F
  ARGVX3(0,_garage,objNull);

  def(_pos);
  def(_terminal);

  private _offset = switch (true) do {
    case (_garage isKindOf "Land_Carrier_01_base_F"): { [-28.663,108.289,23.9749] };
    default                                           { [0,0,0] };
  };

  _pos = AGLtoASL (_garage modelToWorld _offset);
  _garage allowDamage false;

  _terminal = createVehicle ["Land_CampingTable_small_F", ASLtoATL _pos, [], 0, ""];
  _terminal setPosASL _pos;
  _pos set [2, (_pos select 2) - (getPos _terminal select 2)];
  _terminal setPosASL _pos;
  _terminal setVectorDirAndUp [vectorDir _garage, vectorUp _garage];
  //_terminal attachTo [_garage, [0,0,0]];
  _terminal setVariable ["is_parking", true, true];
  [_terminal, _garage] call pp_setup_terminal;

  (_pos)
};

pp_create_terminals = {
  def(_marker);
  def(_marker_pos);
  //def(_marker_name);
  def(_garage);
  def(_terminal);
  def(_model);
  def(_pos);
  def(_name);
  def(_marker);
  init(_i,1);


  {
    _marker = _x;
    //_marker_name =  text(_marker);
    _marker_pos = markerPos _marker;
    //if (isARRAY(pp_cities_whitelist) && {count(pp_cities_whitelist) > 0 && {not(_town_name in pp_cities_whitelist)}}) exitWith {};

    _garage = (nearestObjects [_marker_pos, ["Land_i_Shed_Ind_F", "Land_Carrier_01_base_F"], 50]) select 0;
    if (!isOBJECT(_garage)) exitWith {
      diag_log format["No garage near %1", _marker];
    };

    _name = format["parking_terminal_%1", _i];
    _i = _i + 1;

    _pos = [_garage] call pp_create_terminal;

    diag_log format["Creating parking terminal at %1 (Grid %2)", _marker, mapGridPosition _pos];

  } foreach (allMapMarkers select {_x select [0,7] == "Parking" && _x find "_" == -1}) //(call pp_get_all_cities);
};

pp_get_near_vehicles = {
  ARGVX4(0,_player,objNull,[]);

  def(_vehicles);
  _vehicles = (nearestObjects [_player, ["LandVehicle","Air","Ship"], 50]) select {!(_x getVariable ["A3W_lockpickDisabled",false])};

  init(_filtered,[]);
  def(_uid);
  _uid = getPlayerUID player;

  def(_ownerUID);
  def(_vehicle);

  { call {
    _vehicle = _x;
    if (not(isOBJECT(_vehicle) && {alive _vehicle})) exitWith {};

    _ownerUID = _vehicle getVariable ["ownerUID", ""];
    if(!isSTRING(_ownerUID)) exitWith {};
    if (_ownerUID == "" || {_ownerUID == _uid}) exitWith {
      _filtered pushBack _vehicle;
    };

  };} forEach _vehicles;

  (_filtered)
};

pp_join_time = diag_tickTime; //time when the player joined the server

pp_get_wait_time = {
  ARGVX4(0,_vehicle_id,"",0);

  if (not(isSCALAR(pp_retrieve_wait)) || {pp_retrieve_wait <= 0}) exitWith {0};
  private _retrieve_wait = 0;

  def(_cooldown_start_name);
  _cooldown_start_name =  format["%1_cooldown_start", _vehicle_id];


  def(_cooldown_start);
  _cooldown_start = missionNamespace getVariable _cooldown_start_name;

  if (!isSCALAR(_cooldown_start)) then {
    _cooldown_start = pp_join_time;
    missionNamespace setVariable [_cooldown_start_name, _cooldown_start];
  };

  def(_time_elapsed);
  _time_elapsed = diag_tickTime - _cooldown_start;

  def(_time_remaining);
  _time_remaining = _retrieve_wait - _time_elapsed;

  if (_time_remaining <= 0) then {
    missionNamespace setVariable [_cooldown_start_name, nil];
  };

  (_time_remaining)
};

pp_retrieve_transaction_ok = {
  ARGVX4(0,_player,objNull,true);
  ARGVX4(1,_cost,0,true);
  ARGVX3(2,_class,"",true)

  def(_cmoney);
  _cmoney = _player getVariable ["cmoney",0];
  if (_cost > _cmoney) exitWith {
    _player groupChat format["%1, you do not have enough money to retrieve the %2", (name _player), ([_class] call generic_display_name)];
    false
  };

  _player setVariable ["cmoney", _cmoney - _cost, true];
  true
};

pp_retrieve_allowed = {
  ARGVX4(0,_player,objNull, true);
  ARGVX4(1,_vehicle_id,"",true);
  ARGVX4(2,_class,"", true);

  //check if there is a cool-down period
  def(_wait_time);
  _wait_time = [_vehicle_id] call pp_get_wait_time;
  if (isSCALAR(_wait_time) && {_wait_time > 0 }) exitWith {
    private _remaining = ceil _wait_time;
    private _mins = floor (_remaining / 60);
    private _secs = floor (_remaining - (_mins * 60));
    private _timer = format ["%1%2%3s", [str _mins + "m",""] select (_mins == 0), ["","0"] select (_secs < 10), _secs];

    _player groupChat format["%1, you have to wait %2 to retrieve the %3", (name _player), _timer, ([_class] call generic_display_name)];
    false
  };

  //check if thereis a price for retrieving the vehicle
  if (isSCALAR(pp_retrieve_cost) && {pp_retrieve_cost > 0}) exitWith {
    init(_cost,pp_retrieve_cost);
    _msg = format["It's going to cost you $%1 to retrieve the %2. Do you want to proceed?", strM(_cost), ([_class] call generic_display_name)];

    if (not([_msg, "Confirm", "Yes", "No"] call BIS_fnc_guiMessage)) exitWith {false};
    if (not([_player, _cost] call pp_retrieve_transaction_ok)) exitWith {false};

    true
  };

  true
};

pp_park_allowed = {
  ARGVX4(0,_player,objNull, true);
  ARGVX4(1,_vehicle_id,"",true);
  ARGVX4(2,_class,"", true);

  if (isARRAY(pp_disallowed_vehicle_classes) && {count(pp_disallowed_vehicle_classes) > 0 && { ({_class isKindOf _x} count pp_disallowed_vehicle_classes) > 0}}) exitWith {
    _msg = format["This vehicle (%1) is not allowed to be parked.", ([_class] call generic_display_name)];
    [_msg, "Illegal Parking", "Ok", false] call BIS_fnc_guiMessage;
    false
  };

  def(_parked_vehicles);
  _parked_vehicles = _player getVariable ["parked_vehicles", []];
  init(_count,count(_parked_vehicles));

  //check if the parking is full
  if (isSCALAR(pp_max_player_vehicles) && {pp_max_player_vehicles > 0 && {_count >= pp_max_player_vehicles}}) exitWith {
    _msg = format["You already have %1 vehicle(s) parked. There are no more parking spaces available.", _count];
    [_msg, "Full Parking", "Ok", false] call BIS_fnc_guiMessage;
    false
  };

  true
};

pp_park_vehicle_action = {
  init(_player,player);

  def(_vehicles);
  _vehicles = [_player] call pp_get_near_vehicles;

  def(_vehicle_id);
  _vehicle_id = ["Park Vehicle", _vehicles] call pp_interact_park_vehicle_wait;

  if (!isSTRING(_vehicle_id)) exitWith {
    //_player groupChat format["%1, you did not select any vehicle to park", (name _player)];
  };


  _vehicle = objectFromNetId _vehicle_id;
  if (!isOBJECT(_vehicle)) exitWith {
    _player groupChat format["%1, the vehicle you selected to park could not be found", (name _player)];
  };

  def(_class);
  _class =  typeOf _vehicle;

  if (not([_player, _vehicle_id, _class] call pp_park_allowed)) exitWith {};


  _player groupChat format["Please wait while we park your %1", ([typeOf _vehicle] call generic_display_name)];
  [_player, _vehicle] call pp_park_vehicle;
};

pp_retrieve_vehicle_action = {
  init(_player,player);

  def(_parked_vehicles);
  _parked_vehicles = _player getVariable "parked_vehicles";
  _parked_vehicles = if (isARRAY(_parked_vehicles)) then {_parked_vehicles} else {[]};


  def(_vehicle_id);
  _vehicle_id = ["Retrieve Vehicle", _parked_vehicles] call pp_interact_park_vehicle_wait;


  if (!isSTRING(_vehicle_id)) exitWith {
    //_player groupChat format["%1, you did not select any vehicle to retreive", (name _player)];
  };

  def(_vehicle_data);
  _vehicle_data = [_parked_vehicles, _vehicle_id] call fn_getFromPairs;

  if (!isARRAY(_vehicle_data)) exitWith {
    player groupChat format["ERROR: The selected vehicle (%1) was not found", _vehicle_id];
  };

  def(_class);
  _class = [_vehicle_data, "Class"] call fn_getFromPairs;

  if (not([_player, _vehicle_id, _class] call pp_retrieve_allowed)) exitWith {};

  _player groupChat format["Please wait while we retrieve your %1", ([_class] call generic_display_name)];
  [player, _vehicle_id] call pp_retrieve_vehicle;
};


pp_cameraDir = {
  ([(positionCameraToWorld [0,0,0]), (positionCameraToWorld [0,0,1])] call BIS_fnc_vectorDiff)
};

pp_is_object_parking = {
  ARGVX4(0,_obj,objNull,false);
  (_obj getVariable ["is_parking", false])
};

pp_is_player_near = {
  private["_objects"];
  _objects = nearestObjects [player, ["Land_CampingTable_small_F"], 2];
  if (isNil "_objects") exitWith {false};

  private["_found"];
  _found = false;
  {
    if ([_x] call pp_is_object_parking) exitWith {
      _found = true;
    };
  } forEach _objects ;

  (_found)
};

pp_actions = OR(pp_actions,[]);

pp_remove_actions = {
  if (count pp_actions == 0) exitWith {};

  {
    private["_action_id"];
    _action_id = _x;
    player removeAction _action_id;
  } forEach pp_actions;
  pp_actions = [];
};

pp_add_actions = {
  if (count pp_actions > 0) exitWith {};
  private["_player"];
  _player = _this select 0;

  private["_action_id", "_text"];
  _action_id = _player addAction ["<img image='addons\parking\icons\parking.paa'/> Park Vehicle", {call pp_park_vehicle_action}];
  pp_actions = pp_actions + [_action_id];

  _action_id = _player addAction ["<img image='addons\parking\icons\parking.paa'/> Retrieve Vehicle", {call pp_retrieve_vehicle_action}];
  pp_actions = pp_actions + [_action_id];
};

pp_check_actions = {
    private["_player"];
    _player = player;
    private["_vehicle", "_in_vehicle"];
    _vehicle = (vehicle _player);
    _in_vehicle = (_vehicle != _player);

    if (not(_in_vehicle || {not(alive _player) || {not(call pp_is_player_near)}})) exitWith {
      [_player] call pp_add_actions;
    };

   [_player] call pp_remove_actions;
};


pp_client_loop = {
  if (!hasInterface) exitWith {};

  while {true} do {
    call pp_check_actions;
    sleep 0.5;
  };
};


if (isServer) then
{
  diag_log "Setting up parking terminals ... ";
  [] call pp_create_terminals;
  pp_setup_terminals_complete = true;
  publicVariable "pp_setup_terminals_complete";
}
else
{
  diag_log "Waiting for parking terminals setup to complete ...";
  waitUntil {!isNil "pp_setup_terminals_complete"};
};

if (hasInterface) then
{
  waitUntil {!isNil "A3W_serverSetupComplete" && !isNil "A3W_clientSetupComplete"};
};

{
  _x call pp_setup_terminal;

  if (pp_markers_enabled) then
  {
    [format ["parking_terminal_%1", _forEachIndex + 1], getPosASL _x, pp_markers_properties] call pp_marker_create;
  };
} forEach ((allMissionObjects "Land_CampingTable_small_F") select {_x getVariable ["is_parking",false]});

diag_log "Parking terminals setup complete";

[] spawn pp_client_loop;

parking_functions_defined = true;
diag_log "Loading parking functions complete";

 

Spoiler

if (!isNil "storage_functions_defined") exitWith {};
diag_log format["Loading storage functions ..."];

#include "macro.h"
#include "futura.h"

ps_marker_create = {
  if (!hasInterface) exitWith {""};
  ARGVX3(0,_name,"");
  ARGVX3(1,_location,[]);
  ARGVX3(2,_this,[]);

  ARGVX3(0,_shape,"");
  ARGVX3(1,_type,"");
  ARGVX3(2,_color,"");
  ARGVX3(3,_size,[]);
  ARGVX3(4,_text,"");

  private["_marker"];
  _marker = createMarkerLocal [_name,_location];
  _marker setMarkerShapeLocal _shape;
  _marker setMarkerTypeLocal _type;
  _marker setMarkerColorLocal _color;
  _marker setMarkerSizeLocal _size;
  //_marker setMarkerTextLocal _text;
  (_marker)
};

ps_get_all_cities = {
  if (isARRAY(ps_all_cities)) exitWith {ps_get_all_cities};
  ps_get_all_cities = (nearestLocations [[0,0,0],["NameCityCapital","NameCity","NameVillage"],1000000]);
  (ps_get_all_cities)
};


ps_setup_box = {
  params ["_box"];
  if (_box getVariable ["A3W_storageBoxSetupDone",false]) exitWith {};
  private _garage = param [1, nearestBuilding _box];

  if (local _box) then { _box allowDamage false };
  if (local _garage) then { _garage allowDamage false };
  _box setVariable ["R3F_LOG_disabled", true];
  _garage setVariable ["R3F_LOG_disabled", true];

  _box setVariable ["A3W_storageBoxSetupDone", true];
};

ps_create_boxes = {
  def(_town);
  def(_town_pos);
  def(_town_name);
  def(_garage);
  def(_box);
  def(_model);
  def(_pos);
  def(_name);
  def(_marker);
  init(_i,0);


  { call {
    _town = _x;
    _town_name =  text(_town);
    _town_pos = position _town;
    if (isARRAY(ps_cities_whitelist) && {count(ps_cities_whitelist) > 0 && {not(_town_name in ps_cities_whitelist)}}) exitWith {};

    _garage = (nearestObjects [_town_pos, ["Land_i_Garage_V2_F", "Land_Shed_06_F", "Land_Warehouse_03_F"], 300]) select 0;
    if (!isOBJECT(_garage)) exitWith {
      diag_log format["No storage in %1", _town_name];
    };

    _name = format["storage_box_%1", _i];
    _i = _i + 1;


    _pos = AGLtoASL (_garage modelToWorld [0,0,0]);
    /*if (_garage isKindOf "Land_Shed_06_F") then {
      _pos set [2,0];
    };*/

    _model = ps_box_models call BIS_fnc_selectRandom;

    _box = createVehicle [_model, ASLtoATL _pos, [], 1, ""];
    _pos = getPosASL _box;
    _pos set [2, (_pos select 2) - (getPos _box select 2)];
    _box setPosASL _pos;
    //_box setPos _pos;
    _box setVectorDirAndUp [vectorDir _garage, vectorUp _garage];
    _box setVariable ["is_storage", true, true];
    [_box, _garage] call ps_setup_box;

    diag_log format["Creating Storage at: %1 (%2)", _town_name, _pos];
  }} foreach (call ps_get_all_cities);
};

if (["A3W_savingMethod", "profile"] call getPublicVar != "sock") then
{
  p_saveStorage = {
    params ["", "_obj"];

    private _storage =
    [
      ["Weapons", (getWeaponCargo _obj) call cargoToPairs],
      ["Magazines", _obj call fn_magazineAmmoCargo],
      ["Items", (getItemCargo _obj) call cargoToPairs],
      ["Backpacks", (getBackpackCargo _obj) call cargoToPairs]
    ];

    player setVariable ["private_storage", _storage];
    if (!isNil "fn_savePlayerData") then { [] spawn fn_savePlayerData };

    _storage
  };

  p_recreateStorageBox = {
    params ["", "_class"];

    private _obj = _class createVehicleLocal [0,0,1000];

    if (isNull _obj) exitWith {
      diag_log format["WARNING: Could not create storage container of class '%1'", _class];
    };

    _obj hideObject true;
    clearWeaponCargo _obj;
    clearMagazineCargo _obj;
    clearItemCargo _obj;
    clearBackpackCargo _obj;
    _obj setVariable ["is_obj_box", true];

    {
      _x params ["_name", "_value"];

      switch (_name) do
      {
        case "Weapons": { { _obj addWeaponCargoGlobal _x } forEach _value };
        case "Magazines": { [_obj, _value] call processMagazineCargo };
        case "Items": { { _obj addItemCargoGlobal _x } forEach _value };
        case "Backpacks": { { _obj addBackpackCargoGlobal _x } forEach _value };
      };
    } forEach (player getVariable ["private_storage", []]);

    _obj
  };
};

ps_inventory_ui_mod = {
  ARGVX3(0,_box,objNull);

  disableSerialization;
  waitUntil {!(isNull (findDisplay IDD_FUTURAGEAR))};
  def(_display);
  _display = findDisplay IDD_FUTURAGEAR;


  def(_outside);
  _outside = [-1,-1,0.1,0.1];

  def(_filter);
  _filter = _display displayCtrl IDC_FG_GROUND_FILTER;

  def(_pos);
  def(_ground_tab);
  _ground_tab = _display displayCtrl IDC_FG_GROUND_TAB;
  _pos = (ctrlPosition _ground_tab);
  _ground_tab ctrlSetPosition _outside;
  _ground_tab ctrlCommit 0;

  def(_custom_text);
  _custom_text = _display ctrlCreate ["RscText", -1];
  _pos set [2, (ctrlPosition _filter) select 2];
  _custom_text ctrlSetPosition _pos;
  _custom_text ctrlSetText "Private Storage";
  _custom_text ctrlSetBackgroundColor [0,0,0,1];
  _custom_text ctrlSetTextColor [1,1,1,1];
  _custom_text ctrlSetActiveColor [1,1,1,1];
  _custom_text ctrlSetTooltip "This storage is visible to you only.<br />It's automatically saved in the database,<br />and can be accessed across maps.";
  _custom_text ctrlCommit 0;

  def(_chosen_tab);
  _chosen_tab = _display displayCtrl IDC_FG_CHOSEN_TAB;
  _chosen_tab ctrlSetPosition _outside;
  _chosen_tab ctrlCommit 0;


  waitUntil {
    isNull (findDisplay IDD_FUTURAGEAR)
  };


  [player, _box] call p_saveStorage;
  deleteVehicle _box;
};

ps_access = {
  private["_box"];
  _box = [player, ps_container_class] call p_recreateStorageBox;

  if (isNil "_box") exitWith {
    player commandChat "ERROR: Could not access private storage, please report this error to A3Armory.com.";
  };

  _box attachTo [player, [0,0,3]];


  player removeAllEventHandlers "InventoryOpened";
  player addEventHandler ["InventoryOpened", {
    if (((_this select 1) getVariable ["is_storage_box", false])) exitWith {
      true
    };
    false
  }];

  player action ["Gear",  _box];
  player removeAllEventHandlers "InventoryOpened";
  [_box] spawn ps_inventory_ui_mod;
};

ps_cameraDir = {
  ([(positionCameraToWorld [0,0,0]), (positionCameraToWorld [0,0,1])] call BIS_fnc_vectorDiff)
};

ps_is_object_storage = {
  ARGVX4(0,_obj,objNull,false);
  (_obj getVariable ["is_storage", false])
};

ps_is_player_near = {
  private["_objects"];
  _objects = nearestObjects [player, ["Land_PaperBox_open_full_F", "Land_Pallet_MilBoxes_F", "Land_PaperBox_open_empty_F", "Land_PaperBox_closed_F"], 2];
  if (isNil "_objects") exitWith {false};

  private["_found"];
  _found = false;
  {
    if ([_x] call ps_is_object_storage) exitWith {
        _found = true;
      };
  } forEach _objects ;

  (_found)
};

ps_actions = OR(ps_actions,[]);

ps_remove_actions = {
    if (count ps_actions == 0) exitWith {};

    {
        private["_action_id"];
        _action_id = _x;
        player removeAction _action_id;
    } forEach ps_actions;
    ps_actions = [];
};

ps_add_actions = {
    if (count ps_actions > 0) exitWith {};
    private["_player"];
    _player = _this select 0;

  private["_action_id", "_text"];
  _action_id = _player addAction ["<img image='addons\storage\icons\storage.paa'/> Access Storage", {call ps_access}];
  ps_actions = ps_actions + [_action_id];
};

ps_check_actions = {
      private["_player"];
    _player = player;
    private["_vehicle", "_in_vehicle"];
    _vehicle = (vehicle _player);
    _in_vehicle = (_vehicle != _player);

    if (not(_in_vehicle || {not(alive _player) || {not(call ps_is_player_near)}})) exitWith {
      [_player] call ps_add_actions;
    };

   [_player] call ps_remove_actions;
};


ps_client_loop = {
  if (!hasInterface) exitWith {};

  while {true} do {
    call ps_check_actions;
    sleep 0.5;
  };
};


if (isServer) then
{
  diag_log "Setting up storage boxes ... ";
  [] call ps_create_boxes;
  ps_setup_boxes_complete = true;
  publicVariable "ps_setup_boxes_complete";
}
else
{
  diag_log "Waiting for storage boxes setup to complete ...";
  waitUntil {!isNil "ps_setup_boxes_complete"};
};

if (hasInterface) then
{
  waitUntil {!isNil "A3W_serverSetupComplete" && time > 0};
};

{
  _x call ps_setup_box;

  if (ps_markers_enabled) then
  {
    [format ["storage_box_%1", _forEachIndex + 1], getPosASL _x, ps_markers_properties] call ps_marker_create;
  };
} forEach ((allMissionObjects "All") select {_x getVariable ["is_storage",false]});

diag_log "Storage boxes setup complete";

[] spawn ps_client_loop;

storage_functions_defined = true;
diag_log "Loading storage functions complete";

 

Thx

Stefan

 

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×