Esc to clear, Enter to open the best match, click an export to open it in its page
Vehicles

Vehicles & Keys

How WHIP's cars work: their states, keys that are items, the ignition, locks, seats, storage and the damage they keep. Read it before you write a script that touches a car; the calls are in the Vehicles API.

Vehicle states

StateMeaningEntity exists?
'out'In the world, position trackedYes
'garaged'Stored in a garageNo
'impounded'Seized (admin), retrievableNo

Cars that are out stay in the world when their player leaves or drives off, and come back where they stood after a restart.

Keys and the ignition

A key is an item, vehicle_key, with metadata { vehicleId, plate, model }, and a token when the car's locks have been changed. It doesn't stack and weighs 0.1 kg.

Stopping an engine (an overheat, a breakdown): HoldVehicleEngine keeps it off and shows the driver your reason until ReleaseVehicleEngine. Otherwise a running engine stays on while its key is in the ignition.

Locking

Players lock with L, or Lock / Unlock on a door's prompt; the lock is saved with the car. From the driver's seat the key may be in the ignition or the inventory; on foot it must be in the inventory, within Config.VehicleLockRange (8 m). Players nearby see two flashes for lock, one for unlock.

Street cars

KindComes fromSaved?vehicleId
OwnedCreateOwnedVehicle, or a street car claimed with ClaimVehicleYesDatabase id (1, 2, 3...)
SessionNPC cars, registered on first useNo1,000,000,000 and up

A street car is registered when a player takes its driver's seat, lockpicks it, opens its boot or refuels it, or a script calls ResolveVehicle. It then has a vehicleId, boot, glovebox, ignition, lock and fuel; if its engine was running, a key is put in its ignition.

Street cars stay locked until lockpicked, then stay unlocked. The rule's range is Config.NpcVehicleLockRange (10 m); 0 turns it off. A resource's local, non-networked car is left alone: its prompts work on that one game and it has no boot.

Seats

Passengers stay in their seat: no sliding into an empty driver's seat, and GTA's shuffle button (H, D-pad right) does nothing. Config.Seats.NoAutoShuffle = false brings GTA's behaviour back. Players change seat with Seats on the F1 wheel or /seats. Read a seat with GetPlayerSeat; whip_core:vehicle:entered fires again on a seat change.

Seat anyone from a script with the seat engine, never with SetPedIntoVehicle or TaskEnterVehicle of your own. It works the same for a player, one of WHIP's NPCs or any other ped. PutInSeat walks them to the seat's own door or puts them in at once, and settles a seat someone sits in (refuse, take another, wait in another and move over, or pull them out). TakeOutOfSeat gets them out, waiting for a moving vehicle to stop or bailing out. HoldInSeat keeps them in until you release it: their exit is held, nobody can pull them out, and they are put back if they are thrown out. Each job runs on the game that runs the ped, and is done only when the server sees them in that seat.

F at a car whose driver is held (a Director rider, a chauffeur a script holds) gets the player in beside them instead of trying to pull them out. A held driver who is fighting that player doesn't let them in. Any other driver is GTA's to pull out, as before.

Storage

Each car's boot (trunk), glovebox and ignition are stores. Their sizes come from the first that is set: the car's own (given when it was made), its model's, its category's (a GTA vehicle class), then the config (VehicleTrunkSlots and the rest). Set models and categories in /whip → Vehicles → Vehicle Adjustments, where either can also turn off its boot or glovebox. Shrinking or turning off slots is refused while a car still has items in them.

Naming a car: vehicle references#

Every vehicle, stat and data export takes the car first, on both sides, in any of these forms:

vehicleId    { id = vehicleId }    { entity = veh }    { plate = 'ABC123' }    { netId = netId }

Writing a vehicle script

On the client, GetVehicleId(entity) returns a car's id from the cache, or nil for a car WHIP hasn't met; ResolveVehicle(entity) then registers it. Send the id to the server. This tow hook works on any car:

-- client.lua
Whip.register(function()
    Whip.core:AddAction({
        id    = 'hook',
        at    = { vehiclePart = 'trunk' },
        label = 'Hook Vehicle',
        canInteract = function(ctx) return exports.whip_core:HasItemFlag('tow_hook') end,
        onSelect = function(ctx)   -- runs once, in its own thread: may wait
            local vehicleId, why = exports.whip_core:GetVehicleId(ctx.entity), nil
            if not vehicleId then vehicleId, why = exports.whip_core:ResolveVehicle(ctx.entity) end
            if not vehicleId then return ctx.refuse(why) end
            TriggerServerEvent('tow:hookVehicle', vehicleId)
        end,
    })
end)

