Jump to content
Sign in to follow this  
Drinker

A list of all players

Recommended Posts

i've searched for the answer on the forums but didnt find it...

how do i get a list of all players in a MP game on the server and on all clients? thx

Share this post


Link to post
Share on other sites
Guest

Hi, try it :

create a trigger with axe A = 5000 and Axe B = 5000

In condition line type : true

In activation line type :

hint format [""players are %1"", name (thislist select 0)]

In the "hint" (the little box who appeared) you can see the name of all players who are on the triggers. Be carefull, if you have AI on your trigger, you will see name like "James Pound" or other name wich are used for AI by OFP.

I hope this can help you.

Bye

Share this post


Link to post
Share on other sites

I dont have a clue if this actually works or not, but I figure it should if the assumptions I've made are correct? And as nobody else has replied smile_o.gif

I'm sure there are more ways to do it, but apparently all AI in MP are classed as local to the server.

So if you named all playable units in your mission PLAYER1....PLAYER14 e.t.c. in the editor, and add a game logic called server to your mission.

Then call the following from the init.sqs:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

SPlayerCount=0

SPlayers=[]

If !(Local Server):goto "SkipServer"

;Make sure you add all players, I cant be bothered typing all fourteen out here

_StartArray=[PLAYER1,PLAYER2,....,PLAYER14]

{If (!(Local _x) Or (_x==Player)) Then {SPlayers=SPlayers+[_x]}} ForEach _StartArray

;So SPlayers should now be a server array of all the players.

SPlayerCount=Count SPlayers

_Index=1

{Call {Format["MYPLAYER%1",_Index]=_x}; Public Variable Format["MYPLAYER%1",_Index]; _Index=_Index+1}} ForEach SPlayers

Public Variable "SPlayerCount"

Exit

;This bit will get the players for each client

#SkipServer

;Wait until the server has finished

@(SPlayerCount!=0)

_Index=1

#Loop

SPlayers=SPlayers+[Call {Format["MYPLAYER%1",_Index]}]

_Index=_Index+1

If (_Index<=SPlayerCount) Then {goto "Loop"}

This should give you a global array SPlayers on all the clients and the server?

Curious to see if it would, perhaps someone in the know could confirm this?

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×