Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DT_fnc_saveVehicleDB = {
- params [
- ['_vehicleData',[],[[]]]
- ];
- _vehicleData params ['_classname','_shopClass','_colorData','_materialData','_paintData'];
- private _players = allPlayers select {(owner _x) isEqualTo remoteExecutedOwner};
- if (_players isEqualTo []) exitWith {};
- private _player = _players select 0;
- private _uid = getPlayerUID _player;
- // Create
- private _vehicle = objNull;
- private _createVehicle = getNumber (missionConfigFile >> "vehshop_config" >> "Shops" >> _shopClass >> "createVehicle");
- if (_createVehicle isEqualTo 1) then {
- private _spawnMarker = getText (missionConfigFile >> "vehshop_config" >> "Shops" >> _shopClass >> "spawnPointMarker");
- private _markerPos = getMarkerPos _spawnMarker;
- if (_markerPos isEqualTo [0,0,0]) then {_markerPos = getPos _player}; // Marker is undefined, spawn neaby player.
- _markerPos = [_markerPos, 1, 50, 8, 1, 20, 0, [], _markerPos] call BIS_fnc_findSafePos;
- _vehicle = _classname createVehicle _markerPos;
- _player moveInAny _vehicle;
- [_vehicle,[_colorData,_materialData,_paintData]] call DT_fnc_colorVehicle;
- };
- // Life Framework
- if (isNil {DB_fnc_asyncCall}) exitWith {}; // we dont have life framework
- private _type = switch (true) do {
- case (_classname isKindOf "Car"): {"Car"};
- case (_classname isKindOf "Air"): {"Air"};
- case (_classname isKindOf "Ship"): {"Ship"};
- default {"Car"}
- };
- private _side = switch (side _player) do {
- case west:{"cop"};
- case civilian: {"civ"};
- case independent: {"med"};
- default {"civ"};
- };
- private _plate = round(random(1000000));
- private _query = format ["
- INSERT INTO vehicles (side, classname, type, pid, alive, active, inventory, color, plate, gear, damage, texdata)
- VALUES ('%1', '%2', '%3', '%4', '%8','1','""[[],0]""', '%5', '%6','""[]""','""[]""', '%7')
- ",_side,_classname,_type,_uid,0,_plate,[_colorData,_materialData,_paintData],_createVehicle];
- [_query,1] call DB_fnc_asyncCall;
- // Key management
- [_vehicle] remoteExecCall ["life_fnc_addVehicle2Chain",_player];
- _vehicle setVariable ["dbInfo",[_uid,_plate],true];
- [_uid,side _player,_vehicle,1] call TON_fnc_keyManagement;
- _vehicle setVariable ["vehicle_info_owners",[[_uid,name _player]],true];
- _vehicle disableTIEquipment true;
- [_vehicle] call life_fnc_clearVehicleAmmo;
- };
- DT_fnc_colorVehicle = {
- params [
- ['_vehicle',objNull,[objNull]],
- ['_data',["",-1,[]],[[]]]
- ];
- _data params ['_colorData','_materialData','_paintData'];
- _vehicle setVariable ['shopData',_data,true];
- if !(_colorData isEqualTo '') then {_vehicle setObjectTextureGlobal [0,_colorData]};
- if !(_materialData isEqualTo -1) then {
- private _materials = getArray (missionConfigFile >> "vehshop_config" >> "materials");
- if (_materialData > (count _materials - 1)) exitWith {};
- private _material = (_materials select _materialData) select 1;
- _vehicle setObjectMaterialGlobal [0,_material];
- };
- if !(_paintData isEqualTo []) then {
- _paintData params ['_source','_sourceIndex'];
- switch (_source) do {
- case "textureSources": {
- private _textures = ('true' configClasses (configFile >> "CfgVehicles" >> typeOf _vehicle >> "textureSources")) apply {
- private _texture = (getArray (_x >> "textures")) select 0;
- _texture
- };
- private _texture = _textures select _sourceIndex;
- _vehicle setObjectTextureGlobal [0,_texture];
- };
- default {
- private _textures = getArray (missionConfigFile >> "vehshop_config" >> "Shops" >> _source >> typeOf _vehicle >> "customTextures");
- if (_sourceIndex > (count _textures - 1)) exitWith {};
- _textures = _textures apply {_x select 1};
- private _texture = _textures select _sourceIndex;
- _vehicle setObjectTextureGlobal [0,_texture];
- };
- };
- };
- };
Add Comment
Please, Sign In to add comment