---
title: "GetPlayerCameraTargetVehicle | open.mp"
description: "Get the ID of the vehicle the player is looking at."
canonical: https://omp.itsneufox.com/docs/scripting/functions/GetPlayerCameraTargetVehicle
language: en
---

# GetPlayerCameraTargetVehicle

warning

This function was added in SA-MP 0.3.7 and will not work in earlier versions!

## Description

Get the ID of the vehicle the player is looking at.

| Name | Description |
| --- | --- |
| playerid | The ID of the player to check. |

## Returns

The vehicle ID of the vehicle the player is looking at. `INVALID_VEHICLE_ID` if none.

## Examples

```c
new globalVehicleID;

public OnGameModeInit()
{
    globalVehicleID = CreateVehicle(596, 0.0, 0.0, 3.0, 0.0, 0.0, 0.0, -1, -1, -1);
    return 1;
}

public OnPlayerConnect(playerid)
{
    EnablePlayerCameraTarget(playerid, true);
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (!strcmp(cmdtext, "/check", true))
    {
        new vehicleid = GetPlayerCameraTargetVehicle(playerid);
        if (vehicleid == globalVehicleID)
        {
            SendClientMessage(playerid, -1, "You're looking at your vehicle!");
        }
        else
        {
            SendClientMessage(playerid, -1, "You're not looking at your vehicle.");
        }
        return 1;
    }
    return 0;
}
```

## Notes

note

This function can (obviously) only return one vehicle ID at a time, while the player may be looking at multiple. It generally seems to detect the closest vehicle first.

warning

This function is disabled by default to save bandwidth. Use [EnablePlayerCameraTarget](https://omp.itsneufox.com/docs/scripting/functions/EnablePlayerCameraTarget) to enable it for each player.

## Related Functions

-   [GetPlayerCameraTargetPlayer](https://omp.itsneufox.com/docs/scripting/functions/GetPlayerCameraTargetPlayer): Get the ID of the player a player is looking at.
-   [GetPlayerCameraTargetObject](https://omp.itsneufox.com/docs/scripting/functions/GetPlayerCameraTargetObject): Get the ID of the object a player is looking at.
-   [EnablePlayerCameraTarget](https://omp.itsneufox.com/docs/scripting/functions/EnablePlayerCameraTarget): Enable player camera targetting functions.
-   [GetPlayerCameraFrontVector](https://omp.itsneufox.com/docs/scripting/functions/GetPlayerCameraFrontVector): Get the player's camera fron