-- server.lua, inside Whip.register
Whip.core:SecureEvent('tow:hookVehicle', {
    rateLimit = 2000,
    params = { {'vehicle', 'vehicle', { anyOwner = true, session = true }} },   -- anybody's car, street cars too
    near   = { at = 'vehicle', range = 8.0 },   -- where the car is now
}, function(source, player, v)
    print(('Towing %s (%s)'):format(v.model, v.plate))
end)
ResolveVehicle waits for the server. Call it in onSelect, a command or another one-off, never in canInteract, a label, a loop or per-frame code. Use GetVehicleId or GetVehicle({ entity = entity }) there.

The other client reads are in the Client vehicles API. On the server, GetVehicle returns one snapshot with the owner, lock, state, netId, stats and storage. Sell a car with TransferVehicle and remove one with DeleteVehicle.

Damage a car keeps#

An owned car keeps its engine and body health, torn-off doors and burst tyres, but not its dents. It's saved when the driver gets out, every VehiclePositionSaveInterval, and when the car is stored or leaves the world. It's put back when the car leaves a garage, or after a restart when a player comes near, and only ever adds damage. Config.VehicleDamage.remember = false turns it off.

A wreck comes back with its engine at Config.VehicleDamage.engineFloor (100): smoking, never on fire. The damage is five stats, read with GetVehicleStat:

StatValue
engineHealth, bodyHealth0 to 1000, GTA's scale; below 400 the engine smokes
doorsOffBit n is door n: 0 front left, 1 front right, 2 rear left, 3 rear right, 4 bonnet, 5 boot
tyresFlat, tyresRimBits over GTA's tyre numbers 0, 1, 2, 3, 4, 5, 45, 47
A repair must clear the damage, or the next spawn puts it back. Call ClearVehicleDamage as you fix the car.

Vehicle data#

SetVehicleData attaches anything that should stick to a car and isn't a gauge, a mod or an item: a part's grade, a finance flag. Values are anything JSON-encodable, never clamped or drawn. The calls are in Vehicle data & handling.

exports.whip_core:SetVehicleData(vehicleId, 'turbo', { grade = 'A' })     -- server
local turbo = exports.whip_core:GetVehicleData(vehicleId, 'turbo')        -- any client
If it is...Use
a number with a range a player should watch movea vehicle stat
items in slotsa store
a GTA mod: colour, extra, wheelproperties
anything else that should stick to the carvehicle data

Events#

Server events, for AddEventHandler; a client can't send them. Don't fire them yourself: listeners would hear something that didn't happen.

EventPayloadFires when
whip_core:vehicle:created{ vehicleId, ownerCharId }Any path makes a vehicle
whip_core:vehicle:damageCleared{ vehicleId }After WHIP clears its recorded damage for a repair. A resource can clear its own damage data here; this does not itself repair the game entity
whip_core:vehicle:ownerChanged{ vehicleId, from, to }A vehicle changes character
whip_core:vehicle:deleted{ vehicleId, ownerCharId, wasOut }A vehicle stops existing. Remove your own per-car data here
whip_core:vehicle:dataChanged{ vehicleId, key, value, old, cleared, resource }Vehicle data is set or removed, by resource
whip_core:vehicle:lockChanged{ vehicleId, plate, locked, source }A car is locked or unlocked by anything; source when a player did it
whip_core:vehicle:spawned{ vehicleId, entity, netId, plate, model, session, temp? }An owned car comes out, or a temp car is made (temp = true)
whip_core:vehicle:despawned{ vehicleId, netId }An owned car leaves the world; the record stays. Its next spawn has a new netId
whip_core:vehicle:released{ vehicleId, reason, temp }WHIP lets go of a street car or removes a temp car; the vehicleId then means nothing. reason: 'expired', 'idle', 'gone', 'stopped', 'despawned', 'deleted', 'released' (ReleaseTag) or 'failed'
whip_core:vehicle:registered{ vehicleId, plate, model, session, source }WHIP takes on a street car (driven, lockpicked, at a pump, AdoptVehicle); session is always true, source the reporting player if any
whip_core:vehicle:claimed{ vehicleId, from, ownerCharId }A street car becomes owned; from is its session id
whip_core:vehicle:plateChanged{ vehicleId, from, to }A car's plate changed
whip_core:vehicle:lockpicked{ vehicleId, plate, source }A player lockpicked a car open
AddEventHandler('whip_core:vehicle:lockpicked', function(data)
    local coords = GetEntityCoords(GetPlayerPed(data.source))
    TriggerClientEvent('dispatch:alert', -1, 'Vehicle Break-In', coords)
end)

Full lists: Server Events and Client Events.

Hearing a stat change#

A stat changing has no event. On the server, OnVehicleStatChanged calls you when a named stat moves on any car, whoever registered it. It's called on a change, not on a clock: "full for ten seconds" needs your own timer.

-- A coolant add-on reacting to whip_autos' boost
exports.whip_core:OnVehicleStatChanged('boost', function(vehicleId, value, previous)
    if value >= 20 then --[[ flat out ]] end
end)