Skip to main content

NetObjectType

The NetObjectType enum represents different types of network objects in the game. This is used with the NetObjectBase:GetType() method to determine the type of a network object.

Values

ValueDescription
NetObjectType.PlayerRepresents a player network object
NetObjectType.VehicleRepresents a vehicle network object

Usage Example

-- Get a network object and check its type
local netObject = someNetObject -- Assume this is a NetObjectBase instance

local objectType = netObject:GetType()

if objectType == NetObjectType.Player then
-- It's a player, we can safely cast to NetPlayer
local player = netObject:AsPlayer()
print("Player nick: " .. player:GetNick())
elseif objectType == NetObjectType.Vehicle then
-- It's a vehicle, we can safely cast to NetVehicle
local vehicle = netObject:AsVehicle()
print("Vehicle position: " .. tostring(vehicle:GetPosition()))
end