Show / Hide Table of Contents

Class Element

The base class for any and all elements

Inheritance
object
Element
Blip
CollisionShape
DummyElement
Marker
Ped
Pickup
RadarArea
RootElement
Team
Vehicle
Water
WorldObject
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: SlipeServer.Server.Elements
Assembly: SlipeServer.Server.dll
Syntax
public class Element

Constructors

| Edit this page View Source

Element()

Declaration
public Element()
| Edit this page View Source

Element(Element)

Declaration
public Element(Element parent)
Parameters
Type Name Description
Element parent

Fields

| Edit this page View Source

alpha

Declaration
protected byte alpha
Field Value
Type Description
byte
| Edit this page View Source

areCollisionsEnabled

Declaration
protected bool areCollisionsEnabled
Field Value
Type Description
bool
| Edit this page View Source

dimension

Declaration
protected ushort dimension
Field Value
Type Description
ushort
| Edit this page View Source

interior

Declaration
protected byte interior
Field Value
Type Description
byte
| Edit this page View Source

isCallPropagationEnabled

Declaration
protected bool isCallPropagationEnabled
Field Value
Type Description
bool
| Edit this page View Source

isFrozen

Declaration
protected bool isFrozen
Field Value
Type Description
bool
| Edit this page View Source

position

Declaration
protected Vector3 position
Field Value
Type Description
Vector3
| Edit this page View Source

rotation

Declaration
protected Vector3 rotation
Field Value
Type Description
Vector3
| Edit this page View Source

turnVelocity

Declaration
protected Vector3 turnVelocity
Field Value
Type Description
Vector3
| Edit this page View Source

velocity

Declaration
protected Vector3 velocity
Field Value
Type Description
Vector3

Properties

| Edit this page View Source

Alpha

The element's alpha level, alpha of 0 means completely transparent, while 255 is completely opaque.

Declaration
public byte Alpha { get; set; }
Property Value
Type Description
byte
| Edit this page View Source

AreCollisionsEnabled

Indicates whether the element collides with anything else, this includes both world objects, and the default map.

Declaration
public bool AreCollisionsEnabled { get; set; }
Property Value
Type Description
bool
| Edit this page View Source

AssociatedPlayers

Players the element is associated with. These are players that are aware of the existence of this element.

Declaration
public IEnumerable<Player> AssociatedPlayers { get; }
Property Value
Type Description
IEnumerable<Player>
| Edit this page View Source

Associations

Declaration
public IReadOnlyCollection<ElementAssociation> Associations { get; }
Property Value
Type Description
IReadOnlyCollection<ElementAssociation>
| Edit this page View Source

AttachedElements

Elements that are attached to this element

Declaration
public IReadOnlyCollection<ElementAttachment> AttachedElements { get; }
Property Value
Type Description
IReadOnlyCollection<ElementAttachment>
| Edit this page View Source

Attachment

The element's current attachment. Representing this element being attached to a target element.

Declaration
public ElementAttachment? Attachment { get; }
Property Value
Type Description
ElementAttachment
| Edit this page View Source

BroadcastableElementData

A read-only representation of all element data that is broadcastable

Declaration
public CustomData BroadcastableElementData { get; }
Property Value
Type Description
CustomData
| Edit this page View Source

Children

The element's children as in the element tree.

Declaration
public IReadOnlyCollection<Element> Children { get; }
Property Value
Type Description
IReadOnlyCollection<Element>
| Edit this page View Source

Dimension

The element's dimension, elements are only visible in the dimension a player (or rather their camera) is in.

Declaration
public ushort Dimension { get; set; }
Property Value
Type Description
ushort
| Edit this page View Source

ElementDataSubscriptions

Lists all the players that are subscribed to one (or more) element data entries on this element.

Declaration
public ConcurrentDictionary<Player, ConcurrentDictionary<string, bool>> ElementDataSubscriptions { get; set; }
Property Value
Type Description
ConcurrentDictionary<Player, ConcurrentDictionary<string, bool>>
| Edit this page View Source

ElementType

The element type as per MTA's specifications. Multiple C# types can share the same MTA element type.

Declaration
public virtual ElementType ElementType { get; }
Property Value
Type Description
ElementType
| Edit this page View Source

Forward

A vector representing 1 unit in front of the element.

Declaration
public Vector3 Forward { get; }
Property Value
Type Description
Vector3
| Edit this page View Source

Id

Declaration
public ElementId Id { get; set; }
Property Value
Type Description
ElementId
| Edit this page View Source

Interior

The element's interior, interiors are the mechanism the base game uses to not have the insides of buildings visible in the regular world.

Declaration
public byte Interior { get; set; }
Property Value
Type Description
byte
| Edit this page View Source

IsCallPropagationEnabled

Indicates whether a call on this element will be called on its children a well on clients.

Declaration
public bool IsCallPropagationEnabled { get; set; }
Property Value
Type Description
bool
Remarks

Note: This only affects clients, Slipe Server does not do call propagation.

| Edit this page View Source

IsDestroyed

Indicates whether this element has been destroyed

Declaration
public bool IsDestroyed { get; set; }
Property Value
Type Description
bool
| Edit this page View Source

IsFrozen

Indicates whether the element is frozen, frozen elements are unable to move or be moved.

Declaration
public bool IsFrozen { get; set; }
Property Value
Type Description
bool
| Edit this page View Source

IsSync

Indicates whether the current action originates from the handling of a sync packet

Declaration
public bool IsSync { get; set; }
Property Value
Type Description
bool
| Edit this page View Source

IsVisibleToEveryone

When set to false will not create the element for new players that join, or any players when associated directly with the server

Declaration
public bool IsVisibleToEveryone { get; set; }
Property Value
Type Description
bool
| Edit this page View Source

Name

The element name, for Player's this is the nickname, for other elements it's mostly unused.

Declaration
public string Name { get; set; }
Property Value
Type Description
string
| Edit this page View Source

Parent

The element's parent as in the element tree.

Declaration
public Element? Parent { get; set; }
Property Value
Type Description
Element
| Edit this page View Source

Position

The element's position

Declaration
public Vector3 Position { get; set; }
Property Value
Type Description
Vector3
| Edit this page View Source

Right

A vector representating the location 1 unit to the right of the element.

Declaration
public Vector3 Right { get; }
Property Value
Type Description
Vector3
| Edit this page View Source

Rotation

The element's rotation, in euler angles

Declaration
public Vector3 Rotation { get; set; }
Property Value
Type Description
Vector3
| Edit this page View Source

Subscribers

Indicates which elements are subscribed to this element

Declaration
public IEnumerable<Player> Subscribers { get; }
Property Value
Type Description
IEnumerable<Player>
| Edit this page View Source

TimeContext

The time sync context, this is a value used to verify whether synchronisation packets are to be applied or ignored.

Declaration
public byte TimeContext { get; }
Property Value
Type Description
byte
| Edit this page View Source

TurnVelocity

The element's turn velocity.

Declaration
public Vector3 TurnVelocity { get; set; }
Property Value
Type Description
Vector3
| Edit this page View Source

Up

A vector representing the location 1 unit above the element.

Declaration
public Vector3 Up { get; }
Property Value
Type Description
Vector3
| Edit this page View Source

UpdateContext

The element's update context, this indicates the source of the current change that is being applied to an element. This is primarily used to verify whether or not the current changes originate from a sync packet.

Declaration
public ElementUpdateContext UpdateContext { get; protected set; }
Property Value
Type Description
ElementUpdateContext
| Edit this page View Source

Velocity

The element's current velocity.

Declaration
public Vector3 Velocity { get; set; }
Property Value
Type Description
Vector3

Methods

| Edit this page View Source

AddChild(Element)

Adds a child in the element tree to this element

Declaration
public void AddChild(Element element)
Parameters
Type Name Description
Element element

The child to add

| Edit this page View Source

AddSubscriber(Player)

Adds a subscriber to this element

Declaration
public void AddSubscriber(Player player)
Parameters
Type Name Description
Player player

the subscriber to add to this element

| Edit this page View Source

AssociateWith(Player)

Associates an element with a player, causing the element to be created for this player

Declaration
public Element AssociateWith(Player player)
Parameters
Type Name Description
Player player
Returns
Type Description
Element
| Edit this page View Source

AssociateWith(MtaServer)

Associates an element with the server, causing the element to be created for all players on the server

Declaration
public Element AssociateWith(MtaServer server)
Parameters
Type Name Description
MtaServer server

The server to associate the element with

Returns
Type Description
Element
| Edit this page View Source

AttachTo(Element, Vector3?, Vector3?)

Attaches the element to a target element

Declaration
public ElementAttachment AttachTo(Element element, Vector3? positionOffset = null, Vector3? rotationOffset = null)
Parameters
Type Name Description
Element element

Target element to attach to

Vector3? positionOffset

position offset between the element, and the target element

Vector3? rotationOffset

rotation offset between the element, and the target element

Returns
Type Description
ElementAttachment
Exceptions
Type Condition
Exception

Throws an exception when the target element does not have an ID

| Edit this page View Source

CanUpdateSync(byte)

Indicates whether a specific time context is valid to update this element

Declaration
public bool CanUpdateSync(byte remoteContext)
Parameters
Type Name Description
byte remoteContext

The time context to compare

Returns
Type Description
bool
| Edit this page View Source

CreateFor(Player)

Sends packets to create an elementto a set of players Do note that the element will be required to have an id assigned for this to work properly

Declaration
public virtual void CreateFor(Player player)
Parameters
Type Name Description
Player player
| Edit this page View Source

CreateFor(IEnumerable<Player>)

Sends packets to create an elementto a set of players Do note that the element will be required to have an id assigned for this to work properly

Declaration
public virtual void CreateFor(IEnumerable<Player> players)
Parameters
Type Name Description
IEnumerable<Player> players
| Edit this page View Source

Destroy()

Destroys the element, triggering the Destroyed event.

Declaration
public virtual bool Destroy()
Returns
Type Description
bool

A bool indicating whether the element is destroyed, false if it was already destroyed prior to this call.

| Edit this page View Source

DestroyFor(Player)

Sends packets to destroy an elementto a set of players Do note that the element will be required to have an id assigned for this to work properly

Declaration
public virtual void DestroyFor(Player player)
Parameters
Type Name Description
Player player
| Edit this page View Source

DestroyFor(IEnumerable<Player>)

Sends packets to destroy an elementto a set of players Do note that the element will be required to have an id assigned for this to work properly

Declaration
public virtual void DestroyFor(IEnumerable<Player> players)
Parameters
Type Name Description
IEnumerable<Player> players
| Edit this page View Source

DetachFrom(Element?)

Detaches the element from a target element

Declaration
public virtual void DetachFrom(Element? element = null)
Parameters
Type Name Description
Element element

Target element to detach from

| Edit this page View Source

GetAndIncrementTimeContext()

Returns a new time context, to be used when sync updates sent prior to this moment are meant to be invaldiated.

Declaration
public byte GetAndIncrementTimeContext()
Returns
Type Description
byte

The new time context

| Edit this page View Source

GetData(string, bool)

Gets element data on this element if it exists

Declaration
public LuaValue? GetData(string dataName, bool inherit = false)
Parameters
Type Name Description
string dataName

The key to retrieve the stored value from

bool inherit

Whether the value should be attempted to be fetched from the element's parent(s) as well

Returns
Type Description
LuaValue

The value if it exists, null otherwise.

| Edit this page View Source

GetPlayersSubcribedToData(string)

Returns all players subscribes to a specific element data key on this element

Declaration
public IEnumerable<Player> GetPlayersSubcribedToData(string key)
Parameters
Type Name Description
string key

The element data key

Returns
Type Description
IEnumerable<Player>
| Edit this page View Source

IsChildOf(Element)

Indicates whether the element is an (indirect) child of another element, this includes grandchildren.

Declaration
public bool IsChildOf(Element element)
Parameters
Type Name Description
Element element

The element to check against

Returns
Type Description
bool
| Edit this page View Source

IsPlayerSubscribedToData(Player, string)

Checks whether a player is subscribes to a specific data key on this element

Declaration
public bool IsPlayerSubscribedToData(Player player, string key)
Parameters
Type Name Description
Player player

The player to check

string key

The key for the element data to check

Returns
Type Description
bool
| Edit this page View Source

RemoveChild(Element)

Removes a child from this tree in the element tree

Declaration
public void RemoveChild(Element element)
Parameters
Type Name Description
Element element

The child to remove

| Edit this page View Source

RemoveFrom(Player)

Removes an element from being associated with the server, causing the elements to no longer be created for all players

Declaration
public void RemoveFrom(Player player)
Parameters
Type Name Description
Player player
| Edit this page View Source

RemoveFrom(MtaServer)

Removes an element from being associated with the server, causing the elements to no longer be created for all players

Declaration
public void RemoveFrom(MtaServer server)
Parameters
Type Name Description
MtaServer server
| Edit this page View Source

RemoveSubscriber(Player)

Removes a subscriber from this element

Declaration
public void RemoveSubscriber(Player player)
Parameters
Type Name Description
Player player

the subscriber to remove from this element

| Edit this page View Source

RunAsSync(Action, bool)

Runs an action with the sync context

Declaration
public void RunAsSync(Action action, bool value = true)
Parameters
Type Name Description
Action action

the action to run

bool value

Depending whether the context should be sync or not

| Edit this page View Source

RunAsSync(Func<Task>, bool)

Runs an asynchronous action with the sync context

Declaration
public Task RunAsSync(Func<Task> action, bool value = true)
Parameters
Type Name Description
Func<Task> action

the action to run

bool value

Depending whether the context should be sync or not

Returns
Type Description
Task
| Edit this page View Source

RunWithContext(Action, ElementUpdateContext)

Runs an action with a specific context, this context can be fetched using element.UpdateContext

Declaration
public void RunWithContext(Action action, ElementUpdateContext context)
Parameters
Type Name Description
Action action

the action to run

ElementUpdateContext context

the context to run with

| Edit this page View Source

RunWithContext(Func<Task>, ElementUpdateContext)

Runs an asynchronous action with a specific context, this context can be fetched using element.UpdateContext

Declaration
public Task RunWithContext(Func<Task> action, ElementUpdateContext context)
Parameters
Type Name Description
Func<Task> action

the action to run

ElementUpdateContext context

the context to run with

Returns
Type Description
Task
| Edit this page View Source

SetData(string, LuaValue, DataSyncType)

Sets element data on this element

Declaration
public void SetData(string key, LuaValue value, DataSyncType syncType = DataSyncType.Local)
Parameters
Type Name Description
string key

The key to store the value under

LuaValue value

The value to store

DataSyncType syncType

The type of synchronisation to do with this value

| Edit this page View Source

SubscribeToData(Player, string)

Subscribes a player to changes to a specific element data value

Declaration
public void SubscribeToData(Player player, string key)
Parameters
Type Name Description
Player player

The player to subscribe

string key

The key of the data to subscribe to

| Edit this page View Source

UnsubscribeFromAllData(Player)

Unsubscribes an element from all element data on this element

Declaration
public void UnsubscribeFromAllData(Player player)
Parameters
Type Name Description
Player player
| Edit this page View Source

UnsubscribeFromData(Player, string)

Unsubscribes a player from changes to a specific element data value

Declaration
public void UnsubscribeFromData(Player player, string key)
Parameters
Type Name Description
Player player

The player to unsubscribe

string key

The key of the data to unsubscribe from

| Edit this page View Source

UpdateAssociatedPlayers()

Declaration
protected void UpdateAssociatedPlayers()

Events

| Edit this page View Source

AlphaChanged

Declaration
public event ElementChangedEventHandler<byte>? AlphaChanged
Event Type
Type Description
ElementChangedEventHandler<byte>
| Edit this page View Source

AssociatedWith

Declaration
public event ElementEventHandler<Element, ElementAssociatedWithEventArgs>? AssociatedWith
Event Type
Type Description
ElementEventHandler<Element, ElementAssociatedWithEventArgs>
| Edit this page View Source

Attached

Declaration
public event ElementEventHandler<Element, ElementAttachedEventArgs>? Attached
Event Type
Type Description
ElementEventHandler<Element, ElementAttachedEventArgs>
| Edit this page View Source

AttachedOffsetChanged

Declaration
public event ElementEventHandler<Element, ElementAttachOffsetsChangedArgs>? AttachedOffsetChanged
Event Type
Type Description
ElementEventHandler<Element, ElementAttachOffsetsChangedArgs>
| Edit this page View Source

CallPropagationChanged

Declaration
public event ElementChangedEventHandler<bool>? CallPropagationChanged
Event Type
Type Description
ElementChangedEventHandler<bool>
| Edit this page View Source

CollisionEnabledChanged

Declaration
public event ElementChangedEventHandler<bool>? CollisionEnabledChanged
Event Type
Type Description
ElementChangedEventHandler<bool>
| Edit this page View Source

DataChanged

Declaration
public event ElementEventHandler<Element, ElementDataChangedArgs>? DataChanged
Event Type
Type Description
ElementEventHandler<Element, ElementDataChangedArgs>
| Edit this page View Source

Destroyed

Declaration
public event Action<Element>? Destroyed
Event Type
Type Description
Action<Element>
| Edit this page View Source

Detached

Declaration
public event ElementEventHandler<Element, ElementDetachedEventArgs>? Detached
Event Type
Type Description
ElementEventHandler<Element, ElementDetachedEventArgs>
| Edit this page View Source

DimensionChanged

Declaration
public event ElementChangedEventHandler<ushort>? DimensionChanged
Event Type
Type Description
ElementChangedEventHandler<ushort>
| Edit this page View Source

FrozenChanged

Declaration
public event ElementChangedEventHandler<bool>? FrozenChanged
Event Type
Type Description
ElementChangedEventHandler<bool>
| Edit this page View Source

IdChanged

Declaration
public event ElementChangedEventHandler<Element, ElementId>? IdChanged
Event Type
Type Description
ElementChangedEventHandler<Element, ElementId>
| Edit this page View Source

InteriorChanged

Declaration
public event ElementChangedEventHandler<byte>? InteriorChanged
Event Type
Type Description
ElementChangedEventHandler<byte>
| Edit this page View Source

NameChanged

Declaration
public event ElementChangedEventHandler<string>? NameChanged
Event Type
Type Description
ElementChangedEventHandler<string>
| Edit this page View Source

PositionChanged

Declaration
public event ElementChangedEventHandler<Vector3>? PositionChanged
Event Type
Type Description
ElementChangedEventHandler<Vector3>
| Edit this page View Source

RemovedFrom

Declaration
public event ElementEventHandler<Element, ElementAssociatedWithEventArgs>? RemovedFrom
Event Type
Type Description
ElementEventHandler<Element, ElementAssociatedWithEventArgs>
| Edit this page View Source

RotationChanged

Declaration
public event ElementChangedEventHandler<Vector3>? RotationChanged
Event Type
Type Description
ElementChangedEventHandler<Vector3>
| Edit this page View Source

TurnVelocityChanged

Declaration
public event ElementChangedEventHandler<Vector3>? TurnVelocityChanged
Event Type
Type Description
ElementChangedEventHandler<Vector3>
| Edit this page View Source

VelocityChanged

Declaration
public event ElementChangedEventHandler<Vector3>? VelocityChanged
Event Type
Type Description
ElementChangedEventHandler<Vector3>

Operators

| Edit this page View Source

implicit operator LuaValue(Element)

Returns a Lua value for the element, this is used for any lua event communication.

Declaration
public static implicit operator LuaValue(Element value)
Parameters
Type Name Description
Element value
Returns
Type Description
LuaValue

Extension Methods

ElementPropertyRelayingExtensions.AddRelayers(Element)
ElementPropertyRelayingExtensions.RelayChange(Element, Packet)
  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX