Jump to content
  • 0

Help with adding M240's to Bi-planes


OfficialBW8

Question

Im trying to add M240's to the Bi-planes and I get in the plane but it has no gun. Do you guys know what I need to do to get it working.
I may have done the code wrong or it may be outdated. Please let me know as soon as possible. Here is the edited portion of my server_monitor.sqf
					//Add Magazines
					_objWpnTypes = (_inventory select 1) select 0;
					_objWpnQty = (_inventory select 1) select 1;
					_countr = 0;
					{
						if (_x == "BoltSteel") then { _x = "WoodenArrow" }; // Convert BoltSteel to WoodenArrow
						if (_x == "ItemTent") then { _x = "ItemTentOld" };
						_isOK = 	isClass(configFile >> "CfgMagazines" >> _x);
						if (_isOK) then {
							_object addMagazineCargoGlobal [_x,(_objWpnQty select _countr)];
						};
						_countr = _countr + 1;
					} count _objWpnTypes;

					//Add Backpacks
					_objWpnTypes = (_inventory select 2) select 0;
					_objWpnQty = (_inventory select 2) select 1;
					_countr = 0;
					{
						_isOK = 	isClass(configFile >> "CfgVehicles" >> _x);
						if (_isOK) then {
							_object addBackpackCargoGlobal [_x,(_objWpnQty select _countr)];
						};
						_countr = _countr + 1;
					} count _objWpnTypes;
				};
			};	

if (_object isKindOf "AN2_DZ") then {

_object addWeapon "M240_veh";
_object addMagazine "100Rnd_762x51_M240";
_object addMagazine "100Rnd_762x51_M240";
_object addMagazine "100Rnd_762x51_M240";
_object addMagazine "100Rnd_762x51_M240";
};

if (_object isKindOf "AN2_1_TK_CIV_EP1") then {

_object addWeapon "M240_veh";
_object addMagazine "100Rnd_762x51_M240";
_object addMagazine "100Rnd_762x51_M240";
_object addMagazine "100Rnd_762x51_M240";
_object addMagazine "100Rnd_762x51_M240";
};

if (_object isKindOf "AN2_1_TK_CIV_EP1") then {

_object addWeapon "M240_veh";
_object addMagazine "100Rnd_762x51_M240";
_object addMagazine "100Rnd_762x51_M240";
_object addMagazine "100Rnd_762x51_M240";
_object addMagazine "100Rnd_762x51_M240";
};
			
			if (_object isKindOf "AllVehicles") then {
				{
					_selection = _x select 0;
					_dam = _x select 1;
					if (_selection in dayZ_explosiveParts && _dam > 0.8) then {_dam = 0.8};
					[_object,_selection,_dam] call object_setFixServer;
				} count _hitpoints;

 

Link to comment
Share on other sites

15 answers to this question

Recommended Posts

  • 0

                    //Add Magazines
                    _objWpnTypes = (_inventory select 1) select 0;
                    _objWpnQty = (_inventory select 1) select 1;
                    _countr = 0;
                    {
                        if (_x == "BoltSteel") then { _x = "WoodenArrow" }; // Convert BoltSteel to WoodenArrow
                        if (_x == "ItemTent") then { _x = "ItemTentOld" };
                        _isOK =     isClass(configFile >> "CfgMagazines" >> _x);
                        if (_isOK) then {
                            _object addMagazineCargoGlobal [_x,(_objWpnQty select _countr)];
                        };
                        _countr = _countr + 1;
                    } count _objWpnTypes;

                    //Add Backpacks
                    _objWpnTypes = (_inventory select 2) select 0;
                    _objWpnQty = (_inventory select 2) select 1;
                    _countr = 0;
                    {
                        _isOK =     isClass(configFile >> "CfgVehicles" >> _x);
                        if (_isOK) then {
                            _object addBackpackCargoGlobal [_x,(_objWpnQty select _countr)];
                        };
                        _countr = _countr + 1;
                    } count _objWpnTypes;
                };
            };    

            if (_object isKindOf "AN2_DZ" || _object isKindOf "AN2_1_TK_CIV_EP1") then {
                _object addWeapon "M240_veh";
                _object addMagazine "100Rnd_762x51_M240";
                _object addMagazine "100Rnd_762x51_M240";
                _object addMagazine "100Rnd_762x51_M240";
                _object addMagazine "100Rnd_762x51_M240";
            };
            
            if (_object isKindOf "AllVehicles") then {
                {
                    _selection = _x select 0;
                    _dam = _x select 1;
                    if (_selection in dayZ_explosiveParts && _dam > 0.8) then {_dam = 0.8};
                    [_object,_selection,_dam] call object_setFixServer;
                } count _hitpoints;
Link to comment
Share on other sites

  • 0

try posting it under this line  

 

clearMagazineCargoGlobal  _object;

 

i have this working in the same spot 

 

but it does the opposite of what ur doing let me know if it works , post back here and ill add that to my server aswell =]

 

           //remove weapons
            if (_object isKindOf "HMMWV_Armored") then {
             //_object removeWeapon "M240_veh";
               _object removeMagazine "100Rnd_762x51_M240";
               _object removeMagazine "100Rnd_762x51_M240";
               _object removeMagazine "100Rnd_762x51_M240";
            };
