Table of Contents

Class PlayerObject

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

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

public class PlayerObject : WorldEntity
Inheritance
PlayerObject
Inherited Members

Constructors

PlayerObject(IOmpEntityProvider, IPlayerObjectData, IPlayerObject)

Initializes a new instance of the PlayerObject class.

protected PlayerObject(IOmpEntityProvider entityProvider, IPlayerObjectData playerObjects, IPlayerObject playerObject)

Parameters

entityProvider IOmpEntityProvider
playerObjects IPlayerObjectData
playerObject IPlayerObject

Properties

AttachedPlayer

Gets the Player this player 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 player 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 player object.

public virtual float DrawDistance { get; }

Property Value

float

HasCameraCollision

Gets or sets a value indicating whether this player object collides with the player's camera.

public virtual bool HasCameraCollision { get; set; }

Property Value

bool

IsMoving

Gets a value indicating whether this player 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 player object.

public virtual int ModelId { get; }

Property Value

int

Methods

AttachTo(Player, Vector3, Vector3)

Attaches this 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.

rotation Vector3

The rotation to apply to this object.

AttachTo(PlayerObject, Vector3, Vector3)

Attaches this object to the specified target PlayerObject.

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

Parameters

target PlayerObject

The player object to attach this object to.

offset Vector3

The offset position relative to the target object.

rotation Vector3

The rotation to apply to this object.

AttachTo(Vehicle, Vector3, Vector3)

Attaches this 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.

rotation Vector3

The rotation to apply to this object.

DisableCameraCollisions()

Disables collisions between players' cameras and this player 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 player object.

public virtual ObjectMoveData GetMovingData()

Returns

ObjectMoveData

The ObjectMoveData describing the current move target.

Move(Vector3, float)

Moves this player 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 player object to as a Vector3.

speed float

The speed at which to move this player object.

Returns

TimeSpan

The time for the object to complete the move.

Move(Vector3, float, Vector3)

Moves this player 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 player object to as a Vector3.

speed float

The speed at which to move this player object.

rotation Vector3

The rotation to move this player 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 player object (to a player, vehicle, or another object).

public virtual void ResetAttachment()

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

Sets the material color of this player 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 player 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 player object from moving.

public virtual void Stop()

ToString()

public override string ToString()

Returns

string

Operators

implicit operator IPlayerObject(PlayerObject?)

Performs an implicit conversion from PlayerObject to IPlayerObject.

public static implicit operator IPlayerObject(PlayerObject? playerObject)

Parameters

playerObject PlayerObject

Returns

IPlayerObject