From c0d38c824ca7c248edab5f2f3e970c2e456f3299 Mon Sep 17 00:00:00 2001 From: vbawol Date: Wed, 20 Feb 2013 11:27:42 -0600 Subject: [PATCH] 0.972 + recoded vehicle lock/unlock code fixes #69 + added "vehicle locked" addaction. fixes #116 + added cargo check to all vehicles fixes #115 --- dayz_code/actions/cargocheck.sqf | 24 +++++++++++++ dayz_code/compile/fn_selfActions.sqf | 36 +++++++++++++++---- dayz_code/init/variables.sqf | 1 + dayz_server/compile/server_publishVehicle.sqf | 2 ++ 4 files changed, 56 insertions(+), 7 deletions(-) create mode 100644 dayz_code/actions/cargocheck.sqf diff --git a/dayz_code/actions/cargocheck.sqf b/dayz_code/actions/cargocheck.sqf new file mode 100644 index 000000000..29b446775 --- /dev/null +++ b/dayz_code/actions/cargocheck.sqf @@ -0,0 +1,24 @@ +private["_vehicle"]; +_vehicle = _this select 3; + +_class = typeOf _vehicle; + +// Get max magazines count +_maxMagazines = getNumber (configFile >> "CfgVehicles" >> _class >> "transportMaxMagazines"); + +// Get max weapon count +_maxWeapons = getNumber (configFile >> "CfgVehicles" >> _class >> "transportMaxWeapons"); + +// Get max backpack count +_maxBackpacks = getNumber (configFile >> "CfgVehicles" >> _class >> "transportmaxbackpacks"); + +// Count and show magazines available space +_magazineCount = count (getMagazineCargo _vehicle); + +// Count and show weapons available space +_weaponsCount = count (getWeaponCargo _vehicle); + +// Count and show backpacks available space +_backpackCount = count (getBackpackCargo _vehicle); + +cutText [format[("Magazine %1 / %2 - Weapons %3 / %4 - Backpacks %5 / %6"),_magazineCount,_maxMagazines,_weaponsCount,_maxWeapons,_backpackCount,_maxBackpacks], "PLAIN DOWN"]; \ No newline at end of file diff --git a/dayz_code/compile/fn_selfActions.sqf b/dayz_code/compile/fn_selfActions.sqf index 67d1f10e0..128cb624a 100644 --- a/dayz_code/compile/fn_selfActions.sqf +++ b/dayz_code/compile/fn_selfActions.sqf @@ -101,16 +101,28 @@ if (!isNull cursorTarget and !_inVehicle and (player distance cursorTarget < 6)) // Allow Owner to lock and unlock vehicle - if(_isVehicle and !_isMan and _canDo and _ownerID != "0" and _ownerID == dayz_playerUID) then { + if(_isVehicle and !_isMan and _canDo and _ownerID != "0") then { if (s_player_lockUnlock_crtl < 0) then { - _Unlock = player addAction [format["Unlock %1",_text], "\z\addons\dayz_code\actions\unlock_veh.sqf",cursorTarget, 2, true, true, "", "(locked cursorTarget)"]; - _lock = player addAction [format["Lock %1",_text], "\z\addons\dayz_code\actions\lock_veh.sqf",cursorTarget, 1, true, true, "", "(!locked cursorTarget)"]; - - s_player_lockunlock set [count s_player_lockunlock,_Unlock]; - s_player_lockunlock set [count s_player_lockunlock,_lock]; - s_player_lockUnlock_crtl = 1; + if(locked cursorTarget) then { + if(_ownerID == dayz_playerUID) then { + _Unlock = player addAction [format["Unlock %1",_text], "\z\addons\dayz_code\actions\unlock_veh.sqf",cursorTarget, 2, true, true, "", ""]; + s_player_lockunlock set [count s_player_lockunlock,_Unlock]; + s_player_lockUnlock_crtl = 1; + } else { + _Unlock = player addAction ["Vehicle Locked", "",cursorTarget, 2, true, true, "", ""]; + s_player_lockunlock set [count s_player_lockunlock,_Unlock]; + s_player_lockUnlock_crtl = 1; + }; + } else { + if(_ownerID == dayz_playerUID) then { + _lock = player addAction [format["Lock %1",_text], "\z\addons\dayz_code\actions\lock_veh.sqf",cursorTarget, 1, true, true, "", ""]; + s_player_lockunlock set [count s_player_lockunlock,_lock]; + s_player_lockUnlock_crtl = 1; + }; + }; + }; } else { @@ -129,6 +141,16 @@ if (!isNull cursorTarget and !_inVehicle and (player distance cursorTarget < 6)) s_player_forceSave = -1; }; */ + + if((_isVehicle or _isTent) and _canDo and !_isMan) then { + if (s_player_checkGear < 0) then { + s_player_checkGear = player addAction ["Cargo Check", "\z\addons\dayz_code\actions\checkcargo.sqf",cursorTarget, 1, true, true, "", ""]; + }; + } else { + player removeAction s_player_checkGear; + s_player_checkGear = -1; + }; + //flip vehicle if ((_isVehicletype) and !_canmove and _isAlive and (player distance cursorTarget >= 2) and (count (crew cursorTarget))== 0 and ((vectorUp cursorTarget) select 2) < 0.5) then { if (s_player_flipveh < 0) then { diff --git a/dayz_code/init/variables.sqf b/dayz_code/init/variables.sqf index 9325f0d9b..2a1b66ea6 100644 --- a/dayz_code/init/variables.sqf +++ b/dayz_code/init/variables.sqf @@ -117,6 +117,7 @@ dayz_resetSelfActions = { s_build_Wire_cat1 = -1; s_player_deleteBuild = -1; s_player_forceSave = -1; + s_player_checkGear = -1; s_player_flipveh = -1; s_player_stats = -1; s_player_sleep = -1; diff --git a/dayz_server/compile/server_publishVehicle.sqf b/dayz_server/compile/server_publishVehicle.sqf index 4898949e9..f2301ae28 100644 --- a/dayz_server/compile/server_publishVehicle.sqf +++ b/dayz_server/compile/server_publishVehicle.sqf @@ -68,6 +68,8 @@ if (_spawnDMG) then { }; }; +// TODO: check if uid already exists and if so increment by 1 and check again as soon as we find nothing continue. + //Send request _key = format["CHILD:308:%1:%2:%3:%4:%5:%6:%7:%8:%9:",dayZ_instance, _class, _damage , _characterID, _worldspace, [], _array, _fuel,_uid]; diag_log ("HIVE: WRITE: "+ str(_key));