er2.findVehicle 105
Find a vehicle from it's unique Id (network safe).
Useful in case you have to reference a specific vehicle across different phases or players, based on it's unique Id, for example, passed trough a global variable
Return value
Return Type | Description |
---|---|
Soldier | Vehicle corresponding to the provided Id |
Parameters
Parameter | Type | Description |
---|---|---|
1 | integer | Unique Id of the searched vehicle |
Examples
Example 165
-- Spawn a vehicle
local vehicle = spawnVehicle("JeepWillys", vec3(0, 1.5, 0), vec3(0, 90, 0))
-- Acquire the unique id of the spawned vehicle
local vehicleUniqueId = vehicle.getUniqueId()
-- Retrieve the vehicle using its unique id
local foundVehicle = er2.findVehicle(vehicleUniqueId)
Example 166
-- Spawn a vehicle
local vehicle = spawnVehicle("JeepWillys", vec3(0, 1.5, 0), vec3(0, 90, 0))
if vehicle then
-- Acquire the unique id of the spawned vehicle
local vehicleUniqueId = vehicle.getUniqueId()
print("Vehicle Unique ID: " .. vehicleUniqueId, 3)
-- ... (later in the script or in a subsequent phase)
-- Retrieve the vehicle using its unique id
local foundVehicle = er2.findVehicle(vehicleUniqueId)
if foundVehicle then
print("Vehicle found using unique id!", 3)
else
print("Vehicle not found.", 3)
end
end