CityRP Documentation Repository

Vehicle

Shared Vehicle Metatable.

Functions

ServerVehicle:_AddHP(hp, save) → numberSource ☍

Add HP to a vehicle. This is a higher level interface, so clamps HP in the 0 - 100 range.

Parameters

  • hpnumberHealth to add.
  • savebooleanIf the HP should be saved in the DB (default: true).

Returns

  1. numberHP.
ServerVehicle:AddHP(hp, save) → number, boolean, booleanSource ☍

Adds HP to a vehicle and runs appropriate actions (disabling the vehicle on 0 HP). This is a high level interface, so clamps HP in the 0 - 100 range.

Parameters

  • hpnumberHealth to add.
  • savebooleanIf the HP should be saved in the DB (default: true).

Returns

  1. 1numberHP.
  2. 2booleanthe vehicle is stopping.
  3. 3booleanthe vehicle is starting.
SharedVehicle:CarName() → stringSource ☍

Get the name of a vehicle.

Returns

  1. stringThe name of the vehicle.
SharedVehicle:CarOwner(type) → EntitySource ☍

Get the owner of a vehicle.

Parameters

  • typestring?The type of owner to return (string/name or entity).

Returns

  1. Entityowner entity.
SharedVehicle:GetHP() → numberSource ☍

Get the vehicle's HP.

Returns

  1. numberhealth.
SharedVehicle:getVehicleLocation() → stringSource ☍

Function that returns the current location of the vehicle.

Returns

  1. stringThe position of the vehicle.
SharedVehicle:HasControlPermission(player) → booleanSource ☍

Checks if a player has permission to control this vehicle.

Parameters

  • playerPlayerThe player entity to check permission for.

Returns

  1. booleanTrue if the player has permission, false otherwise.
ServerVehicle:InternalLock()Source ☍

Removed and deprecated.

SharedVehicle:InternalLocked() → booleanSource ☍

Check if a car is internally locked.

Returns

  1. booleanthe vehicle has been internally locked.
ServerVehicle:InternalUnLock()Source ☍

Removed and deprecated.

SharedVehicle:IsDestroyed() → booleanSource ☍

Gets if the vehicle is "destroyed".

Returns

  1. booleanthe vehicle is destroyed.
ServerVehicle:lock(emote)Source ☍

Lock a vehicle.

Parameters

  • emotebooleanAdd notification, sound and lockdelay if true.
SharedVehicle:OwnerWarranted() → booleanSource ☍

Check if a car is marked as wanted.

Returns

  1. booleanthe car is marked as wanted.
ServerVehicle:SetHP(hp, save) → numberSource ☍

Set the vehicle's new HP. This is a low level interface, so does not clamp HP in the 0 - 100 range.

Parameters

  • hpnumberNew health.
  • savebooleanIf the HP should be saved in the DB (default: true).

Returns

  1. numberHP.
ServerVehicle:TurnOff(emote)Source ☍

Turn off a vehicle.

Parameters

  • emotebooleanDetermine if player should emote the action or not.
ServerVehicle:TurnOn(emote)Source ☍

Turn on a vehicle.

Parameters

  • emotebooleanDetermine if player should emote the action or not.
ServerVehicle:unlock(emote)Source ☍

Unlock a vehicle.

Parameters

  • emotebooleanAdd notification, sound and unlockdelay if true.

Classes

SharedVehicleSource ☍

The vehicle metatable, with CityRP's own additions to Garry's Mod's Vehicle.

Fields

ServerplySource ☍
Serverply._NextLockSource ☍
Serverply._NextUnlockSource ☍
SharedVehicle._CarNameClassSource ☍
SharedVehicle._CarNameFallbackSource ☍
ServerVehicle._LockedSource ☍
ServerVehicle._LockedSource ☍