Link to comment
Share on other sites

  • 0
Ive done this and im getting the error message "Script z\addons\dayz_code\actions\An2_ammo.sqf not found"
 
Here is the edited code in my fn_selfactions.sqf
if(_inVehicle and (_vehicle isKindOf "An2_DZ")) then {
    if (s_player_an2_reload < 0) then {
        dayz_An2Vehicle = _vehicle;
        s_player_an2_reload = dayz_An2Vehicle addAction ["Add AMMO to M240 gun", "\z\addons\dayz_code\actions\An2_ammo.sqf",dayz_An2Vehicle,-10,false,true,"","player == driver _target"];
    };
} else {
    dayz_An2Vehicle removeAction s_player_an2_reload;
    s_player_an2_reload = -1;
};

and here is the code in my dayz_code\actions\An2_ammo.sqf

private["_ammo","_vehicle","_hasAmmo","_text","_weapon","_weaponname","_ammoname"];
    _vehicle = _this select 0;
    _weapon = "M240"; //vehicleweapon
    _ammo = "100Rnd_762x51_M240"; //weaponammo
    _weaponname = _weapon; //cant read from config, coz there is no turret or what ever - so its hardcoded
    _ammoname = getText (configFile >> "cfgMagazines" >> _ammo >> "displayName");
    _text = [_ammoname,_weaponname];
    
    _hasAmmo = _ammo in magazines player;
    if (_hasAmmo) exitWith {
        player removeMagazine _ammo;
        ["<t size='0.6'>3</t>",0,0.8,0.5,0,0,8] spawn BIS_fnc_dynamicText;
        sleep 1;
        ["<t size='0.6'>2</t>",0,0.8,0.5,0,0,8] spawn BIS_fnc_dynamicText;
        sleep 1;
        ["<t size='0.6'>1</t>",0,0.8,0.5,0,0,8] spawn BIS_fnc_dynamicText;
        sleep 1;
        _vehicle addMagazine _ammo;
        cutText [format[(localize "str_epoch_player_127"),_ammoname], "PLAIN DOWN"];
    };
    cutText [format[(localize "str_epoch_player_128"),_text], "PLAIN DOWN"];

why is it saying not found. The file is in there.

Link to comment
Share on other sites

  • 0

Because you're supposed to put it in your mission folder/pbo not epoch client files

=P , he's right , you can not add files to the client side files ,they need to be in your mission, so what u need to do is change the location of where the file should be looked for. =]

Link to comment
Share on other sites

  • 0


server_monitor.sqf
_object setVariable ["CharacterID", _ownerID, true];


clearWeaponCargoGlobal  _object;
clearMagazineCargoGlobal  _object;

//======================Vehicle weapons MOD========================
//AN2_DZ add weapons
if (_object isKindOf "AN2_DZ") then {
_object addWeapon "M240_veh";
_object addMagazine "100Rnd_762x51_M240";
_object addMagazine "100Rnd_762x51_M240";
_object addMagazine "100Rnd_762x51_M240";
_object addWeapon "TwinVickers";
_object addMagazine "500Rnd_TwinVickers";

};

then if you want them to actually spawn with weapons and not require restart 

add the same to 

server_publishVehicle2.sqf

//======================Vehicle weapons MOD========================
//AN2_DZ add weapons
if (_object isKindOf "AN2_DZ") then {
_object addWeapon "M240_veh";
_object addMagazine "100Rnd_762x51_M240";
_object addMagazine "100Rnd_762x51_M240";
_object addMagazine "100Rnd_762x51_M240";
_object addWeapon "TwinVickers";
_object addMagazine "500Rnd_TwinVickers";

};
//======================Vehicle weapons MOD END========================

