GE Lua Documentation

Press F to search!

vehicleSwitched

Definition


-- @/lua/ge/main.lua:708

-- when the player is switching vehicles
function vehicleSwitched(oldVehicle, newVehicle, player)
  profilerPushEvent('vehicleSwitched')
  local oid = oldVehicle and oldVehicle:getId() or -1
  local nid = newVehicle and newVehicle:getId() or -1
  -- local oldinfo = oldVehicle and ("id "..dumps(oid).." ("..oldVehicle:getPath()..")") or dumps(oldVehicle)
  -- local newinfo = newVehicle and ("id "..dumps(nid).." ("..newVehicle:getPath()..")") or dumps(newVehicle)
  --log('I', 'main', "Player #"..dumps(player).." vehicle switched from: "..oldinfo.." to: "..newinfo)
  --OnlineServiceProvider.setStat('meters_driven', 1)
  invalidatePlayerVehicles()
  extensions.hook('onVehicleSwitched', oid, nid, player)
  guihooks.trigger('VehicleFocusChanged', {id = nid, mode = true})
  profilerPopEvent('vehicleSwitched')
end

Callers

@/lua/ge/main.lua
-- Callback when vehicles are activated or deactivated (e.g. by the traffic pooling system)
-- This is unrelated to tabbing into other cars (that would be the vehicleSwitched() function)
function vehicleActiveChanged(vehicleID, active)