Home   Help Search Login Register  

Author Topic: give back a weapon to AIs after swim!  (Read 1653 times)

0 Members and 1 Guest are viewing this topic.

Offline fleepee

  • Members
  • *
  • Enter the Matrix!
give back a weapon to AIs after swim!
« on: 25 Feb 2009, 09:02:48 »
Hi everybody!
I need a small script to give back weapons and ammo to AIs after their swimming...
I know one that works great with players, but not with AIs...
I've tried doing it myself, but definetely, i'm not a talented scripter! ::)
Thanks!! :good:

Here is what i've done as I don't care of the type of weapon, I just don't want to see unarmed AIs:
Created a trigger with in the activation line:
Code: [Select]
{[_x] exec "addweapons.sqs"} forEach units groupone
Then a small script:
Code: [Select]
? !isServer : exit

_unit = _this select 0
?!(_unit hasWeapon) then goto "add"

#add
_unit addweapon "AK74";
_unit addMagazine "30Rnd_545x39_AK";
_unit addMagazine "30Rnd_545x39_AK";
_unit addMagazine "30Rnd_545x39_AK";
_unit addMagazine "30Rnd_545x39_AK";
_unit addMagazine "30Rnd_545x39_AK";
_unit addMagazine "30Rnd_545x39_AK";
exit

And I've got that message: (see picture)
I really don't know why!
And when I test it, the AIs get the corect number of magazines...
Help!!
« Last Edit: 26 Feb 2009, 09:28:26 by fleepee »

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: give back a weapon to AIs after swim!
« Reply #1 on: 26 Feb 2009, 18:28:15 »
You are using hasWeapon and then incorrectly (?: is one way, if-then-else is another).

If you want a more complex method, that saves the whole inventory, you could look at SPON Scuba. Couldn't find a simple solution at OFPEC, but searching at Armaholic works for me.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline fleepee

  • Members
  • *
  • Enter the Matrix!
Re: give back a weapon to AIs after swim!
« Reply #2 on: 26 Feb 2009, 20:10:23 »
 ;) thanks for your help!
But it's not a simple script...
SO I modified mine:
Code: [Select]
? !isServer : exit
_unit = _this select 0
_mag= "30Rnd_545x39_AK"
_weapon= "ak74"
?(primaryWeapon _unit == "") : goto "add"

#add
_unit addMagazine _mag
_unit addMagazine _mag
_unit addMagazine _mag
_unit addMagazine _mag
_unit addMagazine _mag
_unit addMagazine _mag
_unit addweapon _weapon
exit

The error message was a consequence of my init file...
Seems ok, AI that swam gets an AK74 when the script is triggered
« Last Edit: 27 Feb 2009, 12:08:58 by fleepee »