From the reference libraryFiveM

marking-a-vehicle-as-player-vehicle-for-game-code

fivem-docs/docs/cookbook/2022/01/06/marking-a-vehicle-as-player-vehicle-for-game-code.md

marking-a-vehicle-as-player-vehicle-for-game-code


title: Marking a vehicle as 'player vehicle' for game code date: 2022-01-06T20:15:28.000+01:00

{{< alert title="Cookbook Archive" color="warning" >}} Note: This Cookbook article was originally published on January 06, 2022. Newer information may exist. {{< /alert >}}

A recent finding from the forums is that the GTA game code checks for the presence of a decorator named player_vehicle on entities to enable/disable certain behavior for player-driven vehicles (e.g. personal vehicles?).

Among other things, this includes:

  • Radio emitters for the radio station the car is playing
  • Some special behavior for entering the vehicle via a door (i.e. the 'enter vehicle' key)

Example code

-- somewhere *once* during initialization
DecorRegister("Player_Vehicle", 3)

-- on a vehicle
if DecorIsRegisteredAsType("Player_Vehicle", 3) then
    DecorSetInt(vehicle, "Player_Vehicle", -1)
end

title: Marking a vehicle as 'player vehicle' for game code date: 2022-01-06T20:15:28.000+01:00

{{< alert title="Cookbook Archive" color="warning" >}} Note: This Cookbook article was originally published on January 06, 2022. Newer information may exist. {{< /alert >}}

A recent finding from the forums is that the GTA game code checks for the presence of a decorator named player_vehicle on entities to enable/disable certain behavior for player-driven vehicles (e.g. personal vehicles?).

Among other things, this includes:

  • Radio emitters for the radio station the car is playing
  • Some special behavior for entering the vehicle via a door (i.e. the 'enter vehicle' key)

Example code

-- somewhere *once* during initialization
DecorRegister("Player_Vehicle", 3)

-- on a vehicle
if DecorIsRegisteredAsType("Player_Vehicle", 3) then
    DecorSetInt(vehicle, "Player_Vehicle", -1)
end
Back to documentation