IfPlayerIsInTarget: Difference between revisions
Jump to navigation
Jump to search
Update Lua API reference |
Complete Lua function catalog |
||
| Line 37: | Line 37: | ||
* The legacy spelling <code>ifPlayerisInTarget</code> is also available, but new resources should use <code>isPlayerInTarget</code>. | * The legacy spelling <code>ifPlayerisInTarget</code> is also available, but new resources should use <code>isPlayerInTarget</code>. | ||
[[Category:Lua Functions]] | |||
[[Category:Server Functions]] | [[Category:Server Functions]] | ||
[[Category:Player Functions]] | [[Category:Player Functions]] | ||
[[Category:Spatial Functions]] | [[Category:Spatial Functions]] | ||
Latest revision as of 09:54, 15 August 2026
ifPlayerIsInTarget
Checks whether a player is inside another player's forward targeting cone.
Syntax
bool ifPlayerIsInTarget(int viewerPlayerId, int targetPlayerId [, number maximumDistance = 25] [, number fieldOfView = 60])
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
viewerPlayerId |
int |
yes | The player whose position and yaw define the targeting cone. |
targetPlayerId |
int |
yes | The player being tested. |
maximumDistance |
number |
no | Maximum range in metres, from 0.1 to 1000. |
fieldOfView |
number |
no | Full horizontal field of view in degrees, from 1 to 180. |
Returns
Returns true when the target is within both the range and forward cone; otherwise returns false.
Examples
Require a nearby player to be in front of the viewer:
if ifPlayerIsInTarget(viewerId, targetId, 8, 70) then
outputChatBox("Target acquired", viewerId)
end
Notes
- Available only in server-side resource scripts.
- This is a compatibility alias of
isPlayerInTarget. - The legacy spelling
ifPlayerisInTargetis also available, but new resources should useisPlayerInTarget.