Home   Help Search Login Register  

Author Topic: How to deal unit script's if he dies?  (Read 1070 times)

0 Members and 1 Guest are viewing this topic.

GeneralCoder

  • Guest
How to deal unit script's if he dies?
« on: 14 Aug 2003, 15:28:53 »
Hi!
I wanted to have script to a unit but if the unit dies and respawns he doesn't have the script anymore, right?
So is there some good way to exec script to a respawing unit or shometing?


Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:How to deal unit script's if he dies?
« Reply #1 on: 15 Aug 2003, 19:05:24 »
run the following lines in a script clientside only


#START
@! alive player
@alive player
;; added to update arrays on all clients;;;;;;;;;;;;;;;;;;;;
updateclient = player; PublicVariable "updateclient"
goto "START"

and then have the following script running clientside only

#START
updateclient = objnull

#LOOP
~1
?(not isnull updateclient AND side updateclient == west): westarray = westarray + [updateclient]; goto "START"
?(not isnull updateclient AND side updateclient == east): eastarray = eastarray + [updateclient]; goto "START"
goto "LOOP"


list all west players in an array called WESTARRAY in the init.sqs
and all east players in an array caleed EASTARRAY

eg
westarray = [w1,w2,w3,w4,w5,w6]
eastarray= [e1,e2,e3,e4,e5,e6]






then you can use a line like
?(player in westarray): exec "SCRIPTNAME.sqs"



or simply add the lines marked in red to a respawn script thats client side only


#START
@! alive player
@alive player
player exec "MYSCRIPTNAME.sqs"
goto "START"


it would be advisable depending what script you are running to have the script exit when the player dies

eg in a looping script have a line like the following
? !(alive player): exit
« Last Edit: 15 Aug 2003, 19:09:42 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

GeneralCoder

  • Guest
Re:How to deal unit script's if he dies?
« Reply #2 on: 16 Aug 2003, 09:09:08 »
run the following lines in a script clientside only


#START
@! alive player
@alive player
;; added to update arrays on all clients;;;;;;;;;;;;;;;;;;;;
updateclient = player; PublicVariable "updateclient"
goto "START"

and then have the following script running clientside only

#START
updateclient = objnull

#LOOP
~1
?(not isnull updateclient AND side updateclient == west): westarray = westarray + [updateclient]; goto "START"
?(not isnull updateclient AND side updateclient == east): eastarray = eastarray + [updateclient]; goto "START"
goto "LOOP"


list all west players in an array called WESTARRAY in the init.sqs
and all east players in an array caleed EASTARRAY

eg
westarray = [w1,w2,w3,w4,w5,w6]
eastarray= [e1,e2,e3,e4,e5,e6]






then you can use a line like
?(player in westarray): exec "SCRIPTNAME.sqs"



or simply add the lines marked in red to a respawn script thats client side only


#START
@! alive player
@alive player
player exec "MYSCRIPTNAME.sqs"
goto "START"


it would be advisable depending what script you are running to have the script exit when the player dies

eg in a looping script have a line like the following
? !(alive player): exit

Thank you terox!
Another way what I just discoverd is to have array of all the groups in game and then index the dead people like this:

Code: [Select]
_i=0
#ul
_man = units _group select _i

_inspawns = false

_ai=0
#iia
?(_ai >= count _spawners): goto"eiia"
?(_i == (_spawners select _ai)): _inspawns = true
_ai=_ai+1
goto"iia"
#eiia
comment"put units index to array becose hes dead and when he is back alive we know the moment it hapend becose he is in deads array but alive"
?(damage _man >= 1 && not _inspawns): _spawners=_spawners+[_i]

goto"skip"
?(damage _man >= 1):goto"skip"

comment"when this is true unit has just respawned!"
?(_inspawns): _spawners=_spawners-[_i];

#skip
_i = _i + 1
?(_i < count units _group): goto"ul"