Skip to main content

NetVehicle

Network representation of a vehicle in the game. NetVehicle inherits from NetObject and provides vehicle-specific functionality.

Class Hierarchy

Instance Methods

Inherited Methods

From NetObjectBase:

NetObjectBase:GetPosition(): vec3

Returns the position of the object.

NetObjectBase:GetRotation(): vec3

Returns the rotation of the object.

NetObjectBase:GetHealth(): number

Returns the current health of the object.

NetObjectBase:GetMaxHealth(): number

Returns the maximum health of the object.

NetObjectBase:GetVelocity(): vec3

Returns the velocity of the object.

NetObjectBase:GetNetId(): number

Returns the network ID of the object.

NetObjectBase:SetData(key: string, value: any): boolean

Sets generic data on the object. Value must be a number, string, bool, vec2, vec3, vec4, or quat. Returns true if the data was set successfully, false otherwise (for unsupported types).

NetObjectBase:GetData(key: string): any

Gets generic data from the object.

NetObjectBase:AsPlayer(): NetPlayer | nil

Returns NetPlayer instance if the object is a player, nil otherwise.

NetObjectBase:AsVehicle(): NetVehicle | nil

Returns NetVehicle instance if the object is a vehicle, nil otherwise.

NetObjectBase:GetType(): NetObjectType

Returns the network object type. Use NetObjectType enum to compare types.

NetVehicles are involved in several vehicle-related events:

Shared Events

Client Events

Usage Example

-- Example: Handle vehicle damage event
Event.Add("OnVehicleDamage", function(vehicle, damager, loss, hitbone, weaponHash, hitposition)
print("Vehicle took " .. loss .. " damage")
print("Vehicle position: " .. tostring(vehicle:GetPosition()))

-- Check if it's low health
if vehicle:GetHealth() < 100 then
print("Vehicle is critically damaged!")
end
end)