Table of Contents

Class GlobalObject

Namespace
SampSharp.Entities.SAMP
Assembly
SampSharp.OpenMp.Entities.dll

Represents a component which provides the data and functionality of an object.

public class GlobalObject : WorldEntity
Inheritance
GlobalObject
Inherited Members

Constructors

GlobalObject(IOmpEntityProvider, IObjectsComponent, IObject)

Initializes a new instance of the GlobalObject class.

protected GlobalObject(IOmpEntityProvider entityProvider, IObjectsComponent objects, IObject @object)

Parameters

entityProvider IOmpEntityProvider
objects IObjectsComponent
object IObject

Properties

AttachedObject

Gets the GlobalObject this object is attached to, or null if it is not attached to another object.

public virtual GlobalObject? AttachedObject { get; }

Property Value

GlobalObject

AttachedPlayer

Gets the Player this object is attached to, or null if it is not attached to a player.

public virtual Player? AttachedPlayer { get; }

Property Value

Player

AttachedVehicle

Gets the Vehicle this object is attached to, or null if it is not attached to a vehicle.

public virtual Vehicle? AttachedVehicle { get; }

Property Value

Vehicle

DrawDistance

Gets the draw distance of this object.

public virtual float DrawDistance { get; }

Property Value

float

HasCameraCollision

Gets or sets a value indicating whether this global object collides with players' cameras.

public virtual bool HasCameraCollision { get; set; }

Property Value

bool

IsMoving

Gets a value indicating whether this object is moving.

public virtual bool IsMoving { get; }

Property Value

bool

IsOmpEntityDestroyed

Gets a value indicating whether the open.mp entity counterpart has been destroyed.

protected bool IsOmpEntityDestroyed { get; }

Property Value

bool

ModelId

Gets the model ID of this object.

public virtual int ModelId { get; }

Property Value

int

Methods

AttachTo(GlobalObject, Vector3, Vector3, bool)

Attaches this global object to the specified target GlobalObject.

public virtual void AttachTo(GlobalObject target, Vector3 offset, Vector3 rotation, bool syncRotation = false)

Parameters

target GlobalObject

The GlobalObject to attach this object to.

offset Vector3

The offset position relative to the target object as a Vector3.

rotation Vector3

The rotation to apply to this object as a Vector3.

syncRotation bool

A value indicating whether to synchronize the rotation with the target object.

AttachTo(Player, Vector3, Vector3)

Attaches this global object to the specified target Player.

public virtual void AttachTo(Player target, Vector3 offset, Vector3 rotation)

Parameters

target Player

The Player to attach this object to.

offset Vector3

The offset position relative to the player as a Vector3.

rotation Vector3

The rotation to apply to this object as a Vector3.

AttachTo(Vehicle, Vector3, Vector3)

Attaches this global object to the specified target Vehicle.

public virtual void AttachTo(Vehicle target, Vector3 offset, Vector3 rotation)

Parameters

target Vehicle

The Vehicle to attach this object to.

offset Vector3

The offset position relative to the vehicle as a Vector3.

rotation Vector3

The rotation to apply to this object as a Vector3.

DisableCameraCollisions()

Disables collisions between players' cameras and this global object.

public virtual void DisableCameraCollisions()

GetMaterialData(int)

Gets the material data for the specified material slot, if any has been set.

public virtual ObjectMaterialData? GetMaterialData(int materialIndex)

Parameters

materialIndex int

The material slot index.

Returns

ObjectMaterialData

The material data, or null if no material has been set in that slot.

GetMovingData()

Gets the current movement data of this global object.

public virtual ObjectMoveData GetMovingData()

Returns

ObjectMoveData

The ObjectMoveData describing the current move target.

Move(Vector3, float)

Moves this global object to the specified position with the specified speed.

public virtual TimeSpan Move(Vector3 position, float speed)

Parameters

position Vector3

The position to move this object to as a Vector3.

speed float

The speed at which to move this object.

Returns

TimeSpan

The time for the object to complete the move.

Move(Vector3, float, Vector3)

Moves this global object to the specified position and rotation with the specified speed.

public virtual TimeSpan Move(Vector3 position, float speed, Vector3 rotation)

Parameters

position Vector3

The position to move this object to as a Vector3.

speed float

The speed at which to move this object.

rotation Vector3

The rotation to move this object to as a Vector3.

Returns

TimeSpan

The time for the object to complete the move.

OnDestroyComponent()

This method is invoked before this component is destroyed and removed from its entity.

protected override void OnDestroyComponent()

ResetAttachment()

Resets any current attachment of this global object (to a player, vehicle, or another object).

public virtual void ResetAttachment()

SetMaterial(int, int, string, string, Color)

Sets the material color of this global object.

public virtual void SetMaterial(int materialIndex, int modelId, string txdName, string textureName, Color materialColor)

Parameters

materialIndex int

The material index on the object to change.

modelId int

The model ID on which the replacement texture is located. Use 0 for alpha. Use -1 to change the material color without altering the texture.

txdName string

The name of the TXD file containing the replacement texture (use "none" if not required).

textureName string

The name of the texture to use as the replacement (use "none" if not required).

materialColor Color

The Color of the material to set (use default(Color) to keep the existing material color).

SetMaterialText(int, string, ObjectMaterialSize, string, int, bool, Color, Color, ObjectMaterialTextAlign)

Sets the material text of this global object.

public virtual void SetMaterialText(int materialIndex, string text, ObjectMaterialSize materialSize, string fontface, int fontSize, bool bold, Color foreColor, Color backColor, ObjectMaterialTextAlign textAlignment)

Parameters

materialIndex int

The material index on the object to change.

text string

The text to display on the object (maximum 2048 characters).

materialSize ObjectMaterialSize

The object's material size.

fontface string

The font to use for the text.

fontSize int

The size of the text (maximum 255).

bold bool

A value indicating whether to write the text in bold.

foreColor Color

The Color of the text.

backColor Color

The background Color of the text.

textAlignment ObjectMaterialTextAlign

The alignment of the text.

Stop()

Stops this object from moving.

public virtual void Stop()

ToString()

public override string ToString()

Returns

string

Operators

implicit operator IObject(GlobalObject?)

Performs an implicit conversion from GlobalObject to IObject.

public static implicit operator IObject(GlobalObject? @object)

Parameters

object GlobalObject

Returns

IObject