Home   Help Search Login Register  

Author Topic: Weapon script  (Read 1634 times)

0 Members and 1 Guest are viewing this topic.

Offline cosjacket

  • Members
  • *
Weapon script
« 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

Offline schuler

  • Contributing Member
  • **
Re: Weapon script
« Reply #1 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
« Last Edit: 01 Jul 2008, 04:19:31 by schuler »
Semper Fi

Offline Cheetah

  • Former Staff
  • ****
Re: Weapon script
« Reply #2 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.
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Weapon script
« Reply #3 on: 01 Jul 2008, 11:20:53 »
My SPON Kits script was written for exactly this purpose and also has a lot of other advantages (such as re-equipping on respawn).
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline cosjacket

  • Members
  • *
Re: Weapon script
« Reply #4 on: 01 Jul 2008, 16:13:36 »
lovely thanks for that will apply it to my loadouts xx :good:

Offline Cheetah

  • Former Staff
  • ****
Re: Weapon script
« Reply #5 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.
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Weapon script
« Reply #6 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
« Last Edit: 01 Jul 2008, 18:11:06 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline USM-CPT.Dyson

  • Members
  • *
Re: Weapon script
« Reply #7 on: 04 Jul 2008, 22:07:43 »
Message posted in wrong thread
« Last Edit: 05 Jul 2008, 17:14:10 by USM-CPT.Dyson »
CTI SectorLink
Version: Beta 7
http://hosted.filefront.com/Spyder001/

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Weapon script
« Reply #8 on: 04 Jul 2008, 22:49:45 »
USM-CPT.Dyson, seems you posted in the wrong thread. Proceeding to reply in the correct thread.