Skip to content

Add owned vehicle

winject edited this page May 31, 2017 · 2 revisions

Description

Adds an owned vehicle that won't be locked for the player. This event must be only used if the player needs special vehicules. If you are using Garages/Owned vehicles script, it is recommended to add vehicles when the player finished connecting.

Event

"nocarjack:addOwnedVehicle"

Parameters

  • playerID : the current playerId returned from server
  • vehicleNetworkID : the current vehicle network ID

Example

if PlayerBoughtThisCar(playerId, "alpha", 25000) == true --pseudo code
  thisVehicle = CreateVehicle("alpha") --pseudo code
  SetEntityAsMissionEntity(thisVehicle, true, true) --this is mandatory in order to retrieve the network ID
  vehNetworkId = GetNetworkIdFromEntity(thisVehicle) --get our networkID because the vehicle is now persistent
  TriggerClientEvent('nocarjack:addOwnedVehicle', playerId, vehNetworkId) --Send the networkID to the player
end

ℹ️ It is important to set your entity as a MISSION_ENTITY, otherwise the network ID will always be 0.

ℹ️ Entities that are not marked as MISSION_ENTITY can disappear from the client and server at any time.

Clone this wiki locally