Da ja einige das gewünscht hatten jetzt das Tutorial der Verwarstelle für AltisLife v4.4.R4+
Ich habe das die Datein auf den Stand des Git Repos gebracht
Update vom Stand 20.10
Also Fangen wir an
In der Life Server zu Ändern sind :
fn_getVehicles.sqf
Spoiler anzeigen
C
#include "\life_server\script_macros.hpp"
/*
File: fn_getVehicles.sqf
Author: Bryan "Tonic" Boardwine
Description:
Sends a request to query the database information and returns vehicles.
*/
private ["_pid","_side","_type","_unit","_ret","_tickTime","_queryResult"];
_pid = [_this,0,"",[""]] call BIS_fnc_param;
_side = [_this,1,sideUnknown,[west]] call BIS_fnc_param;
_type = [_this,2,"",[""]] call BIS_fnc_param;
_unit = [_this,3,objNull,[objNull]] call BIS_fnc_param;
//Error checks
if (_pid isEqualTo "" || _side isEqualTo sideUnknown || _type isEqualTo "" || isNull _unit) exitWith {
if (!isNull _unit) then {
[[]] remoteExec ["life_fnc_impoundMenu",(owner _unit)];
};
};
_unit = owner _unit;
_side = switch (_side) do {
case west:{"cop"};
case civilian: {"civ"};
case independent: {"med"};
default {"Error"};
};
if (_side == "Error") exitWith {
[[]] remoteExec ["life_fnc_impoundMenu",(owner _unit)];
};
_query = format ["SELECT id, side, classname, type, pid, alive, active, plate, color FROM vehicles WHERE pid='%1' AND alive='1' AND active='0' AND impound='0' AND side='%2' AND type='%3'",_pid,_side,_type];
_tickTime = diag_tickTime;
_queryResult = [_query,2,true] call DB_fnc_asyncCall;
if (EXTDB_SETTING(getNumber,"DebugMode") isEqualTo 1) then {
diag_log "------------- Client Query Request -------------";
diag_log format ["QUERY: %1",_query];
diag_log format ["Time to complete: %1 (in seconds)",(diag_tickTime - _tickTime)];
diag_log format ["Result: %1",_queryResult];
diag_log "------------------------------------------------";
};
if (_queryResult isEqualType "") exitWith {
[[]] remoteExec ["life_fnc_impoundMenu",(owner _unit)];
};
[_queryResult] remoteExec ["life_fnc_impoundMenu",_unit];
Alles anzeigen
Neue Datei in \functions\System\fn_getImpoundedvehicles.sqf
Spoiler anzeigen
C
#include "\life_server\script_macros.hpp"
/*
File: fn_getImpoundedvehicles.sqf
Author: Bryan "Tonic" Boardwine
Description:
Sends a request to query the database information and returns vehicles.
*/
private ["_pid","_side","_type","_unit","_ret","_tickTime","_queryResult"];
_pid = [_this,0,"",[""]] call BIS_fnc_param;
_side = [_this,1,sideUnknown,[west]] call BIS_fnc_param;
_type = [_this,2,"",[""]] call BIS_fnc_param;
_unit = [_this,3,objNull,[objNull]] call BIS_fnc_param;
//Error checks
if (_pid isEqualTo "" || _side isEqualTo sideUnknown || _type isEqualTo "" || isNull _unit) exitWith {
if (!isNull _unit) then {
[[]] remoteExec ["life_fnc_impoundedMenu",(owner _unit)];
};
};
_unit = owner _unit;
_side = switch (_side) do {
case west:{"cop"};
case civilian: {"civ"};
case independent: {"med"};
default {"Error"};
};
if (_side == "Error") exitWith {
[[]] remoteExec ["life_fnc_impoundedMenu",(owner _unit)];
};
_query = format ["SELECT id, side, classname, type, pid, alive, active, plate, color FROM vehicles WHERE pid='%1' AND alive='1' AND active='0' AND impound='1' AND side='%2' AND type='%3'",_pid,_side,_type];
_tickTime = diag_tickTime;
_queryResult = [_query,2,true] call DB_fnc_asyncCall;
if (EXTDB_SETTING(getNumber,"DebugMode") isEqualTo 1) then {
diag_log "------------- Client Query Request -------------";
diag_log format ["QUERY: %1",_query];
diag_log format ["Time to complete: %1 (in seconds)",(diag_tickTime - _tickTime)];
diag_log format ["Result: %1",_queryResult];
diag_log "------------------------------------------------";
};
if (_queryResult isEqualType "") exitWith {
[[]] remoteExec ["life_fnc_impoundedMenu",(owner _unit)];
};
[_queryResult] remoteExec ["life_fnc_impoundedMenu",_unit];
Alles anzeigen
fn_spawnvehicle.sqf
Spoiler anzeigen
C
#include "\life_server\script_macros.hpp"
/*
File: fn_spawnVehicle.sqf
Author: Bryan "Tonic" Boardwine
Description:
Sends the query request to the database, if an array is returned then it creates
the vehicle if it's not in use or dead.
*/
private ["_vid","_sp","_pid","_query","_sql","_vehicle","_nearVehicles","_name","_side","_tickTime","_dir","_servIndex","_damage","_wasIllegal","_location","_thread"];
_vid = [_this,0,-1,[0]] call BIS_fnc_param;
_pid = [_this,1,"",[""]] call BIS_fnc_param;
_sp = [_this,2,[],[[],""]] call BIS_fnc_param;
_unit = [_this,3,objNull,[objNull]] call BIS_fnc_param;
_price = [_this,4,0,[0]] call BIS_fnc_param;
_dir = [_this,5,0,[0]] call BIS_fnc_param;
_spawntext = _this select 6;
_unit_return = _unit;
_name = name _unit;
_side = side _unit;
_unit = owner _unit;
if (_vid isEqualTo -1 || _pid isEqualTo "") exitWith {};
if (_vid in serv_sv_use) exitWith {};
serv_sv_use pushBack _vid;
_servIndex = serv_sv_use find _vid;
_query = format ["SELECT id, side, classname, type, pid, alive, active, plate, color, inventory, gear, fuel, damage, blacklist, impound FROM vehicles WHERE id='%1' AND pid='%2'",_vid,_pid];
_tickTime = diag_tickTime;
_queryResult = [_query,2] call DB_fnc_asyncCall;
if (EXTDB_SETTING(getNumber,"DebugMode") isEqualTo 1) then {
diag_log "------------- Client Query Request -------------";
diag_log format ["QUERY: %1",_query];
diag_log format ["Time to complete: %1 (in seconds)",(diag_tickTime - _tickTime)];
diag_log format ["Result: %1",_queryResult];
diag_log "------------------------------------------------";
};
if (_queryResult isEqualType "") exitWith {};
_vInfo = _queryResult;
if (isNil "_vInfo") exitWith {serv_sv_use deleteAt _servIndex;};
if (count _vInfo isEqualTo 0) exitWith {serv_sv_use deleteAt _servIndex;};
if ((_vInfo select 5) isEqualTo 0) exitWith {
serv_sv_use deleteAt _servIndex;
[1,"STR_Garage_SQLError_Destroyed",true,[_vInfo select 2]] remoteExecCall ["life_fnc_broadcast",_unit];
};
if ((_vInfo select 6) isEqualTo 1) exitWith {
serv_sv_use deleteAt _servIndex;
[1,"STR_Garage_SQLError_Active",true,[_vInfo select 2]] remoteExecCall ["life_fnc_broadcast",_unit];
};
if (!(_sp isEqualType "")) then {
_nearVehicles = nearestObjects[_sp,["Car","Air","Ship"],10];
} else {
_nearVehicles = [];
};
if (count _nearVehicles > 0) exitWith {
serv_sv_use deleteAt _servIndex;
[_price,_unit_return] remoteExecCall ["life_fnc_garageRefund",_unit];
[1,"STR_Garage_SpawnPointError",true] remoteExecCall ["life_fnc_broadcast",_unit];
};
_query = format ["UPDATE vehicles SET active='1', impound='0', damage='""[]""' WHERE pid='%1' AND id='%2'",_pid,_vid];
_trunk = [(_vInfo select 9)] call DB_fnc_mresToArray;
_gear = [(_vInfo select 10)] call DB_fnc_mresToArray;
_damage = [(_vInfo select 12)] call DB_fnc_mresToArray;
_wasIllegal = (_vInfo select 13);
_wasIllegal = if (_wasIllegal isEqualTo 1) then { true } else { false };
[_query,1] call DB_fnc_asyncCall;
if (_sp isEqualType "") then {
_vehicle = createVehicle[(_vInfo select 2),[0,0,999],[],0,"NONE"];
waitUntil {!isNil "_vehicle" && {!isNull _vehicle}};
_vehicle allowDamage false;
_hs = nearestObjects[getMarkerPos _sp,["Land_Hospital_side2_F"],50] select 0;
_vehicle setPosATL (_hs modelToWorld [-0.4,-4,12.65]);
uiSleep 0.6;
} else {
_vehicle = createVehicle [(_vInfo select 2),_sp,[],0,"NONE"];
waitUntil {!isNil "_vehicle" && {!isNull _vehicle}};
_vehicle allowDamage false;
_vehicle setPos _sp;
_vehicle setVectorUp (surfaceNormal _sp);
_vehicle setDir _dir;
};
_vehicle allowDamage true;
//Send keys over the network.
[_vehicle] remoteExecCall ["life_fnc_addVehicle2Chain",_unit];
[_pid,_side,_vehicle,1] call TON_fnc_keyManagement;
_vehicle lock 2;
//Reskin the vehicle
[_vehicle,(_vInfo select 8)] remoteExecCall ["life_fnc_colorVehicle",_unit];
_vehicle setVariable ["vehicle_info_owners",[[_pid,_name]],true];
_vehicle setVariable ["dbInfo",[(_vInfo select 4),(_vInfo select 7)],true];
_vehicle disableTIEquipment true; //No Thermals.. They're cheap but addictive.
[_vehicle] call life_fnc_clearVehicleAmmo;
// Avoid problems if u keep changing which stuff to save!
if (LIFE_SETTINGS(getNumber,"save_vehicle_virtualItems") isEqualTo 1) then {
_vehicle setVariable ["Trunk",_trunk,true];
if (_wasIllegal) then {
if (_sp isEqualType "") then {
_location= (nearestLocations [getPos _sp,["NameCityCapital","NameCity","NameVillage"],1000]) select 0;
} else {
_location= (nearestLocations [_sp,["NameCityCapital","NameCity","NameVillage"],1000]) select 0;
};
_location = text _location;
[1,"STR_NOTF_BlackListedVehicle",true,[_location,_name]] remoteExecCall ["life_fnc_broadcast",west];
_query = format ["UPDATE vehicles SET blacklist='0' WHERE id='%1' AND pid='%2'",_vid,_pid];
_thread = [_query,1] call DB_fnc_asyncCall;
};
}else{
_vehicle setVariable ["Trunk",[[],0],true];
};
if (LIFE_SETTINGS(getNumber,"save_vehicle_fuel") isEqualTo 1) then {
_vehicle setFuel (_vInfo select 11);
}else{
_vehicle setFuel 1;
};
if (count _gear > 0 && (LIFE_SETTINGS(getNumber,"save_vehicle_inventory") isEqualTo 1)) then {
_items = _gear select 0;
_mags = _gear select 1;
_weapons = _gear select 2;
_backpacks = _gear select 3;
for "_i" from 0 to ((count (_items select 0)) - 1) do {
_vehicle addItemCargoGlobal [((_items select 0) select _i), ((_items select 1) select _i)];
};
for "_i" from 0 to ((count (_mags select 0)) - 1) do {
_vehicle addMagazineCargoGlobal [((_mags select 0) select _i), ((_mags select 1) select _i)];
};
for "_i" from 0 to ((count (_weapons select 0)) - 1) do {
_vehicle addWeaponCargoGlobal [((_weapons select 0) select _i), ((_weapons select 1) select _i)];
};
for "_i" from 0 to ((count (_backpacks select 0)) - 1) do {
_vehicle addBackpackCargoGlobal [((_backpacks select 0) select _i), ((_backpacks select 1) select _i)];
};
};
if (count _damage > 0 && (LIFE_SETTINGS(getNumber,"save_vehicle_damage") isEqualTo 1)) then {
_parts = getAllHitPointsDamage _vehicle;
for "_i" from 0 to ((count _damage) - 1) do {
_vehicle setHitPointDamage [format ["%1",((_parts select 0) select _i)],_damage select _i];
};
};
//Sets of animations
if ((_vInfo select 1) isEqualTo "civ" && (_vInfo select 2) isEqualTo "B_Heli_Light_01_F" && !((_vInfo select 8) isEqualTo 13)) then {
[_vehicle,"civ_littlebird",true] remoteExecCall ["life_fnc_vehicleAnimate",_unit];
};
if ((_vInfo select 1) isEqualTo "cop" && ((_vInfo select 2)) in ["C_Offroad_01_F","B_MRAP_01_F","C_SUV_01_F","C_Hatchback_01_sport_F","B_Heli_Light_01_F","B_Heli_Transport_01_F"]) then {
[_vehicle,"cop_offroad",true] remoteExecCall ["life_fnc_vehicleAnimate",_unit];
};
if ((_vInfo select 1) isEqualTo "med" && (_vInfo select 2) isEqualTo "C_Offroad_01_F") then {
[_vehicle,"med_offroad",true] remoteExecCall ["life_fnc_vehicleAnimate",_unit];
};
[1,_spawntext] remoteExecCall ["life_fnc_broadcast",_unit];
serv_sv_use deleteAt _servIndex;
Alles anzeigen
Neue Datei \Function\System\fn_vehicleImpound.sqf
Spoiler anzeigen
C
#include "\life_server\script_macros.hpp"
/*
File: fn_vehicleStore.sqf
Author: Bryan "Tonic" Boardwine
Description:
Stores the vehicle in the 'Garage'
*/
private ["_vehicle","_impound","_vInfo","_vInfo","_plate","_uid","_query","_sql","_unit","_trunk","_vehItems","_vehMags","_vehWeapons","_vehBackpacks","_cargo","_saveItems","_storetext","_resourceItems","_fuel","_damage","_itemList","_totalweight","_weight","_thread"];
_vehicle = [_this,0,objNull,[objNull]] call BIS_fnc_param;
_impound = [_this,1,false,[true]] call BIS_fnc_param;
_unit = [_this,2,objNull,[objNull]] call BIS_fnc_param;
_storetext = [_this,3,"",[""]] call BIS_fnc_param;
_resourceItems = LIFE_SETTINGS(getArray,"save_vehicle_items");
if (isNull _vehicle || isNull _unit) exitWith {life_impound_inuse = false; (owner _unit) publicVariableClient "life_impound_inuse";life_garage_store = false;(owner _unit) publicVariableClient "life_garage_store";}; //Bad data passed.
_vInfo = _vehicle getVariable ["dbInfo",[]];
if (count _vInfo > 0) then {
_plate = _vInfo select 1;
_uid = _vInfo select 0;
};
// save damage.
if (LIFE_SETTINGS(getNumber,"save_vehicle_damage") isEqualTo 1) then {
_damage = getAllHitPointsDamage _vehicle;
_damage = _damage select 2;
} else {
_damage = [];
};
_damage = [_damage] call DB_fnc_mresArray;
// because fuel price!
if (LIFE_SETTINGS(getNumber,"save_vehicle_fuel") isEqualTo 1) then {
_fuel = (fuel _vehicle);
} else {
_fuel = 1;
};
if (_impound) exitWith {
if (count _vInfo isEqualTo 0) then {
life_impound_inuse = false;
(owner _unit) publicVariableClient "life_impound_inuse";
if (!isNil "_vehicle" && {!isNull _vehicle}) then {
deleteVehicle _vehicle;
};
} else { // no free repairs!
_query = format ["UPDATE vehicles SET active='0', impound='1', fuel='%3', damage='%4' WHERE pid='%1' AND plate='%2'",_uid , _plate, _fuel, _damage];
_thread = [_query,1] call DB_fnc_asyncCall;
if (!isNil "_vehicle" && {!isNull _vehicle}) then {
deleteVehicle _vehicle;
};
life_impound_inuse = false;
(owner _unit) publicVariableClient "life_impound_inuse";
};
};
// not persistent so just do this!
if (count _vInfo isEqualTo 0) exitWith {
[1,"STR_Garage_Store_NotPersistent",true] remoteExecCall ["life_fnc_broadcast",(owner _unit)];
life_garage_store = false;
(owner _unit) publicVariableClient "life_garage_store";
};
if (_uid != getPlayerUID _unit) exitWith {
[1,"STR_Garage_Store_NoOwnership",true] remoteExecCall ["life_fnc_broadcast",(owner _unit)];
life_garage_store = false;
(owner _unit) publicVariableClient "life_garage_store";
};
// sort out whitelisted items!
_trunk = _vehicle getVariable ["Trunk", [[], 0]];
_itemList = _trunk select 0;
_totalweight = 0;
_items = [];
if (LIFE_SETTINGS(getNumber,"save_vehicle_virtualItems") isEqualTo 1) then {
if (LIFE_SETTINGS(getNumber,"save_vehicle_illegal") isEqualTo 1) then {
private ["_isIllegal", "_blacklist"];
_blacklist = false;
_profileQuery = format ["SELECT name FROM players WHERE pid='%1'", _uid];
_profileName = [_profileQuery, 2] call DB_fnc_asyncCall;
_profileName = _profileName select 0;
{
_isIllegal = M_CONFIG(getNumber,"VirtualItems",(_x select 0),"illegal");
_isIllegal = if (_isIllegal isEqualTo 1) then { true } else { false };
if (((_x select 0) in _resourceItems) || (_isIllegal)) then {
_items pushBack[(_x select 0),(_x select 1)];
_weight = (ITEM_WEIGHT(_x select 0)) * (_x select 1);
_totalweight = _weight + _totalweight;
};
if (_isIllegal) then {
_blacklist = true;
};
}
foreach _itemList;
if (_blacklist) then {
[_uid, _profileName, "481"] remoteExecCall["life_fnc_wantedAdd", RSERV];
_query = format ["UPDATE vehicles SET blacklist='1' WHERE pid='%1' AND plate='%2'", _uid, _plate];
_thread = [_query, 1] call DB_fnc_asyncCall;
};
}
else {
{
if ((_x select 0) in _resourceItems) then {
_items pushBack[(_x select 0),(_x select 1)];
_weight = (ITEM_WEIGHT(_x select 0)) * (_x select 1);
_totalweight = _weight + _totalweight;
};
}
forEach _itemList;
};
_trunk = [_items, _totalweight];
}
else {
_trunk = [[], 0];
};
if (LIFE_SETTINGS(getNumber,"save_vehicle_inventory") isEqualTo 1) then {
_vehItems = getItemCargo _vehicle;
_vehMags = getMagazineCargo _vehicle;
_vehWeapons = getWeaponCargo _vehicle;
_vehBackpacks = getBackpackCargo _vehicle;
_cargo = [_vehItems,_vehMags,_vehWeapons,_vehBackpacks];
// no items? clean the array so the database looks pretty
if ((count (_vehItems select 0) isEqualTo 0) && (count (_vehMags select 0) isEqualTo 0) && (count (_vehWeapons select 0) isEqualTo 0) && (count (_vehBackpacks select 0) isEqualTo 0)) then {_cargo = [];};
} else {
_cargo = [];
};
// prepare
_trunk = [_trunk] call DB_fnc_mresArray;
_cargo = [_cargo] call DB_fnc_mresArray;
// update
_query = format ["UPDATE vehicles SET active='0', impound='1', inventory='%3', gear='%4', fuel='%5', damage='%6' WHERE pid='%1' AND plate='%2'", _uid, _plate, _trunk, _cargo, _fuel, _damage];
_thread = [_query,1] call DB_fnc_asyncCall;
if (!isNil "_vehicle" && {!isNull _vehicle}) then {
deleteVehicle _vehicle;
};
life_garage_store = false;
(owner _unit) publicVariableClient "life_garage_store";
[1,_storetext] remoteExecCall ["life_fnc_broadcast",(owner _unit)];
Alles anzeigen
fn_vehicleStore.sqf
Spoiler anzeigen
C
#include "\life_server\script_macros.hpp"
/*
File: fn_vehicleStore.sqf
Author: Bryan "Tonic" Boardwine
Description:
Stores the vehicle in the 'Garage'
*/
private ["_vehicle","_impound","_vInfo","_vInfo","_plate","_uid","_query","_sql","_unit","_trunk","_vehItems","_vehMags","_vehWeapons","_vehBackpacks","_cargo","_saveItems","_storetext","_resourceItems","_fuel","_damage","_itemList","_totalweight","_weight","_thread"];
_vehicle = [_this,0,objNull,[objNull]] call BIS_fnc_param;
_impound = [_this,1,false,[true]] call BIS_fnc_param;
_unit = [_this,2,objNull,[objNull]] call BIS_fnc_param;
_storetext = [_this,3,"",[""]] call BIS_fnc_param;
_resourceItems = LIFE_SETTINGS(getArray,"save_vehicle_items");
if (isNull _vehicle || isNull _unit) exitWith {life_impound_inuse = false; (owner _unit) publicVariableClient "life_impound_inuse";life_garage_store = false;(owner _unit) publicVariableClient "life_garage_store";}; //Bad data passed.
_vInfo = _vehicle getVariable ["dbInfo",[]];
if (count _vInfo > 0) then {
_plate = _vInfo select 1;
_uid = _vInfo select 0;
};
// save damage.
if (LIFE_SETTINGS(getNumber,"save_vehicle_damage") isEqualTo 1) then {
_damage = getAllHitPointsDamage _vehicle;
_damage = _damage select 2;
} else {
_damage = [];
};
_damage = [_damage] call DB_fnc_mresArray;
// because fuel price!
if (LIFE_SETTINGS(getNumber,"save_vehicle_fuel") isEqualTo 1) then {
_fuel = (fuel _vehicle);
} else {
_fuel = 1;
};
if (_impound) exitWith {
if (count _vInfo isEqualTo 0) then {
life_impound_inuse = false;
(owner _unit) publicVariableClient "life_impound_inuse";
if (!isNil "_vehicle" && {!isNull _vehicle}) then {
deleteVehicle _vehicle;
};
} else { // no free repairs!
_query = format ["UPDATE vehicles SET active='0', impound='0', fuel='%3', damage='%4' WHERE pid='%1' AND plate='%2'",_uid , _plate, _fuel, _damage];
_thread = [_query,1] call DB_fnc_asyncCall;
if (!isNil "_vehicle" && {!isNull _vehicle}) then {
deleteVehicle _vehicle;
};
life_impound_inuse = false;
(owner _unit) publicVariableClient "life_impound_inuse";
};
};
// not persistent so just do this!
if (count _vInfo isEqualTo 0) exitWith {
[1,"STR_Garage_Store_NotPersistent",true] remoteExecCall ["life_fnc_broadcast",(owner _unit)];
life_garage_store = false;
(owner _unit) publicVariableClient "life_garage_store";
};
if (_uid != getPlayerUID _unit) exitWith {
[1,"STR_Garage_Store_NoOwnership",true] remoteExecCall ["life_fnc_broadcast",(owner _unit)];
life_garage_store = false;
(owner _unit) publicVariableClient "life_garage_store";
};
// sort out whitelisted items!
_trunk = _vehicle getVariable ["Trunk", [[], 0]];
_itemList = _trunk select 0;
_totalweight = 0;
_items = [];
if (LIFE_SETTINGS(getNumber,"save_vehicle_virtualItems") isEqualTo 1) then {
if (LIFE_SETTINGS(getNumber,"save_vehicle_illegal") isEqualTo 1) then {
private ["_isIllegal", "_blacklist"];
_blacklist = false;
_profileQuery = format ["SELECT name FROM players WHERE pid='%1'", _uid];
_profileName = [_profileQuery, 2] call DB_fnc_asyncCall;
_profileName = _profileName select 0;
{
_isIllegal = M_CONFIG(getNumber,"VirtualItems",(_x select 0),"illegal");
_isIllegal = if (_isIllegal isEqualTo 1) then { true } else { false };
if (((_x select 0) in _resourceItems) || (_isIllegal)) then {
_items pushBack[(_x select 0),(_x select 1)];
_weight = (ITEM_WEIGHT(_x select 0)) * (_x select 1);
_totalweight = _weight + _totalweight;
};
if (_isIllegal) then {
_blacklist = true;
};
}
foreach _itemList;
if (_blacklist) then {
[_uid, _profileName, "481"] remoteExecCall["life_fnc_wantedAdd", RSERV];
_query = format ["UPDATE vehicles SET blacklist='1' WHERE pid='%1' AND plate='%2'", _uid, _plate];
_thread = [_query, 1] call DB_fnc_asyncCall;
};
}
else {
{
if ((_x select 0) in _resourceItems) then {
_items pushBack[(_x select 0),(_x select 1)];
_weight = (ITEM_WEIGHT(_x select 0)) * (_x select 1);
_totalweight = _weight + _totalweight;
};
}
forEach _itemList;
};
_trunk = [_items, _totalweight];
}
else {
_trunk = [[], 0];
};
if (LIFE_SETTINGS(getNumber,"save_vehicle_inventory") isEqualTo 1) then {
_vehItems = getItemCargo _vehicle;
_vehMags = getMagazineCargo _vehicle;
_vehWeapons = getWeaponCargo _vehicle;
_vehBackpacks = getBackpackCargo _vehicle;
_cargo = [_vehItems,_vehMags,_vehWeapons,_vehBackpacks];
// no items? clean the array so the database looks pretty
if ((count (_vehItems select 0) isEqualTo 0) && (count (_vehMags select 0) isEqualTo 0) && (count (_vehWeapons select 0) isEqualTo 0) && (count (_vehBackpacks select 0) isEqualTo 0)) then {_cargo = [];};
} else {
_cargo = [];
};
// prepare
_trunk = [_trunk] call DB_fnc_mresArray;
_cargo = [_cargo] call DB_fnc_mresArray;
// update
_query = format ["UPDATE vehicles SET active='0', impound='0', inventory='%3', gear='%4', fuel='%5', damage='%6' WHERE pid='%1' AND plate='%2'", _uid, _plate, _trunk, _cargo, _fuel, _damage];
_thread = [_query,1] call DB_fnc_asyncCall;
if (!isNil "_vehicle" && {!isNull _vehicle}) then {
deleteVehicle _vehicle;
};
life_garage_store = false;
(owner _unit) publicVariableClient "life_garage_store";
[1,_storetext] remoteExecCall ["life_fnc_broadcast",(owner _unit)];
Alles anzeigen
fn_insertVehicle.sqf
Spoiler anzeigen
C
/*
File: fn_insertVehicle.sqf
Author: Bryan "Tonic" Boardwine
Description:
Inserts the vehicle into the database
*/
private ["_query","_sql"];
params [
"_uid",
"_side",
"_type",
"_className",
["_color",-1,[0]],
["_plate",-1,[0]]
];
//Stop bad data being passed.
if (_uid isEqualTo "" || _side isEqualTo "" || _type isEqualTo "" || _className isEqualTo "" || _color isEqualTo -1 || _plate isEqualTo -1) exitWith {};
_query = format ["INSERT INTO vehicles (side, classname, type, pid, alive, active, inventory, color, plate, gear, damage, impound) VALUES ('%1', '%2', '%3', '%4', '1','1','""[[],0]""', '%5', '%6','""[]""','""[]""','0')",_side,_className,_type,_uid,_color,_plate];
[_query,1] call DB_fnc_asyncCall;
Alles anzeigen
und in der config.cpp
Spoiler anzeigen
Das dürfte es auch schon gewesen sein.