Home   Help Search Login Register  

Author Topic: adding 1 to an array during..  (Read 1491 times)

0 Members and 1 Guest are viewing this topic.

Snuffles

  • Guest
adding 1 to an array during..
« on: 26 Aug 2006, 14:06:47 »
Well, I am into scripting, and have (edited) the following script (which I got fromsomeone else..):

Code: [Select]
;}}MLES system Script{{
;all Wait lengths are customisable to suit mission preferances
;i suggest you use two spawns if you are doing a TvT mission
;to have two versions of this script: i.e each team will have to have a different spawn location.
_Unit= _This select 0
_MonitorDelay= 2
_UnitStopDammage= 0.75
_RestartWait= 10

;waits for specified time before checking to see if the Unit is dammaged/Hit
#Monitor
~_MonitorDelay

?((damage _unit) < .8): goto "Monitor"

;If the Unit has been hit/Damaged it will lose its weapons be healed and sit down
#ResultantAction
_Unit SetDammage 0
RemoveAllWeapons _Unit
_Unit switchmove "EffectStandSitDown"
;Respawns at a predifined marker.
~_RestartWait

_Unit setpos (getmarkerpos "respawn_west")
_Unit addMagazine "LSR_m4mag"
_Unit addMagazine "LSR_m4mag"
_Unit addMagazine "LSR_m4mag"
_Unit addMagazine "LSR_m4mag"
_Unit addMagazine "LSR_m4mag"
_Unit addMagazine "LSR_m4mag"
_Unit addMagazine "LSR_m4mag"
_Unit addMagazine "LSR_m4mag"
_Unit addMagazine "LSR_m4mag"
_Unit addWeapon "LSR_m4_acog"

goto "Monitor"

Basically, what I need to know how to do is how to when the script reaches "#ResultantAction", right afterwards an array gets 1 added to it, so that later in the game I can have updates as to which team has more kills than the other.

Can anyone help me?  Thank you in advance if you can!  :)

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re: adding 1 to an array during..
« Reply #1 on: 26 Aug 2006, 14:15:54 »
you dont have any arrays in that script.

and by your question, i think you mean "increment a count"


to add an element to an array do the following

INIT.SQS
;; define the array
tx_myarray = []


then to add an element to an array, do the following when it's required

tx_myarray = tx_myarray + [element]



if what you really want to do is add to a count of how many kills etc

1) Define the variable in the init.sqs
tx_killcount = 0

then in your script, whren you want to add to the count do the following
tx_killcount = tx_killcount + 1


if this is a multiplayer system
then you would need 2 varuiables, 1 for each side and publicvariable the new count when you update it

eg
tx_WestKillCount = tx_WestKillCount + 1; Publicvariable "tx_WestKillCount "
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Snuffles

  • Guest
Re: adding 1 to an array during..
« Reply #2 on: 26 Aug 2006, 14:22:35 »
wow!  thank you for the speedy response!

yeah, i meant increment a count by my question :P



one more question though, now that I have an array, I am not quite sure how to show it in a titlecut [" "," ",] format?


thank you again!  :thumbsup:

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re: adding 1 to an array during..
« Reply #3 on: 27 Aug 2006, 13:51:57 »

okay  if it were a variable

eg 
tx_counter = 5

hint format ["Count value: %1",tx_counter]
would print out

Quote
Count value: 5

if you wanted to print out a value from an array

eg

tx_MyStatus = [30, 59, 0.7]

then you would do something like the following

hint format ["Speed: %1 mph\n Direction %2 deg\n Dammage %3", Tx_Mystatus select 0, Tx_Mystatus select 1, Tx_Mystatus select 2]

this would print out
Quote
Speed: 30 mph
Direction: 59 deg
Dammage: 0.7


using titlecut not sure

using titletext format, it would look like

titletext[format["Speed: %1 mph\n Direction %2 deg\n Dammage %3", Tx_Mystatus select 0, Tx_Mystatus select 1, Tx_Mystatus select 2],"PLAIN"]


Side/group chat etc. you cant use the \n to print on a new line, so you would need to print out each line in order
eg
player sidechat format ["Speed: %1 mph", Tx_Mystatus select 0]
player sidechat format ["Direction: %1 deg", Tx_Mystatus select 1]
player sidechat format ["Dammage: %1", Tx_Mystatus select 2]


or place them all one 1 line
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Snuffles

  • Guest
Re: adding 1 to an array during..
« Reply #4 on: 27 Aug 2006, 23:32:06 »
yes!  that worked perfectly!  thank you very much Terox!


i may release this mission in the missions board soon.

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re: adding 1 to an array during..
« Reply #5 on: 29 Aug 2006, 07:11:17 »
Code: [Select]
_Unit addMagazine "LSR_m4mag"
_Unit addMagazine "LSR_m4mag"
_Unit addMagazine "LSR_m4mag"
_Unit addMagazine "LSR_m4mag"
_Unit addMagazine "LSR_m4mag"
_Unit addMagazine "LSR_m4mag"
_Unit addMagazine "LSR_m4mag"
_Unit addMagazine "LSR_m4mag"
_Unit addMagazine "LSR_m4mag"
_Unit addWeapon "LSR_m4_acog"

May i suggest to replace this 9liner of adding magazines by a simple 1liner?
Since you did removeAllWeapons before and you only add LSR_m4mag's,
there can't happen that counting the magazines of the unit will become
influenced by any other type than "LSR_m4mag".

Code: [Select]
while "count magazines _Unit < 10" do {_unit addmagazine {LSR_m4mag}}
_Unit addweapon "LSR_m4_acog"

:note - i included the addweapon in my example, just that you keep everything
in correct position of your script.

Off course it's nothing serious, but that way you can help your cpu saving resources
whenever it's possible.  :yes:

~S~ CD
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted