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
Value | Description |
---|---|
NetObjectType.Player | Represents a player network object |
NetObjectType.Vehicle | Represents 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
Related Methods
NetObjectBase:GetType()
- Returns the type of the network objectNetObjectBase:AsPlayer()
- Casts to NetPlayer if the object is a playerNetObjectBase:AsVehicle()
- Casts to NetVehicle if the object is a vehicle