OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: Terox on 04 Jan 2003, 12:47:25

Title: Coop maps stating how many players alive
Post by: Terox on 04 Jan 2003, 12:47:25
As a server admin i find when playing coops, its difficult to know how many players are still alive
Asking them doesnt always give you an accurate picture

To that end could somebody create a script to help all us admins in this task

Ideally it would show perhaps in the hintbox something like the following

Hint box
6 out of12 alive
(Where 12 was the number of players that started the mission)

Also if possible
(Like the estimated timeleft=param1 line in the init file)
To show in the pool screen to those that are waiting, the same thing


Overall this would help the admin assess when to #reassign etc
Title: Re:Coop maps stating how many players alive
Post by: Ranger on 06 Jan 2003, 19:50:23
There are a few ways you can count the remaining players, such as counting once every x seconds, or counting only when someone dies.

Below, I have provided instructions on how to count the remaining players every time someone dies.  The code assumes that all players belong to the same group.  If they do not, then modify the code as necessary.

1. In the group leader's initialization field, put squad1 = group this.  This gives a name to the group.

2. Also in the leader's initialization field, put squad1 exec "CountPlayers.sqs".

3. Create the CountPlayers.sqs script with the following code:

Code: [Select]
; Take the passed group name and assign it to the _group local variable.

_group = _this

; Initialize the _OldCount variable by giving it a value
; of the number of currently alive players.  This code assumes that the
; players belong to the West side.  _OldCount is used to contain the
; previous number of alive players for comparison purposes.

_OldCount = west countSide (units _group)

#Loop

; Wait until the current number of alive players and _OldCount are not
; equal, which indicates that someone has died.

@ (_CurCount = west countSide (units _group)) != _OldCount

; Display a hint indicating how many players are still alive.

hint format ["There are %1 players remaining.",_CurCount]

; Set the old count to the current count.

_OldCount = _CurCount

; Loop the script.

goto "Loop"

Good luck.  :D
Title: Re:Coop maps stating how many players alive
Post by: Diepvriezer on 09 Jan 2003, 20:42:38
I can use it for my co-op 2, thank you, and I will give you credits!
Title: Re:Coop maps stating how many players alive
Post by: Terox on 11 Jan 2003, 16:37:24
Thanks very much