diag_log ("PUBLISH: " + str(_activatingPlayer) + " Bought " + (_class) + " with ID " + str(_uid));
};
Link to comment
Share on other sites

  • 0

Hi,

I tried this script and got it working, its very nice, thank you for writing it.

I placed the fn_selfactions.sqf part and added the An2_ammo.sqf.

Then I added your part Calamity and found it did add the guns but no ammo.

If you change:

_object addMagazine "100Rnd_762x51_M240";
_object addMagazine "100Rnd_762x51_M240";
_object addMagazine "100Rnd_762x51_M240";

to this:

_object addMagazineCargoGlobal ["100Rnd_762x51_M240",3];

then the aircraft has 3 magazines in the cargo when you spawn it in.

You can then add them to your inventory and use the load ammo option.

Link to comment
Share on other sites

  • 0

unpack your mission.pbo

 

inside create a folder named "custom" (or how ever you want call it)

create a file named "An2_ammo.sqf" and put that code into it

private["_ammo","_vehicle","_hasAmmo","_text","_weapon","_weaponname","_ammoname"];
    _vehicle = _this select 0;
    _weapon = "M240"; //vehicleweapon
    _ammo = "100Rnd_762x51_M240"; //weaponammo
    _weaponname = _weapon; //cant read from config, coz there is no turret or what ever - so its hardcoded
    _ammoname = getText (configFile >> "cfgMagazines" >> _ammo >> "displayName");
    _text = [_ammoname,_weaponname];
    
    _hasAmmo = _ammo in magazines player;
    if (_hasAmmo) exitWith {
        player removeMagazine _ammo;
        ["<t size='0.6'>3</t>",0,0.8,0.5,0,0,8] spawn BIS_fnc_dynamicText;
        sleep 1;
        ["<t size='0.6'>2</t>",0,0.8,0.5,0,0,8] spawn BIS_fnc_dynamicText;
        sleep 1;
        ["<t size='0.6'>1</t>",0,0.8,0.5,0,0,8] spawn BIS_fnc_dynamicText;
        sleep 1;
        _vehicle addMagazine _ammo;
        cutText [format[(localize "str_epoch_player_127"),_ammoname], "PLAIN DOWN"];
    };
    cutText [format[(localize "str_epoch_player_128"),_text], "PLAIN DOWN"];

...and save it.

 

 

open your customized "fn_selfaction.sqf" and search for that code-block...

if (!DZE_ForceNameTagsOff) then {
	if (s_player_showname < 0 && !_isPZombie) then {
		if (DZE_ForceNameTags) then {
			s_player_showname = 1;
			player setVariable["DZE_display_name",true,true];
		} else {
			s_player_showname = player addAction [localize "STR_EPOCH_ACTIONS_NAMEYES", "\z\addons\dayz_code\actions\display_name.sqf",true, 0, true, false, "",""];
			s_player_showname1 = player addAction [localize "STR_EPOCH_ACTIONS_NAMENO", "\z\addons\dayz_code\actions\display_name.sqf",false, 0, true, false, "",""];
		};
	};
};

after it place that code-block...

 

// option to add ammo to An2 PKT gun
if(_inVehicle && (_vehicle isKindOf "An2_DZ")) then {
	if (s_player_an2_reload < 0) then {
		dayz_An2Vehicle = _vehicle;
		s_player_an2_reload = dayz_An2Vehicle addAction ["Add AMMO to M240 gun", "custom\An2_ammo.sqf",dayz_An2Vehicle,-10,false,true,"","player == driver _target"];
	};
} else {
	dayz_An2Vehicle removeAction s_player_an2_reload;
	s_player_an2_reload = -1;
};

 

now open your customized "variables.sqf" and search for that lines...

 

        s_player_heli_lift = -1;
	s_player_heli_detach = -1;
	s_player_lockUnlock_crtl = -1;

 

after it insert this line ...

        s_player_an2_reload = -1;

so it looks like ...

	s_player_heli_lift = -1;
	s_player_heli_detach = -1;
	s_player_lockUnlock_crtl = -1;
	s_player_an2_reload = -1;

now search for ...

        DZE_myHaloVehicle = objNull;
	dayz_myLiftVehicle = objNull;

add after ...

        dayz_An2Vehicle = objNull;

so it looks like ...

        DZE_myHaloVehicle = objNull;
	dayz_myLiftVehicle = objNull;
	dayz_An2Vehicle = objNull;

... save file.

 

thats all in your missionfile.. so repack it.

 

 

now unpack your server.pbo file or open it with pbomanager...

