Jump to content
Sign in to follow this  
EightEx

Adding weapons to a menu spawned vehicle

Recommended Posts

Hello, I'm trying to add custom weapons to a vehicle (AN2) I spawn in with a scripted command. I can get the plane to spawn but the loadout doesnt. Any ideas?

Share this post


Link to post
Share on other sites

_car = createVehicle [_cartype,_pos,[], _rad,"None"];
clearMagazineCargoGlobal _car;
clearWeaponCargoGlobal _car;
_car addMagazineCargoGlobal [_mag,(random 4)];
_car addWeaponCargoGlobal [_weapon,1];

It helps to see your code if we are to help with your specific case. In this example, I've left my variable names in there so you get the idea of where stuff goes.

*Mine is MP... hence the Global

Edited by _Mofo_

Share this post


Link to post
Share on other sites

Oh yea, duh. My noob is showing. anyway this is what I've got so far:

car1 = createVehicle ["An2_1_TK_CIV_EP1", position player, [], 0, "car1 = this"];publicVariable "AN21";
AN21 setVehicleInit "AN21 addweapon "AZP85";
			AN21 addweapon "CMFlareLauncher";
			AN21 addWeapon "VikhrLauncher";
			AN21 addMagazine "12Rnd_Vikhr_KA50";
			AN21 addmagazine "60Rnd_CMFlareMagazine";
			AN21 addmagazine "2000Rnd_23mm_AZP85";
			AN21 addmagazine "2000Rnd_23mm_AZP85";
			AN21 addmagazine "2000Rnd_23mm_AZP85";
			AN21 addmagazine "2000Rnd_23mm_AZP85";";processInitCommands;

Share this post


Link to post
Share on other sites

The reference for your vehicle is car1, not AN21.

You also publicVariable "AN21" but it's not defined.

Use what Mofo posted.

Share this post


Link to post
Share on other sites

Might I also suggest learning more about arrays as well as loops. It will help you TONS with repeating commands. You will also want to bookmark the bwiki to learn more about the functions and how to use them.

https://community.bistudio.com/wiki/Main_Page

// Create the vehicle
_AN21 = createVehicle ["An2_1_TK_CIV_EP1", position player, [], 0, "NONE"];
// Clear it's cargo
clearMagazineCargoGlobal _AN21;
clearWeaponCargoGlobal _AN21;
// Add the mags
_AN21 addMagazineCargoGlobal ["2000Rnd_23mm_AZP85",4];
_AN21 addMagazineCargoGlobal ["12Rnd_Vikhr_KA50",1];
_AN21 addmagazineCargoGlobal ["60Rnd_CMFlareMagazine",1];
// Add the weapons
_AN21 addweapon ["CMFlareLauncher",1];
_AN21 addWeapon ["VikhrLauncher",1];

P.s... I've only been coding for about 1 month. n00b to n00b. ;)

P.s.s. This code keeps AN21 "local" to the script. I'm not sure why you wanted it global but if its for testing purposes... no need to make it global.

Edited by _Mofo_

Share this post


Link to post
Share on other sites

Great! Thanks for the help. Its a work in progress learning all this.

I can get the plane to spawn but still no loadout.

I'm trying to make a AN2 Biplane battle for some friends. I can make them on the editor have the weapons but the menu is what they want.

Edited by EightEx

Share this post


Link to post
Share on other sites

when you say "menu"... what do you mean?

Sorry... bad code... last part should be

addWeaponCargoGlobal

not

addweapon

Try this...

// Create the vehicle
_AN21 = createVehicle ["An2_1_TK_CIV_EP1", position player, [], 0, "NONE"];
// Clear it's cargo
clearMagazineCargoGlobal _AN21;
clearWeaponCargoGlobal _AN21;
// Add the mags
_AN21 addMagazineCargoGlobal ["2000Rnd_23mm_AZP85",4];
_AN21 addMagazineCargoGlobal ["12Rnd_Vikhr_KA50",1];
_AN21 addmagazineCargoGlobal ["60Rnd_CMFlareMagazine",1];
// Add the weapons
_AN21 addWeaponCargoGlobal ["CMFlareLauncher",1];
_AN21 addWeaponCargoGlobal ["VikhrLauncher",1];

Also forgot another useful thing for you to use... Add "-showscripterrors" to your link properties. ;)

-----------

Edit... on a side note... are you trying to do some sort of MadMax type thing with the biplane?

Edited by _Mofo_

Share this post


Link to post
Share on other sites

Made a menu that you can bring up on a key press (stole it from Takistan Life) I have it call a ExecVM to bring up the biplane script

Share this post


Link to post
Share on other sites

See above edit... The weapons your trying to add are for a different type of vehicle. I don't believe it's going to work the way you're thinking it will.

Share this post


Link to post
Share on other sites

I have got it to work with the vehicle respawn script, it would call the loadout on spawn. But I can't seem to set it like this. I tried SetVehicleInit too but nada.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×