player: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\[\[Category:[ _]?Scripting[ _]Commands[ _]Armed[ _]Assault(\|.*)]]" to "{{GameCategory|arma1|Scripting Commands}}")
m (Fix)
 
(34 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Command|Comments=
{{RV|type=command
____________________________________________________________________________________________


| ofp |Game name=
|game1= ofp
|version1= 1.00


|1.00|Game version=
|game2= ofpe
|version2= 1.00


|gr1= Object Manipulation |GROUP1=
|game3= arma1
____________________________________________________________________________________________
|version3= 1.00


| A person object controlled by user. In Intros and Outros this isn't set by default and must be assigned.<br><br>
|game4= arma2
In MP [[player]] is different on each computer and on dedicated server it is [[objNull]] by default ([https://www.youtube.com/watch?v{{=}}JzgJe9sXAiU however this doesn't mean there couldn't be one]). When user is joining dedicated server mission, at the moment of [[onPlayerConnected]] the [[player]] object is remote to the joining client, as the [[player]] unit is created on the server, but once control of the unit is passed to the user moments later, the [[player]] objects becomes [[local]] to the client and stays local.<br><br>
|version4= 1.00


See [[Multiplayer Scripting#General information about locality|Multiplayer Scripting's player topic]] for additional helpful information. |Description=
|game5= arma2oa
____________________________________________________________________________________________
|version5= 1.50


| [[player]] |Syntax=
|game6= tkoh
|version6= 1.00


| [[Object]] |Return value=
|game7= arma3
____________________________________________________________________________________________
|version7= 0.50
 
|x1= <code>[[player]] [[addRating]] 500;</code> |Example 1=
____________________________________________________________________________________________


|pr= In MP the command is not initialised in functions called by initline or init eventhandlers.|=
|gr1= Object Manipulation


| [[Multiplayer Scripting]], [[isPlayer]], [[playableUnits]], [[selectPlayer]] |See also=
|descr= A person object controlled by user. In Intros and Outros this isn't set by default and must be assigned.
}}
 
|mp= In MP [[player]] is different on each computer and on dedicated server it is [[objNull]] by default ({{Link|https://www.youtube.com/watch?v{{=}}JzgJe9sXAiU|unless scripted}}).
When user is joining a dedicated server mission, at the moment of [[onPlayerConnected]] the [[player]] object is remote to the joining client, as the [[player]] unit is created on the server, but once control of the unit is passed to the user moments later, the [[player]] objects becomes and remains [[Multiplayer Scripting#Locality|local]] to the client.
 
See [[Multiplayer Scripting#General information about locality|Multiplayer Scripting's player topic]] for additional helpful information.


<h3 style="display:none">Notes</h3>
|pr= In multiplayer, the command is not initialised in functions called by initline or init eventhandlers.
<dl class="command_description">
<!-- Note Section BEGIN -->
<dd class="notedate">Posted on 20 Jul, 2010
<dt class="note">[[User:GalZohar|GalZohar]]
<dd class="note">Before you use the '''player''' object (usually to avoid JIP issues) all you need is to run:<br>
<code>[[waitUntil]] { [[not]] [[isNull]] [[player]] };</code>
Anything else you see in other scripts is equivalent and/or redundant.
Of course JIP players may need more than just the player to point at the actual JIP player unit, but that's script/mission-specific.


<dd class="notedate">Posted on 27 Jan, 2008
|s1= [[player]]
<dt class="note">[[User:Dr_Eyeball|Dr_Eyeball]]
<dd class="note"><code>[[isNull]] [[player]]</code> is true for JIP players on their client during initialization.<br>
After initialization, it will be set, making it valid again.<br><br>
To cater for this, some people use code similar to the following in their <u>spawned</u> scripts:
<code>if (![[isServer]] && (player != player)) then
{
[[waitUntil]] { player == player };
[[waitUntil]] { time > 10 };
};


{{codecomment|// 'player' will now be valid}}
|r1= [[Object]]
_action = [[player]] [[addAction]] ["heal", "heal.sqf", [], -1, false, false, ""];
</code>


<dd class="notedate">Posted on June 26, 2014 - 18:49 (UTC)
|x1= <sqf>player addRating 500;</sqf>
<dt class="note">[[User:Killzone Kid|Killzone Kid]]
<dd class="note">[[player]] can actually be REMOTE object on player's PC: http://www.youtube.com/watch?v=m6IILtfa3cQ<br><br>
</dd>


<!-- Note Section END -->
|seealso= [[Multiplayer Scripting]] [[isPlayer]] [[playableUnits]] [[selectPlayer]]
</dl>
}}


<h3 style="display:none">Bottom Section</h3>
{{Note
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]
|user= Galzohar
[[Category:Scripting Commands OFP 1.46|{{uc:{{PAGENAME}}}}]]
|timestamp= 20100620031100
[[Category:Scripting Commands OFP 1.96|{{uc:{{PAGENAME}}}}]]
|text= Before you use the '''player''' object in init scripts, to avoid JIP issues all you need is to run:
[[Category:Scripting Commands OFP 1.99|{{uc:{{PAGENAME}}}}]]
<sqf>waitUntil { not isNull player };</sqf>
{{GameCategory|arma1|Scripting Commands}}
Anything else you see in other scripts is equivalent and/or redundant. (but you may need to add other conditions too, such as checking [[hasInterface]] before initiating that loop)<br>
[[Category:Scripting Commands Arma 2|{{uc:{{PAGENAME}}}}]]
Of course JIP players may need more than just the player to point at the actual JIP player unit, but that's script/mission-specific.
[[Category:Scripting Commands Take On Helicopters|{{uc:{{PAGENAME}}}}]]
}}
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
 
{{Note
|user= Killzone_Kid
|timestamp= 20140626184900
|text= [[player]] can actually be REMOTE object on player's PC: {{Link|http://www.youtube.com/watch?v{{=}}m6IILtfa3cQ}}
}}

Latest revision as of 23:56, 24 April 2024

Hover & click on the images for description

Description

Description:
A person object controlled by user. In Intros and Outros this isn't set by default and must be assigned.
Multiplayer:
In MP player is different on each computer and on dedicated server it is objNull by default (unless scripted). When user is joining a dedicated server mission, at the moment of onPlayerConnected the player object is remote to the joining client, as the player unit is created on the server, but once control of the unit is passed to the user moments later, the player objects becomes and remains local to the client. See Multiplayer Scripting's player topic for additional helpful information.
Problems:
In multiplayer, the command is not initialised in functions called by initline or init eventhandlers.
Groups:
Object Manipulation

Syntax

Syntax:
player
Return Value:
Object

Examples

Example 1:
player addRating 500;

Additional Information

See also:
Multiplayer Scripting isPlayer playableUnits selectPlayer

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
Galzohar - c
Posted on Jun 20, 2010 - 03:11 (UTC)
Before you use the player object in init scripts, to avoid JIP issues all you need is to run:
waitUntil { not isNull player };
Anything else you see in other scripts is equivalent and/or redundant. (but you may need to add other conditions too, such as checking hasInterface before initiating that loop)
Of course JIP players may need more than just the player to point at the actual JIP player unit, but that's script/mission-specific.
Killzone_Kid - c
Posted on Jun 26, 2014 - 18:49 (UTC)
player can actually be REMOTE object on player's PC: [1]