next open "system\server_monitor.sqf" and search for that line ...

         _object setFuel _fuel;

after it insert ..

if (_object isKindOf "AN2_DZ") then {
     _object addWeapon "M240_veh";
     _object addMagazine "100Rnd_762x51_M240";
     _object addMagazine "100Rnd_762x51_M240";
     _object addMagazine "100Rnd_762x51_M240";
     _object addMagazine "100Rnd_762x51_M240";
};

...thats all in server_monitor.sqf.. save it!

 

 

next step... open "compile\server_publishVehicle2.sqf" and search for that lines...

        clearWeaponCargoGlobal  _object;
	clearMagazineCargoGlobal  _object;

 after insert ....

if (_object isKindOf "AN2_DZ") then {
     _object addWeapon "M240_veh";
     _object addMagazine "100Rnd_762x51_M240";
     _object addMagazine "100Rnd_762x51_M240";
     _object addMagazine "100Rnd_762x51_M240";
     _object addMagazine "100Rnd_762x51_M240";
};

ready, save!

 

last step open "compiles\server_publishVehicle3.sqf" and search for that lines ...

        _object setVariable ["ObjectID", _oid, true];
	
	_object setVariable ["lastUpdate",time];
	
	_object setVariable ["CharacterID", _characterID, true];

and insert BEFORE that code-block..

if (_object isKindOf "AN2_DZ") then {
     _object addWeapon "M240_veh";
     _object addMagazine "100Rnd_762x51_M240";
     _object addMagazine "100Rnd_762x51_M240";
     _object addMagazine "100Rnd_762x51_M240";
     _object addMagazine "100Rnd_762x51_M240";
};

save!

 

finally repack your server.pbo..

 

 

note: an russian plane with nato-weapons?? tztztztz...

Link to comment
Share on other sites

  • 0

lets extend the Merlin with some useractions...

 

what you need ...

 

(server.pbo - server_monitor.sqf/server_publishVehicle2.sqf/server_publishVehicle3.sqf)

    //BAF_Merlin_DZE add door actions
    if (_object isKindOf "BAF_Merlin_HC3_D") then {
        _object setVariable ["Merlin_Doors", 0, true];
        _object setVariable ["Merlin_Ramp", 0, true];
    };

 

(client - varibales.sqf)

    s_player_merlin_doors = -1;
    s_player_merlin_ramp = -1;

 

    dayz_MerlinVehicle = objNull;

 

(client - fn_selfActions.sqf)

// option to add Merlin Doors/Ramp-action
if ( _inVehicle && (_vehicle isKindOf "BAF_Merlin_HC3_D") ) then {
	dayz_MerlinVehicle = _vehicle;
	if (s_player_merlin_doors < 0) then {
		s_player_merlin_doors = dayz_MerlinVehicle addAction ["open/close doors", "custom\Merlin_Doors.sqf",dayz_MerlinVehicle,-10,false,true,"","player == driver _target"];
	};
	if (s_player_merlin_ramp < 0) then {
		s_player_merlin_ramp = dayz_MerlinVehicle addAction ["open/close ramp", "custom\Merlin_Ramp.sqf",dayz_MerlinVehicle,-10,false,true,"","player == driver _target"];
	};
} else {
	dayz_MerlinVehicle removeAction s_player_merlin_doors;
	s_player_merlin_doors = -1;
	dayz_MerlinVehicle removeAction s_player_merlin_ramp;
	s_player_merlin_ramp = -1;
};

(client - files - Merlin_Doors.sqf)

if (isNil "merlinDoors") then { merlinDoors = 0; };
if (merlinDoors == 0) then { merlinDoors = 1; } else { merlinDoors = 0; };

private["_vcl"];
_vcl = _this select 0; //vehicle player;
_vcl animate ["DVERE_L", merlinDoors];
_vcl animate ["DVERE_L_POP", merlinDoors];
_vcl animate ["DVERE_P", merlinDoors];
_vcl animate ["DVERE_P_POP", merlinDoors];
_vcl setVariable ["Merlin_Doors", merlinDoors,true];

(client - files - Merlin_Ramp.sqf)

if (isNil "merlinRamp") then { merlinRamp = 0; };
if (merlinRamp == 0) then { merlinRamp = 1; } else { merlinRamp = 0; };

private["_vcl"];
_vcl = _this select 0;
_vcl animate ["rampa", merlinRamp];
_vcl setVariable ["Merlin_Ramp", merlinRamp,true];

if you followed the tutorial of previous post, you should be able to handle this code-snippets ;)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...