OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: LightWalker on 21 Apr 2004, 17:03:16
-
Strongly finding a way to move players that disconnect during a MP-mission to a group that doesnt take part in the mission, using the [UNITID] join aigroup command. How to determine when a player is disconnected and turned into an AI?
-
hmm...if you don't need these units anymore, why not just delete them?
;deletedisconnected.sqs
_unit = _this select 0
#loop
~1
deletevehicle _unit
#goto "loop"
then just put in the init line of each playable unit:
[this] exec "deletedisconnected.sqs"
As OFP wont delete Human controlled units, the script would delete a unit which is no longer under human control.
Warning: this is untested, make a test mission first to test if it works...but out of my mind it should ;D
-
Tried this, it doesnt remove them.
Thats why I wanted the disconnected player / AI moved to another group.
Thanks anyway though.
-
Off course you won't success doing it this way
It's because the unit won't get deleted after the first RESPAWN.
You need to exit the script, once the unit is dead, and start the
script again, after respawning.
P.S: I'm not sure, if it will work when doing it the correct way,
as i seem to remember these units will still keep their player's
names, and this could cause that the game still thinks it's a player
not tested that yet, but at least you should give the correct method a chance first :)
~S~ CD
-
what you will probably need to do is update the playable unit arrays after every respawn
This is how to do it
1) Create a gamelogic and name it SERVER
2) Add the following to the init.sqs
tx_PlayableArray = [W1,W2,W3,..... etc etc etc]
tx_updateArray = objnull
player addEventHandler ["killed", {_this exec "playerkilled.sqs"}]
[]exec ArrayUpdate.sqs
3) Create script ArrayUpdate.sqs
?!(local Server):exit
~ (Random 2)
;;Playerarray_update.sqs
;;Maintains PlayerArray integrity, use it for whatever you want
#START
@ (not isnull tx_updateArray)
#UPDATE
tx_PlayableArray = tx_PlayableArray + [tx_updateArray]
tx_updateArray = objnull
{deletevehicle _x} forEach tx_PlayableArray
goto "START"
4) Create script Playerkilled.sqs
player removeAllEventHandlers "Killed"
@alive player
tx_updateArray = player; PublicVariable "tx_updateArray"
player addEventHandler ["killed", {_this exec "playerkilled.sqs"}]
exit
in theory every time somebody is killed, the update script will self clean any ai units (Untested), however i know the array update system works because i use it a lot
NB>>> note the use of a tag "tx_" before any global variable, this is to help reduce conflicts when addons are also being run alongside the scripts