OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: GeneralCoder 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?
-
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
-
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:
_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"