S4M Posted April 11, 2017 Report Share Posted April 11, 2017 Old script the @Donnovan that together with @juandayz we got it working on 1.0.6.1 All my compliment to @Donnovan and @juandayz. 1. in your init.sqf, you look for the line where the compiles.sqf is called and under this you paste this Spoiler Call compile preprocessFileLineNumbers "custom \ lock_god.sqf"; 2. create lock_god.sqf Spoiler if (isServer) then { "cad_pvar_set_veh" addPublicVariableEventHandler { private ["_veh","_godOn"]; _veh = _this select 1 select 0; _godOn = _this select 1 select 1; if (_godOn) then { _veh allowDamage false; _veh RemoveAllEventHandlers "handleDamage"; _veh addEventHandler ["handleDamage",{0}]; } else { _veh allowDamage true; _veh RemoveAllEventHandlers "handleDamage"; _veh addEventHandler ["handleDamage",{_this call veh_handleDam;}]; }; }; }; local_lockUnlock = { private ["_vehicle","_status"]; _vehicle = _this select 0; _status = _this select 1; if (local _vehicle || isServer) then { if(_status) then { _vehicle setVehicleLock "LOCKED"; if (((locked _vehicle && (count(crew _vehicle)) == 0))) then { //MIKE POST _vehicle allowDamage false; _vehicle RemoveAllEventHandlers "handleDamage"; _vehicle addEventHandler ["handleDamage",{0}]; cad_pvar_set_veh = [_vehicle,true]; publicVariableServer "cad_pvar_set_veh"; }; //MIKE POST } else { _vehicle setVehicleLock "UNLOCKED"; _vehicle allowDamage true; _vehicle RemoveAllEventHandlers "handleDamage"; _vehicle addEventHandler ["handleDamage",{_this call veh_handleDam;}]; cad_pvar_set_veh = [_vehicle,false]; publicVariableServer "cad_pvar_set_veh"; }; }; }; 3. Open server_monitor.sql and look for this line Spoiler if (_ownerID != "0" && {!(_object isKindOf "Bicycle")}) then {_object setVehicleLock "locked";}; And replace with if(_ownerID != "0" && !(_object isKindOf "Bicycle")) then { _object setvehiclelock "locked"; //LOCK GOD BEGIN _object allowDamage false; _object RemoveAllEventHandlers "handleDamage"; _object addEventHandler ["handleDamage",{0}]; //LOCK GOD END }; Done! Another option thanks @Cherdenko 1-you will need a custom compiles.sqf 2-in the custom compiles.sqf find: fnc_veh_handleDam = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\veh_handleDam.sqf"; change the line by: fnc_veh_handleDam = compile preprocessFileLineNumbers "custom\veh_handleDam.sqf"; 3.create this new sqf and paste in mpmissions\your_instance\custom\ veh_handleDam.sqf Reveal hidden contents ////////Vehicles With GodMode by Cherdenko /* Created exclusively for ArmA2:OA - DayZMod. Please request permission to use/alter/distribute from project leader (R4Z0R49) AND the author ([email protected]) */ /*********************************************************** ASSIGN DAMAGE TO A UNIT. Called by "HandleDamage" vehicle Event Handler or by "PVCDZ_veh_SH" PV or by zombie_attack - Function fnc_veh_handleDam - [unit, selectionName, damage, source, projectile, broadcast] call fnc_veh_handleDam; - return : updated damage for that part broadcast: boolean. if true, then the request will be sent to all players if the vehicle is not local. ************************************************************/ private["_unit","_selection","_strH","_total","_damage","_needUpdate","_totalDmg"]; _unit = _this select 0; _selection = _this select 1; _total = _this select 2; if (((locked _unit && (count(crew _unit)) == 0)))) then { _unit addEventHandler ["HandleDamage", {false}]; _unit enableSimulation false; }else{ if (_selection != "") then { _strH = "hit_" + _selection; _totalDmg = false; } else { _strH = "totalDmg"; _totalDmg = true; }; if (_total >= 0.98) then { _total = 1.0; }; if (local _unit) then { if (_total > 0) then { if (!_totalDmg) then { _unit setVariable [_strH, _total, true]; }; _unit setHit [_selection, _total]; PVDZ_veh_Save = [_unit,"damage",false,_totalDmg]; if (!isServer) then { publicVariableServer "PVDZ_veh_Save"; } else { PVDZ_veh_Save call server_updateObject; }; }; } else { //if ( (count _this > 5) AND {(_this select 5)}) then { // vehicle is not local to this client, ask the client which vehicle is local to set damage //_this resize 5; // delete "broadcast" boolean PVDZ_send = [_unit,"VehHandleDam",_this]; publicVariableServer "PVDZ_send"; //}; }; // all "HandleDamage event" functions should return the effective damage that the engine will record for that part _total }; juandayz, Cherdenko and gernika 3 Link to comment Share on other sites More sharing options...
juandayz Posted April 11, 2017 Report Share Posted April 11, 2017 the donnovan old post. (1.0.5.1). Spoiler gernika and S4M 2 Link to comment Share on other sites More sharing options...
gernika Posted April 11, 2017 Report Share Posted April 11, 2017 THIS IS AWESOME!!!!!!!!! TNKS YOU GUYS FOR THE UPDATE!! works great S4M 1 Link to comment Share on other sites More sharing options...
Cherdenko Posted April 12, 2017 Report Share Posted April 12, 2017 well i would call it where the source of the problem exists(vehDamageHandler) like this: Spoiler /* Created exclusively for ArmA2:OA - DayZMod. Please request permission to use/alter/distribute from project leader (R4Z0R49) AND the author ([email protected]) */ /*********************************************************** ASSIGN DAMAGE TO A UNIT. Called by "HandleDamage" vehicle Event Handler or by "PVCDZ_veh_SH" PV or by zombie_attack - Function fnc_veh_handleDam - [unit, selectionName, damage, source, projectile, broadcast] call fnc_veh_handleDam; - return : updated damage for that part broadcast: boolean. if true, then the request will be sent to all players if the vehicle is not local. ************************************************************/ private["_unit","_selection","_strH","_total","_damage","_needUpdate","_totalDmg"]; _unit = _this select 0; _selection = _this select 1; _total = _this select 2; if (((locked _unit && (count(crew _unit)) == 0)))) then { _unit addEventHandler ["HandleDamage", {false}]; _unit enableSimulation false; }else{ if (_selection != "") then { _strH = "hit_" + _selection; _totalDmg = false; } else { _strH = "totalDmg"; _totalDmg = true; }; if (_total >= 0.98) then { _total = 1.0; }; if (local _unit) then { if (_total > 0) then { if (!_totalDmg) then { _unit setVariable [_strH, _total, true]; }; _unit setHit [_selection, _total]; PVDZ_veh_Save = [_unit,"damage",false,_totalDmg]; if (!isServer) then { publicVariableServer "PVDZ_veh_Save"; } else { PVDZ_veh_Save call server_updateObject; }; }; } else { //if ( (count _this > 5) AND {(_this select 5)}) then { // vehicle is not local to this client, ask the client which vehicle is local to set damage //_this resize 5; // delete "broadcast" boolean PVDZ_send = [_unit,"VehHandleDam",_this]; publicVariableServer "PVDZ_send"; //}; }; // all "HandleDamage event" functions should return the effective damage that the engine will record for that part _total }; gernika 1 Link to comment Share on other sites More sharing options...
S4M Posted April 12, 2017 Author Report Share Posted April 12, 2017 30 minutes ago, Cherdenko said: well i would call it where the source of the problem exists(vehDamageHandler) like this: Reveal hidden contents /* Created exclusively for ArmA2:OA - DayZMod. Please request permission to use/alter/distribute from project leader (R4Z0R49) AND the author ([email protected]) */ /*********************************************************** ASSIGN DAMAGE TO A UNIT. Called by "HandleDamage" vehicle Event Handler or by "PVCDZ_veh_SH" PV or by zombie_attack - Function fnc_veh_handleDam - [unit, selectionName, damage, source, projectile, broadcast] call fnc_veh_handleDam; - return : updated damage for that part broadcast: boolean. if true, then the request will be sent to all players if the vehicle is not local. ************************************************************/ private["_unit","_selection","_strH","_total","_damage","_needUpdate","_totalDmg"]; _unit = _this select 0; _selection = _this select 1; _total = _this select 2; if (((locked _unit && (count(crew _unit)) == 0)))) then { _unit addEventHandler ["HandleDamage", {false}]; _unit enableSimulation false; }else{ if (_selection != "") then { _strH = "hit_" + _selection; _totalDmg = false; } else { _strH = "totalDmg"; _totalDmg = true; }; if (_total >= 0.98) then { _total = 1.0; }; if (local _unit) then { if (_total > 0) then { if (!_totalDmg) then { _unit setVariable [_strH, _total, true]; }; _unit setHit [_selection, _total]; PVDZ_veh_Save = [_unit,"damage",false,_totalDmg]; if (!isServer) then { publicVariableServer "PVDZ_veh_Save"; } else { PVDZ_veh_Save call server_updateObject; }; }; } else { //if ( (count _this > 5) AND {(_this select 5)}) then { // vehicle is not local to this client, ask the client which vehicle is local to set damage //_this resize 5; // delete "broadcast" boolean PVDZ_send = [_unit,"VehHandleDam",_this]; publicVariableServer "PVDZ_send"; //}; }; // all "HandleDamage event" functions should return the effective damage that the engine will record for that part _total }; How do you say all vehicles god... juandayz 1 Link to comment Share on other sites More sharing options...
Cherdenko Posted April 12, 2017 Report Share Posted April 12, 2017 (((locked _unit && (count(crew _unit)) == 0)))) with this, so if the unit is locked and theres no crew in it juandayz and S4M 2 Link to comment Share on other sites More sharing options...
S4M Posted April 12, 2017 Author Report Share Posted April 12, 2017 To add sound and light description.ext Spoiler class CfgSounds { sounds[] = { Radio_Message_Sound,lock }; class Radio_Message_Sound { name = "Radio_Message_Sound"; sound[] = {scripts\radio\radio.ogg,0.4,1}; titles[] = {}; }; class lock { name="lock"; sound[]={scripts\sounds\lock.ogg,0.2,1}; titles[] = {}; }; }; lock_god.sqf Spoiler if (isServer) then { "cad_pvar_set_veh" addPublicVariableEventHandler { private ["_veh","_godOn"]; _veh = _this select 1 select 0; _godOn = _this select 1 select 1; if (_godOn) then { _veh allowDamage false; _veh RemoveAllEventHandlers "handleDamage"; _veh addEventHandler ["handleDamage",{0}]; } else { _veh allowDamage true; _veh RemoveAllEventHandlers "handleDamage"; _veh addEventHandler ["handleDamage",{_this call veh_handleDam;}]; }; }; }; local_lockUnlock = { private ["_vehicle","_status","_sounddist"]; _vehicle = _this select 0; _status = _this select 1; _sounddist = 30; if (local _vehicle || isServer) then { if(_status) then { _vehicle setVehicleLock "LOCKED"; if (((locked _vehicle && (count(crew _vehicle)) == 0))) then { //MIKE POST _nul = [objNull, _vehicle, rSAY, "lock", _sounddist] call RE; _vehicle allowDamage false; _vehicle RemoveAllEventHandlers "handleDamage"; _vehicle addEventHandler ["handleDamage",{0}]; cad_pvar_set_veh = [_vehicle,true]; publicVariableServer "cad_pvar_set_veh"; player action ["lightOn", _vehicle]; sleep 0.5; player action ["lightOff", _vehicle]; }; //MIKE POST } else { _vehicle setVehicleLock "UNLOCKED"; _nul = [objNull, _vehicle, rSAY, "lock", _sounddist] call RE; _vehicle allowDamage true; _vehicle RemoveAllEventHandlers "handleDamage"; _vehicle addEventHandler ["handleDamage",{_this call veh_handleDam;}]; cad_pvar_set_veh = [_vehicle,false]; publicVariableServer "cad_pvar_set_veh"; player action ["lightOn", _vehicle]; sleep 0.5; player action ["lightOff", _vehicle]; }; }; }; Lock.ogg I've taken it from here Link to comment Share on other sites More sharing options...
WLF Posted April 12, 2017 Report Share Posted April 12, 2017 Hi! I have 2 problems: 1. After unlocking vehicle it still in godmode. No errors about this problem in both RPTs. 2. I get an error in server's RPT when I lock vehicle inside vehicle. 13:23:07 Suspending not allowed in this context 13:23:07 Error in expression <"; player action ["lightOn", _vehicle]; sleep 0.5; player action ["lightOff", _v> 13:23:07 Error position: <sleep 0.5; player action ["lightOff", _v> 13:23:07 Error Generic error in expression 13:23:07 File mpmissions\DayZ_Epoch_11.Chernarus\custom\lock_god.sqf, line 50 13:23:12 Suspending not allowed in this context 13:23:12 Error in expression <"; player action ["lightOn", _vehicle]; sleep 0.5; player action ["lightOff", _v> 13:23:12 Error position: <sleep 0.5; player action ["lightOff", _v> 13:23:12 Error Generic error in expression 13:23:12 File mpmissions\DayZ_Epoch_11.Chernarus\custom\lock_god.sqf, line 50 Link to comment Share on other sites More sharing options...
juandayz Posted April 12, 2017 Report Share Posted April 12, 2017 5 hours ago, WLF said: Hi! I have 2 problems: 1. After unlocking vehicle it still in godmode. No errors about this problem in both RPTs. 2. I get an error in server's RPT when I lock vehicle inside vehicle. 13:23:07 Suspending not allowed in this context 13:23:07 Error in expression <"; player action ["lightOn", _vehicle]; sleep 0.5; player action ["lightOff", _v> 13:23:07 Error position: <sleep 0.5; player action ["lightOff", _v> 13:23:07 Error Generic error in expression 13:23:07 File mpmissions\DayZ_Epoch_11.Chernarus\custom\lock_god.sqf, line 50 13:23:12 Suspending not allowed in this context 13:23:12 Error in expression <"; player action ["lightOn", _vehicle]; sleep 0.5; player action ["lightOff", _v> 13:23:12 Error position: <sleep 0.5; player action ["lightOff", _v> 13:23:12 Error Generic error in expression 13:23:12 File mpmissions\DayZ_Epoch_11.Chernarus\custom\lock_god.sqf, line 50 i guess the errors become from the "sleep" command , S4M is working now to fix it. the way that scripts its executed not allow the sleep command. gernika, S4M and Cherdenko 3 Link to comment Share on other sites More sharing options...
Cherdenko Posted April 14, 2017 Report Share Posted April 14, 2017 maybe something with the "for count" command juandayz and S4M 2 Link to comment Share on other sites More sharing options...
S4M Posted April 14, 2017 Author Report Share Posted April 14, 2017 Everything works fine but gives that error. I will try with this Spoiler if (isServer) then { "cad_pvar_set_veh" addPublicVariableEventHandler { private ["_veh","_godOn"]; _veh = _this select 1 select 0; _godOn = _this select 1 select 1; if (_godOn) then { _veh allowDamage false; _veh RemoveAllEventHandlers "handleDamage"; _veh addEventHandler ["handleDamage",{0}]; } else { _veh allowDamage true; _veh RemoveAllEventHandlers "handleDamage"; _veh addEventHandler ["handleDamage",{_this call veh_handleDam;}]; }; }; }; local_lockUnlock = { private ["_vehicle","_status","_sounddist","_wait_time"]; _vehicle = _this select 0; _status = _this select 1; _sounddist = 20; _wait_time = 0.5; if (local _vehicle || isServer) then { if(_status) then { _vehicle setVehicleLock "LOCKED"; if (((locked _vehicle && (count(crew _vehicle)) == 0))) then { //MIKE POST _nul = [objNull, _vehicle, rSAY, "lock", _sounddist] call RE; player action ["lightOn", _vehicle]; sleep _wait_time; player action ["lightOff", _vehicle]; _vehicle allowDamage false; _vehicle RemoveAllEventHandlers "handleDamage"; _vehicle addEventHandler ["handleDamage",{0}]; cad_pvar_set_veh = [_vehicle,true]; publicVariableServer "cad_pvar_set_veh"; }; } else { _vehicle setVehicleLock "UNLOCKED"; _nul = [objNull, _vehicle, rSAY, "lock", _sounddist] call RE; player action ["lightOn", _vehicle]; sleep _wait_time; player action ["lightOff", _vehicle]; _vehicle allowDamage true; _vehicle RemoveAllEventHandlers "handleDamage"; _vehicle addEventHandler ["handleDamage",{_this call veh_handleDam;}]; cad_pvar_set_veh = [_vehicle,false]; publicVariableServer "cad_pvar_set_veh"; }; }; }; juandayz 1 Link to comment Share on other sites More sharing options...
S4M Posted April 14, 2017 Author Report Share Posted April 14, 2017 Without getting error in server's RPT, The only light just lock Spoiler if (isServer) then { "cad_pvar_set_veh" addPublicVariableEventHandler { private ["_veh","_godOn"]; _veh = _this select 1 select 0; _godOn = _this select 1 select 1; if (_godOn) then { _veh allowDamage false; _veh RemoveAllEventHandlers "handleDamage"; _veh addEventHandler ["handleDamage",{0}]; } else { _veh allowDamage true; _veh RemoveAllEventHandlers "handleDamage"; _veh addEventHandler ["handleDamage",{_this call veh_handleDam;}]; }; }; }; local_lockUnlock = { private ["_vehicle","_status","_sounddist","_wait_time"]; _vehicle = _this select 0; _status = _this select 1; _sounddist = 20; _wait_time = 0.5; if (local _vehicle || isServer) then { if(_status) then { _vehicle setVehicleLock "LOCKED"; if (((locked _vehicle && (count(crew _vehicle)) == 0))) then { //MIKE POST _nul = [objNull, _vehicle, rSAY, "lock", _sounddist] call RE; player action ["lightOn", _vehicle]; sleep _wait_time; player action ["lightOff", _vehicle]; _vehicle allowDamage false; _vehicle RemoveAllEventHandlers "handleDamage"; _vehicle addEventHandler ["handleDamage",{0}]; cad_pvar_set_veh = [_vehicle,true]; publicVariableServer "cad_pvar_set_veh"; }; } else { _vehicle setVehicleLock "UNLOCKED"; _nul = [objNull, _vehicle, rSAY, "lock", _sounddist] call RE; _vehicle allowDamage true; _vehicle RemoveAllEventHandlers "handleDamage"; _vehicle addEventHandler ["handleDamage",{_this call veh_handleDam;}]; cad_pvar_set_veh = [_vehicle,false]; publicVariableServer "cad_pvar_set_veh"; }; }; }; juandayz 1 Link to comment Share on other sites More sharing options...
juandayz Posted April 14, 2017 Report Share Posted April 14, 2017 in @Cherdenko way thers a bad ) this line : if (((locked _unit && (count(crew _unit)) == 0)))) then { must be if (((locked _unit && (count(crew _unit)) == 0))) then { gernika 1 Link to comment Share on other sites More sharing options...
Kimarik Posted April 30, 2017 Report Share Posted April 30, 2017 This script is good for PVE Sevrer but not for PVP Epoch 1.0.6.1, because if you are in a vehicle and drive u can lock it so you allways have like a godmod i think. Link to comment Share on other sites More sharing options...
WLF Posted April 30, 2017 Report Share Posted April 30, 2017 It should not be so: _vehicle setVehicleLock "LOCKED"; if (((locked _vehicle && (count(crew _vehicle)) == 0))) then { ... _vehicle allowDamage false; ... } i.e. if a vehicle being locked then it don't be damaged only if no one inside. @juandayz am I right? juandayz 1 Link to comment Share on other sites More sharing options...
Relentless Posted April 30, 2017 Report Share Posted April 30, 2017 Wow this method is wayyy to complicated. Why didn't you guys just make a custom veh_handleDam.sqf and then add this to it? if (locked _unit) exitWith {}; Link to comment Share on other sites More sharing options...
juandayz Posted April 30, 2017 Report Share Posted April 30, 2017 @WLF @Kimarik @DAmNRelentless custom compiles.sqf Spoiler find: Hide contents fnc_veh_handleDam = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\veh_handleDam.sqf"; replace by: fnc_veh_handleDam = compile preprocessFileLineNumbers "custom\veh_handleDam.sqf"; veh_handleDam.sqf (mpmissions\the instance youre using\custom\ ) Spoiler /* Created exclusively for ArmA2:OA - DayZMod. Please request permission to use/alter/distribute from project leader (R4Z0R49) AND the author ([email protected]) */ /*********************************************************** ASSIGN DAMAGE TO A UNIT. Called by "HandleDamage" vehicle Event Handler or by "PVCDZ_veh_SH" PV or by zombie_attack - Function fnc_veh_handleDam - [unit, selectionName, damage, source, projectile, broadcast] call fnc_veh_handleDam; - return : updated damage for that part broadcast: boolean. if true, then the request will be sent to all players if the vehicle is not local. ************************************************************/ private["_unit","_selection","_strH","_total","_damage","_needUpdate","_totalDmg"]; _unit = _this select 0; _selection = _this select 1; _total = _this select 2; if (((locked _unit && (count(crew _unit)) == 0))) exitWith{}; if (_selection != "") then { _strH = "hit_" + _selection; _totalDmg = false; } else { _strH = "totalDmg"; _totalDmg = true; }; if (_total >= 0.98) then { _total = 1.0; }; if (local _unit) then { if (_total > 0) then { if (!_totalDmg) then { _unit setVariable [_strH, _total, true]; }; _unit setHit [_selection, _total]; PVDZ_veh_Save = [_unit,"damage",false,_totalDmg]; if (!isServer) then { publicVariableServer "PVDZ_veh_Save"; } else { PVDZ_veh_Save call server_updateObject; }; }; } else { //if ( (count _this > 5) AND {(_this select 5)}) then { // vehicle is not local to this client, ask the client which vehicle is local to set damage //_this resize 5; // delete "broadcast" boolean PVDZ_send = [_unit,"VehHandleDam",_this]; publicVariableServer "PVDZ_send"; //}; }; // all "HandleDamage event" functions should return the effective damage that the engine will record for that part _total this line: if (((locked _unit && (count(crew _unit)) == 0))) exitWith{}; do not allow use godmode while thers players inside (count(crew _unit)) == 0) gernika 1 Link to comment Share on other sites More sharing options...
Relentless Posted April 30, 2017 Report Share Posted April 30, 2017 @juandayz I know this, that's why I removed that part from the line I posted. If you only make a custom veh_handleDam.sqf and then add this line to it, all vehicles that are locked have god mode even if there are players in. Just saying. There is not that much work needed. juandayz 1 Link to comment Share on other sites More sharing options...
Voltan Posted May 23, 2018 Report Share Posted May 23, 2018 I want to have vehicles invincible while locked within plot pole range and invincible in trader zones, but otherwise not invincible when locked out and about in the rest of the map, anyone know how I can achieve this? Link to comment Share on other sites More sharing options...
BigEgg Posted May 23, 2018 Report Share Posted May 23, 2018 1 hour ago, Voltan said: I want to have vehicles invincible while locked within plot pole range and invincible in trader zones, but otherwise not invincible when locked out and about in the rest of the map, anyone know how I can achieve this? salival and Relentless 1 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now