Home   Help Search Login Register  

Author Topic: addWeapon "Binocular" in MP  (Read 3114 times)

0 Members and 1 Guest are viewing this topic.

Offline GameAdd1cted

  • Members
  • *
addWeapon "Binocular" in MP
« on: 15 Feb 2010, 13:22:38 »
Hi,

PROBLEM:
If I play locally, a specific unit have binocular. If I upload the mission to the server, the same unit doesn't have the bino.
I spent more than 3 hours looking for a solution, but can't seem to find one.
I had a look at SPON_Kits, but I think it's overkill for what I want (come on, I just want a bino at the start of the mission - can't be that hard :dunno:)

DESCRIPTION:
Initline for a specific unit:
Code: [Select]
nullReturn = [this] ExecVM "Scripts\UnitsInit\Observador.sqf";
Then in observador.sqf:

Code: [Select]
_u = _this select 0;

_id1 = _u addAction ["Clear", "Scripts\Actions\GadAction_Clear.sqf",[],1,false,true,"",""];
_u addWeapon "Binocular";
_u addWeapon "ItemGPS";

_u setCaptive  true;

After the script executes, actions are available and the unit is captive; no binos though...

Offline laggy

  • Members
  • *
  • "Behold a pale horse"
Re: addWeapon "Binocular" in MP
« Reply #1 on: 16 Feb 2010, 00:33:52 »
Don't have much experience with arming units through scripts, but have you tried to just add the weapon in the init line of the unit?

init line (on unit in editor)
Code: [Select]
this addweapon "Binocular"
Removing any Laser designator or NV goggles first might be important since they occupy the same weapon slots as a binocular, and you can't add a weapon if the slots are full already.
« Last Edit: 16 Feb 2010, 00:38:28 by laggy »
And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.

Offline GameAdd1cted

  • Members
  • *
Re: addWeapon "Binocular" in MP
« Reply #2 on: 20 Feb 2010, 13:24:47 »
Laggy,

You are right; it works in the unit init line, but I want to do it via script.

It works properly via script if you add:
Code: [Select]
waituntil {alive player};just before the line:
Code: [Select]
_u addWeapon "ItemGPS";
 :dunno: Shouldn't the game check by itself for this condition?
I find it even more intriguing that the game adds the actions for the player but it unable to add the bino unless checking for alive... ???

Offline laggy

  • Members
  • *
  • "Behold a pale horse"
Re: addWeapon "Binocular" in MP
« Reply #3 on: 22 Feb 2010, 16:46:21 »
Quote
Shouldn't the game check by itself for this condition?

ArmA2 is an amazing game.

However, I find that I often struggle with even the most basic stuff when editing a mission these days. Never had to dedicate as many hours for problem solving in OFP or Armed Assault.

The whole complexity of the engine and the many new functions can be a real struggle to master sometimes.

Laggy
And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.

Offline GameAdd1cted

  • Members
  • *
Re: addWeapon "Binocular" in MP
« Reply #4 on: 22 Feb 2010, 18:55:19 »
I stay corrected... if you add
Code: [Select]
waituntil {alive player};in the script executed from the unit's init line, than it won't execute scripts in the init file...

I think I give up and I'll follow laggy's suggestion (add bino in the init line).
 >:(

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: addWeapon "Binocular" in MP
« Reply #5 on: 06 Mar 2010, 03:15:26 »
I had no end of trouble in MP with unit's init lines in OFP so I stopped using them and started doing everything from the init.sqf. Call your script from there. Don't know if you will still need to add the alive check, but you will want to add a check that the unit is local if you want the addAction to be visible only to the unit itself, and not to everyone.
urp!

Offline kju

  • Members
  • *
    • PvPScene - The ArmA II multiplayer community
Re: addWeapon "Binocular" in MP
« Reply #6 on: 06 Mar 2010, 09:20:30 »
You need before any player interaction:

Code: [Select]
waitUntil {!(isNull player)};

Offline GameAdd1cted

  • Members
  • *
Re: addWeapon "Binocular" in MP
« Reply #7 on: 07 Mar 2010, 20:18:21 »
I had no end of trouble in MP with unit's init lines in OFP so I stopped using them and started doing everything from the init.sqf. Call your script from there. Don't know if you will still need to add the alive check, but you will want to add a check that the unit is local if you want the addAction to be visible only to the unit itself, and not to everyone.

Mr.Peanut,

In the end I used a mixed solution:
- the actions were added via script in the unit's init line;
- the bino were added in the init.sqf

@kju
Thank you for your suggestion. I'll give it a try.