Home   Help Search Login Register  

Author Topic: Finding Magazines  (Read 2965 times)

0 Members and 1 Guest are viewing this topic.

Offline six6six

  • Members
  • *
Finding Magazines
« on: 28 Apr 2008, 18:49:28 »
What i want to do is write a script to make it so a soldier acts as an ammo bearer, and i need a way of telling what ammo another soldier

Offline Gcfungus

  • Members
  • *
Re: Finding Magazines
« Reply #1 on: 28 Apr 2008, 20:40:02 »
Can you please make it exactly clear what you want, try to give as many details as you can.
The object of war is not to die for your country, but to make the other bastard die for his.
~George Patton

Offline six6six

  • Members
  • *
Re: Finding Magazines
« Reply #2 on: 28 Apr 2008, 21:48:54 »
What I want is prferably a way to find the aray of magazines on a unit.

Offline Gcfungus

  • Members
  • *
Re: Finding Magazines
« Reply #3 on: 28 Apr 2008, 22:42:02 »
Try checking the comref.

Quote from: COMREF
magazines vehicle
Operand types:
vehicle: Object

Type of returned value:
Array
Description:
Returns array of types names of all vehicle's magazines.
Used In:
OFP/ArmA
Example:
_mags = magazines player

-=GC=-Fungus1999
The object of war is not to die for your country, but to make the other bastard die for his.
~George Patton

Offline six6six

  • Members
  • *
Re: Finding Magazines
« Reply #4 on: 29 Apr 2008, 16:23:32 »
Thanks, but can i just ask, what order in the array do they come?

Offline schuler

  • Contributing Member
  • **
Re: Finding Magazines
« Reply #5 on: 29 Apr 2008, 16:29:13 »
_mags
"M16"
edit this is a good question  :yes:
 More info would be better, please, cut?!?!?, in play gaming?1?!?!?
 You can place an ammo box near the ammo bearer and the Ap [player] can tell him want ammo to take or reload. Make it an U.S. ammo box from you editor, they will get what they need. place a soldier near the ammo box,  It would look like the ammo bearer is giving it to the soldiers
And more is i.e. ,,,     ammo box 
AddWeaponCargo
AddMagazineCargo

If it is in a cutsence a playMove would look nice!
editors choice award here  :P  ;)
« Last Edit: 29 Apr 2008, 16:51:44 by schuler »
Semper Fi

Offline six6six

  • Members
  • *
Re: Finding Magazines
« Reply #6 on: 05 May 2008, 15:43:15 »
Anyone? what order in the array do the weapons come in?

Offline schuler

  • Contributing Member
  • **
Re: Finding Magazines
« Reply #7 on: 05 May 2008, 16:24:09 »
hi Six,, please do not say array again :no:
tell us what you are looking for :clap:
here is one way of many!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

_unit = _this Select 0


RemoveAllWeapons _unit


_unit AddMagazine "AK47"
_unit AddMagazine "AK47"
_unit AddMagazine "AK47"
_unit AddMagazine "AK47"
_unit AddMagazine "AK47"
_unit AddMagazine "AK47"
_unit AddWeapon "AK47"
_unit SelectWeapon "AK47"
_unit AddMagazine "GlockMag"
_unit AddMagazine "GlockMag"
_unit AddMagazine "GlockMag"
_unit AddMagazine "GlockMag"
_unit AddWeapon "Glock"
_unit AddMagazine "HandGrenade"
_unit AddMagazine "HandGrenade"
_unit AddMagazine "HandGrenade"
_unit AddMagazine "HandGrenade"
_unit AddWeapon "Binocular"
_unit AddWeapon "NVGoggles"
exit

hope i am sending you on the right track  :good:
cheers schuler
Semper Fi

Offline six6six

  • Members
  • *
Re: Finding Magazines
« Reply #8 on: 05 May 2008, 19:01:52 »
What i want to know, is what order the different types of magazine are arranged in when i use the magazine command.
eg. [m16,m16,m16,m16,handgrenade,handgrenade,law,law]
or [handgrenade,handgrenade,m16,m16,m16,m16,law,law]
etc.

