OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: six6six 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
-
Can you please make it exactly clear what you want, try to give as many details as you can.
-
What I want is prferably a way to find the aray of magazines on a unit.
-
Try checking the 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
-
Thanks, but can i just ask, what order in the array do they come?
-
_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 ;)
-
Anyone? what order in the array do the weapons come in?
-
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
-
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.
-
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:
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
-
One last question. How do i find what members are in a group?
-
Try:
_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.
-
Try:
_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.
-
_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).
-
'_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
_max = count units _groupnot
_max = count _group
-
Exactly ;)
-
How can I find out if a unit has no ammo via script?
-
Read the OFP ComRef start to finish over and over again, even if you do not understand it all.
ammo (http://www.ofpec.com/COMREF/index.php?action=list&game=All&letter=a#20)
forEach (http://www.ofpec.com/COMREF/index.php?action=list&game=All&letter=f#140)
magazines (http://www.ofpec.com/COMREF/index.php?action=list&game=All&letter=m#209)
_magsleft = 0
{_magsleft = _magsleft + (_myUnit ammo _x)} forEach magazines _myUnitWill have to test how this behaves when unit is in vehicle.