player: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\{\{ *codecomment *\| *\/\/ *([^ ]+) *\}\} " to "{{cc|$1}}")
m (revert + fix)
Line 1: Line 1:
{{RV|type=command
{{RV|type=command


| ofp
|game1= ofp


|1.00
|version1= 1.00


|gr1= Object Manipulation
|gr1= Object Manipulation


| A person object controlled by user. In Intros and Outros this isn't set by default and must be assigned.<br><br>
|descr= A person object controlled by user. In Intros and Outros this isn't set by default and must be assigned.<br><br>
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>
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>


See [[Multiplayer Scripting#General information about locality|Multiplayer Scripting's player topic]] for additional helpful information.
See [[Multiplayer Scripting#General information about locality|Multiplayer Scripting's player topic]] for additional helpful information.


| [[player]]
|s1= [[player]]


| [[Object]]
|r1= [[Object]]
   
   
|x1= <code>[[player]] [[addRating]] 500;</code>
|x1= <code>[[player]] [[addRating]] 500;</code>
Line 20: Line 20:
|pr= In MP the command is not initialised in functions called by initline or init eventhandlers.
|pr= In MP the command is not initialised in functions called by initline or init eventhandlers.


| [[Multiplayer Scripting]], [[isPlayer]], [[playableUnits]], [[selectPlayer]]
|seealso= [[Multiplayer Scripting]], [[isPlayer]], [[playableUnits]], [[selectPlayer]]
}}
}}


<dl class="command_description">
<dl class="command_description">
<!-- Note Section BEGIN -->
<!-- Note Section BEGIN -->
<dd class="notedate">Posted on 20 Jul, 2010
<dd class="notedate">Posted on 20 Jul, 2010</dd>
<dt class="note">[[User:GalZohar|GalZohar]]
<dt class="note">[[User:GalZohar|GalZohar]]</dt>
<dd class="note">Before you use the '''player''' object (usually to avoid JIP issues) all you need is to run:<br>
<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>
<code>[[waitUntil]] { [[not]] [[isNull]] [[player]] };</code>
Anything else you see in other scripts is equivalent and/or redundant.
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.
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>


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


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


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


<!-- Note Section END -->
<!-- Note Section END -->
</dl>
</dl>


[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands OFP 1.46|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands OFP 1.46|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands OFP 1.96|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands OFP 1.96|{{uc:{{PAGENAME}}}}]]

Revision as of 21:22, 29 January 2021

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.

In MP player is different on each computer and on dedicated server it is objNull by default (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.

See Multiplayer Scripting's player topic for additional helpful information.
Problems:
In MP 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 ScriptingisPlayerplayableUnitsselectPlayer

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
Posted on 20 Jul, 2010
GalZohar
Before you use the player object (usually 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. 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.
Posted on 27 Jan, 2008
Dr_Eyeball
isNull player is true for JIP players on their client during initialization.
After initialization, it will be set, making it valid again.

To cater for this, some people use code similar to the following in their spawned scripts: if (!isServer && (player != player)) then { waitUntil { player == player }; waitUntil { time > 10 }; }; // 'player' will now be valid _action = player addAction ["heal", "heal.sqf", [], -1, false, false, ""];
Posted on June 26, 2014 - 18:49 (UTC)
Killzone Kid
player can actually be REMOTE object on player's PC: http://www.youtube.com/watch?v=m6IILtfa3cQ