IfPlayerIsInTarget
Jump to navigation
Jump to search
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.