Player::taskLookAt: Difference between revisions

From RAGE Multiplayer Wiki
(yay)
 
(Page update)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
param3: duration in ms, use -1 to look forever<br>param4: using 2048 is fine<br>param5: using 3 is fine
Method to task player to look at another entity. Client-side tasks are synced.
 
==Syntax==
==Syntax==
<syntaxhighlight lang="javascript">player.taskLookAt(lookAt, duration, unknown1, unknown2);</syntaxhighlight>
<syntaxhighlight lang="javascript">player.taskLookAt(lookAt, duration, flags, priority);</syntaxhighlight>
=== Required Arguments ===
=== Required Arguments ===
*'''lookAt:''' Entity handle or object
*'''lookAt:''' Entity handle or object
*'''duration:''' int
*'''duration:''' int
*'''unknown1:''' int
*'''flags:''' int
*'''unknown2:''' int
*'''priority:''' int
 
===Return value===
===Return value===
*'''Undefined'''
*'''Undefined'''
==Example==
==Example==
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
// todo
/**
* Function to make local player look at another player
* @param {number} targetRemoteId - Remote(server) id of the player to look at
*/
function localPlayerLookAtPlayer(targetRemoteId) {
    // Get target player from the pool by his remote id
    const target = mp.players.atRemoteId(targetRemoteId);
 
    // If target player is not found, stop
    if (!target || target.handle === 0) return;
 
    // Call the method to look at another entity, in this case player
    mp.players.local.taskLookAt(target.handle, -1, 2048, 2);
}
</syntaxhighlight>
</syntaxhighlight>
==See also==
==See also==
{{Player_function_c}}
{{Player_function_c}}
[[Category:Clientside API]]
[[Category:Clientside API]]
[[Category:TODO: Example]]

Latest revision as of 13:22, 7 February 2024

Method to task player to look at another entity. Client-side tasks are synced.

Syntax

player.taskLookAt(lookAt, duration, flags, priority);

Required Arguments

  • lookAt: Entity handle or object
  • duration: int
  • flags: int
  • priority: int

Return value

  • Undefined

Example

/**
 * Function to make local player look at another player
 * @param {number} targetRemoteId - Remote(server) id of the player to look at
 */
function localPlayerLookAtPlayer(targetRemoteId) {
    // Get target player from the pool by his remote id
    const target = mp.players.atRemoteId(targetRemoteId);

    // If target player is not found, stop
    if (!target || target.handle === 0) return;

    // Call the method to look at another entity, in this case player
    mp.players.local.taskLookAt(target.handle, -1, 2048, 2);
}

See also