[CODE title="fn_furnitureFetchHouses.sqf" highlight="60-84"]/*
Author: Louis Wood
Website: www.the-programmer.com
Discord: discord.the-programmer.com
Terms of use:
- This file is forbidden unless you have permission from the author. If you have this file without permission to use it please do not use it and do not share it.
- If you have permission to use this file, you can use it on your server however it is strictly forbidden to share it.
- Out of respect for the author please do not delete this information.
*/
params [
["_uid", "", [""]]
];
if (_uid isEqualTo "") exitWith {};
private _query = format ["SELECT classname, pos, inventory, gear, dir, id FROM containers WHERE pid='%1' AND owned='1'", _uid];
private _furnituresDB = [_query, 2, true] call DB_fnc_asyncCall;
_query = format ["SELECT pos FROM houses WHERE pid='%1' AND owned='1'", _uid];
private _houses = [_query, 2, true] call DB_fnc_asyncCall;
{
private _className = _x select 0;
private _furniturePos = call compile format ["%1", _x select 1];
private _trunk = [_x select 2] call DB_fnc_mresToArray;
private _gear = [_x select 3] call DB_fnc_mresToArray;
private _dir = call compile format ["%1", _x select 4];
private _id = _x select 5;
if (_trunk isEqualType "") then {_trunk = call compile format ["%1", _trunk];};
if (_gear isEqualType "") then {_gear = call compile format ["%1", _gear];};
private _furniture = createVehicle [_className, [0, 0, 999], [], 0, "NONE"];
waitUntil {!isNil "_furniture" && {!isNull _furniture}};
_furniture enableSimulationGlobal false;
_furniture allowDamage false;
_furniture enableRopeAttach false;
_furniture setPosATL _furniturePos;
_furniture setVectorDirAndUp _dir;
private _house = [_furniture, _houses] call tp_furnituresystem_fnc_furnitureGetHouse;
private _furnitures = _house getVariable ["containers", []];
_furniture setVariable ["House", _house, true];
_furniture setVariable ["Trunk", _trunk, true];
_furniture setVariable ["container_owner", [_uid], true];
_furniture setVariable ["container_id", _id, true];
clearWeaponCargoGlobal _furniture;
clearItemCargoGlobal _furniture;
clearMagazineCargoGlobal _furniture;
clearBackpackCargoGlobal _furniture;
[_furniture, _gear, _house] call tp_furnituresystem_fnc_furnitureCreateStorage;
_furnitures pushBack _furniture;
if (_className = "cequejeveux") then {
_furniture addAction[localize"STR_Process_LSD",life_fnc_processAction,"LSD",0,false,false,"",' life_inv_champignons > 0 && !life_is_processing && !life_action_inUse',5];
};
if (_className = "cequejeveux") then {
[] spawn { [
_furniture, // Mettre la variable du PNJ/Objet qui aura cette addAction - A MODIFIER IMPÉRATIVEMENT !!
"STR_Process_LSD", // Titre - A MODIFIER IMPÉRATIVEMENT !!
"a3\ui_f_oldman\data\igui\cfg\holdactions\holdaction_market_ca.paa", // Icone de l'addAction (voir point n°2)
"a3\ui_f_oldman\data\igui\cfg\holdactions\holdaction_market_ca.paa", // Icone de progression (voir point n°2)
"(player distance _target) < 5 && life_inv_champignons > 0 && !life_is_processing && !life_action_inUse", // Condition pour que l'action soit montrée
"(player distance _target) < 5", // Condition pour que l'acion soit activable
{}, // Code exécuté lors du démarrage de l'action
{}, // Code exécuté à chaque tic
{life_fnc_processAction}, // Code exécuté une fois terminé - A MODIFIER IMPÉRATIVEMENT !!
{}, // Code exécuté lorsqu'il est interrompu
[LSD], // Anciens arguments pour le script
1, // Durée
0, // Priorité
false, // Supprime l'action lorsqu'elle est exécutée
false // Montrer quand on est inconscient
] remoteExec ["BIS_fnc_holdActionAdd", -2, true]; };
};
_house setVariable ["containers", _furnitures, true];
} forEach _furnituresDB;
private _return = [];
{
_pos = call compile format ["%1", _x select 0];
_house = nearestObject [_pos, "House"];
_house allowDamage false;
_return pushBack [_x select 0];
} forEach _houses;
missionNamespace setVariable [format ["houses_%1", _uid], _return];
[/CODE]