API ReferenceGE Extensionscareermodules
Career Player Driving Module
M.dependencies = {'career_career'}
Dependencies
M.dependencies = {'career_career'}Manages the player's driving state in career freeroam: traffic spawning, parking detection, police pursuits, vehicle recovery, and garage teleportation. Acts as the bridge between career systems and the traffic/parking gameplay modules.
Internal State
| Field | Type | Description |
|---|---|---|
M.ensureTraffic | bool | Flag to re-spawn traffic on next opportunity (set in onCareerModulesActivated, cleared in setupTraffic) |
M.debugMode | varies | Assigned as not shipping_build |
M.preStart | varies | Assigned as true |
Public API
| Function | Signature | Description |
|---|---|---|
M.getPlayerData | () → table | Returns player driving state (parking, traffic, pursuit data) |
M.retrieveFavoriteVehicle | () | Spawns/teleports the favorite vehicle to the player's location |
M.playerPursuitActive | () → bool | Whether the player is in an active police pursuit |
M.resetPlayerState | () | Resets player parking/traffic tracking and pursuit state |
M.teleportToGarage | (garageId, veh, resetVeh) | Teleports vehicle (and trailer) to a garage, turns off ignition |
M.showPosition | (pos) | Points camera/walking direction at a world position; plays cam path if obstructed |
Lifecycle Hooks
| Hook | Purpose |
|---|---|
M.onPlayerCameraReady | Spawns traffic during loading screen |
M.onTrafficStarted | Inserts player into traffic system, sets police probability |
M.onTrafficStopped | Clears player traffic data; re-spawns if ensureTraffic flag set |
M.onPursuitAction | Handles pursuit start/evade/arrest (fines, recovery prompt) |
M.onVehicleParkingStatus | Tracks parking valid/exit events |
M.onVehicleSwitched | Updates player data for new vehicle |
M.onCareerModulesActivated | Sets ensureTraffic flag, calls setup if already in level |
M.onClientStartMission | Triggers traffic setup |
M.onUpdate | Pre-start light trigger cycling; pursuit stuck-timer (force evade after 10s) |
Dependencies
career_career- active/tutorial checkscareer_modules_inventory- favorite vehicle, vehicle spawningcareer_modules_payment- police arrest finescareer_modules_fuel- minimum refueling check after garage teleportcareer_modules_insurance_insurance- repair state for favorite vehiclegameplay_traffic,gameplay_police,gameplay_parking- traffic subsystemscore_trailerRespawn- trailer teleportation handling
Player Data Structure
playerData = {
trafficActive = 8, -- number of active traffic vehicles
isParked = false, -- currently in a valid parking spot
traffic = { ... }, -- traffic system data for player vehicle
parking = { ... }, -- parking tracking data
}Traffic Setup
Traffic amount is read from settings with auto-calculation fallback. Police are temporarily set to 0 by default. Career-specific adjustments:
enableRandomEvents = falsearrestRadius = 15,evadeTime = 30parkingPrecision = 0.2(relaxed detection)
Usage Example
-- Check if player is being chased
if career_modules_playerDriving.playerPursuitActive() then
-- disable certain actions
end
-- Teleport to garage
career_modules_playerDriving.teleportToGarage(garageId, playerVeh, true)See Also
- quickTravel - Taxi-based teleportation
- permissions - Recovery action permissions