OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: cosjacket on 01 Jul 2008, 01:56:18

Title: Weapon script
Post by: cosjacket on 01 Jul 2008, 01:56:18
Hi there,
is there a way of scripting weapon loadout for individual players..ie instead of writitng out the magazine 6 times,etc could it be done by scripting the loadout and adding to init line of each player
Title: Re: Weapon script
Post by: schuler on 01 Jul 2008, 04:15:42
hi cosjacket ,, this way is easier
Code: [Select]
removeallweapons this;this addMagazine "30Rnd_545x39_AK",6]; this addWeapon "AK74" ;this addMagazine ["PG7V",3] ; this addWeapon "RPG7V";this addweapon "binocular";this addweapon "NVGoggles";remove all weapons then add the magazines first then weapons ,, dont know why!
cheers schuler
Title: Re: Weapon script
Post by: Cheetah on 01 Jul 2008, 10:05:17
Hey cosjacket,

Yes you can do it with a script that you execute via the init line of a soldier.

To do so you'll need a script that can go as detailed as you want. To add an AK74 and a specific number of magazines, you can use the following. Create a file called loadout.sqf (save as .sqf) in the mission folder (My Documents/ArmA/..somewhere)

Put the following in the script.

Code: [Select]
_unit = _this select 0;
_mags = _this select 1;
removeallweapons _unit;

if(_mags > 0) then { _unit addMagazine "30Rnd_545x39_AK"; _mags = _mags - 1; };

_unit addWeapon "AK74"

while { _mags > 0 } do
{
_unit addMagazine "30Rnd_545x39_AK";
_mags = _mags - 1;
};

This line goes in the init line of a unit (6 is variable and determines the number of mags)
Code: [Select]
nul = [this,6] execVM "loadout.sqf";

Hopefully it works, untested.
Title: Re: Weapon script
Post by: Spooner on 01 Jul 2008, 11:20:53
My SPON Kits (http://www.ofpec.com/forum/index.php?topic=30711.0) script was written for exactly this purpose and also has a lot of other advantages (such as re-equipping on respawn).
Title: Re: Weapon script
Post by: cosjacket on 01 Jul 2008, 16:13:36
lovely thanks for that will apply it to my loadouts xx :good:
Title: Re: Weapon script
Post by: Cheetah on 01 Jul 2008, 17:53:21
Knew there was a script for it, but a search in the Ed. Depot ended up empty. Forgot to search the beta board for scripts.

Forget about my script, unless you want to see some basic scripting, and go for spooner's creation.
Title: Re: Weapon script
Post by: Spooner on 01 Jul 2008, 18:07:17
Yeah, I never am happy to submit my scripts or I just never get around to it or I never get any feedback to tell me that they actually do work in "battle" situations (or I take a 6 month holiday and sort of forget about them ;/). SPON Kits seemed pretty stable to me though, at least as far as I was able to test it. Any problems you find will be new to me and I'd be keen to fix them if you tell me about them ;P
Title: Re: Weapon script
Post by: USM-CPT.Dyson on 04 Jul 2008, 22:07:43
Message posted in wrong thread
Title: Re: Weapon script
Post by: Mandoble on 04 Jul 2008, 22:49:45
USM-CPT.Dyson, seems you posted in the wrong thread. Proceeding to reply in the correct thread.