Home   Help Search Login Register  

Author Topic: Player array  (Read 1087 times)

0 Members and 3 Guests are viewing this topic.

Offline Gadjuka

  • Members
  • *
  • Programmer
    • Operation Flashpoint: Commander
Player array
« on: 06 Jun 2003, 11:14:52 »
Hi!

I wonder how you do to get an array of all the (human) players in a MP game.
Currently working on Operation Flashpoint: Commander.
Website: http://www.nordserver.se/commander/

Offline CrashDome

  • Members
  • *
Re:Player array
« Reply #1 on: 06 Jun 2003, 15:11:16 »
unpossible!

thats right..i said it..... UNpossible....


really it IS possible but you need alot of scripting knowledge. Fortunately, someone has done that for you. The Chain of Command released a set of scripts and functions called COC Network Services. It has a function in there for you that just may work for ya. I do believe it is hosted on this site.

Mujahedeen

  • Guest
Re:Player array
« Reply #2 on: 06 Jun 2003, 20:51:32 »
Hi!

You might be able to use this:
...although it only counts all players...

-----
playersNumber side
Operand types:
    side: Side
Compatibility:
    Version 1.8 required.
Type of returned value:
    Number
Description:
    Return count of players playing on given side.
-----

Cheers...
« Last Edit: 06 Jun 2003, 20:52:42 by Mujahedeen »

Offline Gadjuka

  • Members
  • *
  • Programmer
    • Operation Flashpoint: Commander
Re:Player array
« Reply #3 on: 17 Jun 2003, 05:13:35 »
I've noticed that players always has the skill 1...
To find out which units are players, set all units to a skill less than 1. Then check which units have their skill set to 1 - these are the players!
q.e.d  8)
Currently working on Operation Flashpoint: Commander.
Website: http://www.nordserver.se/commander/

Offline DrStrangelove

  • Members
  • *
  • Mr.Creative
Re:Player array
« Reply #4 on: 17 Jun 2003, 20:57:41 »
Wow, now that's a good trick!  :D

Offline MI_Fred

  • Members
  • *
  • AA
    • OFP Team Finlanders
Re:Player array
« Reply #5 on: 17 Jun 2003, 21:35:07 »
How about this in your init.sqs:
Code: [Select]
allplayers = []
allplayers = allplayers + [player]

;D

Init.sqs is ran on all machines, and player is picked up from each. I quarantee not that it works, nor the order is nothing but random. It might also work only in-mission, I experimented with enabling/disabling maps, pads, watches and compass' for certain units only. It was only possible after enabling all from description.ext and from the mission executing the script with [player] exec "equipment.sqs". That got a hold of em all and it works.
There's gooks over there, there's mines over there, and watch out those goddamn monkeys talk, I'll bite ya.

PheliCan

  • Guest
Re:Player array
« Reply #6 on: 18 Jun 2003, 00:35:51 »
Well...
Init.sqs is started on all computers. But they are still runned locally and therefor, you vill get a global array on your local computer containing the name of your player. What you have to do is to broadcast the playername with "publicVariable", but them you'll risk overwriting each other...
This method is much better, even if it might not look very well. ::)

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:Player array
« Reply #7 on: 20 Jun 2003, 17:08:25 »
Another way:

This might take some pre-work to be done, but it's also a
solution:

As you all know, there's a little difference on the names,
once a unit get's player controlled (except you're using
setidentity command).

Now there are guys called: Bobby Bruining, Mike Hirasaki,
etc. hanging around, if they are AI controlled.

If a player takes control over an AI, the name will change to
the player's name: [BF] ChrisDeath, etc..

Only thing you need to do is:

Put all your playable soldiers into an array (let's say: player_array)

check for the AI name like:

?(name unit1 != "Bobby Bruining"): player_array = player_array - [unit1]


The only thing i'm not sure about is:

If you disable unit1, and select unit2 in the player selection menu, will Bobby Bruining then be unit2, or do the names
remain to their affilatetd units.

Sorry, but i can't check this right now as i'm at work.

If this is the case, then there would still be a work around
by creating a second array: names_array

Into this names array you would have to put all your AI names.

names_array = ["Bobby Bruining","Mike Hirasaki",etc..]

Then you would have to check:

?(name unit1 in names_array): player_array = player_array - [unit1]

But don't take my sample commands here too serious, as i just
showed ya where the kitchen is, and not how to cook.

You might need to make a loop for checking all those names
through the arrays.


~S~ CD
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
Re:Player array
« Reply #8 on: 21 Jun 2003, 10:59:47 »
Start with a trigger (I'll call it "allunits") that covers the map to gather all units...
then place a gamelogic and name it "server"....

then use these lines to weed out the AI dudes and return an array of players...

Code: [Select]
_everyone = list allunits
_players = []
{if ((!local _x) || (player == _x)) then {_players = _players + [_x]}} foreach _everyone
_players = _players - [server]
hint format ["%1",_players]

This of course, will only work on the server.

« Last Edit: 21 Jun 2003, 11:00:32 by toadlife »
"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.

Offline Dinger

  • Contributing Member
  • **
  • where's the ultra-theoretical mega-scripting forum
Re:Player array
« Reply #9 on: 22 Jun 2003, 15:58:50 »
aren't AI units local to the group leader's client?

Anyway, check out CoC_NS.  v. 1.1 is simple to use (just place an object on the map; or copy scripts and run an init).  Run the script, and all players appear in an array (I think it's CoC_PeerList)
Dinger/Cfit

Offline toadlife

  • OFPEC Old Skool
  • Former Staff
  • ****
  • Official OFP Editing Center Toad
    • toadlife.net
Re:Player array
« Reply #10 on: 23 Jun 2003, 00:25:28 »
aren't AI units local to the group leader's client?

Ewww you're right. We'll my little script is flawed then.
"Whenever you want information on the 'net, don't ask a question; just post a wrong answer." -- Cancer Omega.