Offline Gcfungus

  • Members
  • *
Re: Finding Magazines
« Reply #9 on: 05 May 2008, 20:51:50 »
I tried a test and it gave me all the types from the comref. Ie:

Ak47, M16, MM1mag, g36amag ect.

It gives you it without the "s. However be careful, as if you check one without a mag in that slot (either if it is empty or if something takes up 2 slots then u will not have 10 mag slots) it will give you an odd result, such as:
Code: [Select]
scalar bool array string 0xfcffffefI'm not sure of the order, but i would presume it would be the same as on the gear screen.

Hope this helps.  :D

-=GC=-Fungus1999

« Last Edit: 05 May 2008, 21:05:07 by Gcfungus »
The object of war is not to die for your country, but to make the other bastard die for his.
~George Patton

Offline six6six

  • Members
  • *
Re: Finding Magazines
« Reply #10 on: 06 May 2008, 08:50:59 »
One last question. How do i find what members are in a group?

Offline Gcfungus

  • Members
  • *
Re: Finding Magazines
« Reply #11 on: 06 May 2008, 17:53:17 »
Try:

Code: [Select]
_group = group player
_max = count _group
_counter = 1
_selecter = 0
#loop
_subject = _group select _selecter

<do what you want here>
_subject command whatever

_counter = _counter + 1
?(_counter > _max): exit
goto "loop"

This is untested, but should work.
The object of war is not to die for your country, but to make the other bastard die for his.
~George Patton

Offline six6six

  • Members
  • *
Re: Finding Magazines
« Reply #12 on: 01 Jun 2008, 12:21:52 »
Try:

Code: [Select]
_group = group player
_max = count _group
_counter = 1
_selecter = 0
#loop
_subject = _group select _selecter

<do what you want here>
_subject command whatever

_counter = _counter + 1
?(_counter > _max): exit
goto "loop"


This is untested, but should work.

Im sorry to dig this up, but this doesnt work. It just gives me the error
'_subject = _group select _selecter
  • ': error select:type number, expected array", and i have no idea how to solve it.

Offline Garcia

  • Members
  • *
  • Leeds United is the best football team...EVER!
Re: Finding Magazines
« Reply #13 on: 01 Jun 2008, 12:46:58 »
Code: [Select]
_group = group player
_max = count _group
_counter = 0

#loop
_subject = (units _group) select _counter

<do what you want here>
_subject command whatever

_counter = _counter + 1
?(_counter >= _max): exit
goto "loop"

First of all, you need (units _group). "Units groupName" creates an array with the soldiers within the group. Also, no point in using the _selecter variable that way, because it didn't change during the looping. It would stay at 0, and that would make it select the first element in the array all the time (which means it would select the same unit over and over again).

Offline six6six

  • Members
  • *
Re: Finding Magazines
« Reply #14 on: 01 Jun 2008, 13:57:06 »
Code: [Select]
'_max = count _group[#]'; Error count: type group, expected array
is what im getting now.

Ive changed the defines to this:

_group = _this select 2
_max = count _group
_counter = 0
as ive intergrated it with my script.
please help.


Fixed it, it should be
Code: [Select]
_max = count units _groupnot
Code: [Select]
_max = count _group
« Last Edit: 01 Jun 2008, 16:04:17 by six6six »

Offline Garcia

  • Members
  • *
  • Leeds United is the best football team...EVER!
Re: Finding Magazines
« Reply #15 on: 01 Jun 2008, 17:42:58 »
Exactly ;)

Offline six6six

  • Members
  • *
Re: Finding Magazines
« Reply #16 on: 04 Jun 2008, 13:27:35 »
How can I find out if a unit has no ammo via script?

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Finding Magazines
« Reply #17 on: 04 Jun 2008, 16:24:02 »
Read the OFP ComRef start to finish over and over again, even if you do not understand it all.
ammo
forEach
magazines
Code: [Select]
_magsleft = 0
{_magsleft = _magsleft + (_myUnit ammo _x)} forEach magazines _myUnit
Will have to test how this behaves when unit is in vehicle.
« Last Edit: 04 Jun 2008, 16:29:13 by Mr.Peanut »
urp!