_ID ? is this the players globalID or the game slot number ? _name? is this the players profile name from the client or the name of the players slot.
When abouts does this actually execute ? When the player connects and before they pick a player slot, or when they assume a player in the game ?
ID is broken for players on a dedicated server (id is a very high number e.g. 3.03242E+008).
On a dedicated server this function is also called with [2, "__SERVER__"] at startup (double underscores).
--Cleanrock 18:33, 21 June 2007 (CEST)
Could we compile somewhere what is sent to the JIP client when they connect?? And what is not sent to them? For example: objects and their positions are sent (whether alive or dead). What is surprisingly not sent: any weather or time change since mission start. Any objstatus update. Any marker placed by someone in game. Is flagowner sent?? Is the state of destroyed trees and buildings sent?? Maybe this should go in http://community.bistudio.com/wiki/Multiplayer_scripting? I just know that as a scripter I would be looking at onPlayerConnected for a way to solve these issues. --Doolittle 19:00, 21 June 2007 (CEST)
I'd be happy with someone providing a working example of the use of the command. --Sy 08:07, 22 June 2007 (CEST)
Put this in init.sqf:
onPlayerConnected "[_id, _name] execVM ""PlayerConnected.sqf""";
and fill PlayerConnected.sqf with stuff u want done when a player has connected.
onPlayerConnected could be much more handy if the player unit was supplied as a parameter, do anyone know if there are more variables than _id and _name ?
--Cleanrock 10:08, 24 June 2007 (CEST)
Can you have multiple occurrences of onPlayerConnected such that each of them will be run when a player connects? --Leopard2 19:56, 22 December 2007 (CET)
- I doubt that, not sure, though. --raedor 20:21, 22 December 2007 (CET)
- I did some testing of multiple occurrences of onPlayerConnected on a dedicated server. I placed two onPlayerConnected commands in an init.sqf (each changed and broadcasted a different public variable) and found that only one of the commands executes (only one of the variables was changed). The command that was listed last was executed (are .sqf files read into memory from end to beginning?). I am going to conduct some more testing with seperate onPlayerConnected commands in different scripts but I don't think the results will vary. --Loyalguard 10:45, 8 January 2008 (CET)
These two are mentioned in the scripting help dialog when i enter onPlayerConnected to the init field in the editor. Does anyone have any information on this? upcoming commands? --Benargee (talk) 03:35, 30 September 2014 (CEST)
Historical changes to the command
Note that as of 1.08, this command only accepts a code-string rather than code delimited by braces.
Note as of ArmA 2 version 1.02 this function also returns the variable _uid which denotes uniqueID of player.
As of version Arma2 1.04, _id will return a number in float format, something like 1.4253e+10.